Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
de2b5038
Commit
de2b5038
authored
May 13, 2013
by
David Fuhrmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auhal: better deregistration of deviceAlive and audioStreams callbacks
parent
c1cb426c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
28 deletions
+46
-28
modules/audio_output/auhal.c
modules/audio_output/auhal.c
+46
-28
No files found.
modules/audio_output/auhal.c
View file @
de2b5038
...
...
@@ -147,7 +147,7 @@ static OSStatus RenderCallbackSPDIF (AudioDeviceID, const AudioTimeStamp *,
static
OSStatus
HardwareListener
(
AudioObjectID
,
UInt32
,
const
AudioObjectPropertyAddress
*
,
void
*
);
static
OSStatus
StreamListener
(
AudioObjectID
,
UInt32
,
const
AudioObjectPropertyAddress
*
,
void
*
);
static
int
RegisterAudioStreamsCallback
(
audio_output_t
*
,
AudioDeviceID
);
static
int
ManageAudioStreamsCallback
(
audio_output_t
*
p_aout
,
AudioDeviceID
i_dev_id
,
bool
b_register
);
static
int
AudioDeviceHasOutput
(
AudioDeviceID
);
static
int
AudioDeviceSupportsDigital
(
audio_output_t
*
,
AudioDeviceID
);
static
int
AudioStreamSupportsDigital
(
audio_output_t
*
,
AudioStreamID
);
...
...
@@ -226,19 +226,20 @@ static void Close(vlc_object_t *obj)
if
(
err
!=
noErr
)
msg_Err
(
p_aout
,
"AudioHardwareRemovePropertyListener failed [%4.4s]"
,
(
char
*
)
&
err
);
/* remove audio device alive callback */
AudioObjectPropertyAddress
deviceAliveAddress
=
{
kAudioDevicePropertyDeviceIsAlive
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
err
=
AudioObjectRemovePropertyListener
(
p_sys
->
i_selected_dev
,
&
deviceAliveAddress
,
HardwareListener
,
(
void
*
)
p_aout
);
if
(
err
!=
noErr
)
msg_Err
(
p_aout
,
"failed to remove audio device life checker [%4.4s]"
,
(
char
*
)
&
err
);
/* remove audio streams callback */
if
(
p_sys
->
i_stream_id
>
0
)
{
AudioObjectPropertyAddress
physicalFormatsAddress
=
{
kAudioStreamPropertyAvailablePhysicalFormats
,
kAudioObjectPropertyScopeGlobal
,
0
};
err
=
AudioObjectRemovePropertyListener
(
p_sys
->
i_stream_id
,
&
physicalFormatsAddress
,
HardwareListener
,
(
void
*
)
p_aout
);
if
(
err
!=
noErr
)
msg_Err
(
p_aout
,
"failed to remove audio device property streams callback [%4.4s]"
,
(
char
*
)
&
err
);
/* remove streams callbacks */
CFIndex
count
=
CFArrayGetCount
(
p_sys
->
device_list
);
if
(
count
>
0
)
{
for
(
CFIndex
x
=
0
;
x
<
count
;
x
++
)
{
AudioDeviceID
deviceId
=
0
;
CFNumberRef
cfn_device_id
=
CFArrayGetValueAtIndex
(
p_sys
->
device_list
,
x
);
if
(
!
cfn_device_id
)
continue
;
CFNumberGetValue
(
cfn_device_id
,
kCFNumberSInt32Type
,
&
deviceId
);
if
(
!
(
deviceId
&
AOUT_VAR_SPDIF_FLAG
))
{
ManageAudioStreamsCallback
(
p_aout
,
deviceId
,
false
);
}
}
}
config_PutPsz
(
p_aout
,
"auhal-audio-device"
,
aout_DeviceGet
(
p_aout
));
...
...
@@ -1058,6 +1059,16 @@ static void Stop(audio_output_t *p_aout)
msg_Err
(
p_aout
,
"Failed to release hogmode [%4.4s]"
,
(
char
*
)
&
err
);
}
/* remove audio device alive callback */
AudioObjectPropertyAddress
deviceAliveAddress
=
{
kAudioDevicePropertyDeviceIsAlive
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
err
=
AudioObjectRemovePropertyListener
(
p_sys
->
i_selected_dev
,
&
deviceAliveAddress
,
HardwareListener
,
(
void
*
)
p_aout
);
if
(
err
!=
noErr
)
{
/* Be tolerant, only give a warning here */
msg_Warn
(
p_aout
,
"failed to remove audio device life checker [%4.4s]"
,
(
char
*
)
&
err
);
}
p_sys
->
i_bytes_per_sample
=
0
;
p_sys
->
b_digital
=
false
;
...
...
@@ -1169,7 +1180,7 @@ static void RebuildDeviceList(audio_output_t * p_aout)
}
// TODO: only register once for each device
RegisterAudioStreamsCallback
(
p_aout
,
deviceIDs
[
i
]
);
ManageAudioStreamsCallback
(
p_aout
,
deviceIDs
[
i
],
true
);
CFRelease
(
device_name_ref
);
free
(
psz_name
);
...
...
@@ -1469,8 +1480,6 @@ static OSStatus HardwareListener(AudioObjectID inObjectID, UInt32 inNumberAddre
OSStatus
err
=
noErr
;
audio_output_t
*
p_aout
=
(
audio_output_t
*
)
inClientData
;
VLC_UNUSED
(
inObjectID
);
VLC_UNUSED
(
inNumberAddresses
);
VLC_UNUSED
(
inAddresses
);
if
(
!
p_aout
)
return
-
1
;
...
...
@@ -1524,7 +1533,7 @@ static OSStatus StreamListener(AudioObjectID inObjectID, UInt32 inNumberAddress
#pragma mark -
#pragma mark helpers
static
int
RegisterAudioStreamsCallback
(
audio_output_t
*
p_aout
,
AudioDeviceID
i_dev_id
)
static
int
ManageAudioStreamsCallback
(
audio_output_t
*
p_aout
,
AudioDeviceID
i_dev_id
,
bool
b_register
)
{
OSStatus
err
=
noErr
;
UInt32
i_param_size
=
0
;
...
...
@@ -1535,7 +1544,7 @@ static int RegisterAudioStreamsCallback(audio_output_t *p_aout, AudioDeviceID i_
AudioObjectPropertyAddress
streamsAddress
=
{
kAudioDevicePropertyStreams
,
kAudioDevicePropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
err
=
AudioObjectGetPropertyDataSize
(
i_dev_id
,
&
streamsAddress
,
0
,
NULL
,
&
i_param_size
);
if
(
err
!=
noErr
)
{
msg_Err
(
p_aout
,
"could not get number of streams
[%4.4s] (%i)"
,
(
char
*
)
&
err
,
(
int32_t
)
err
);
msg_Err
(
p_aout
,
"could not get number of streams
for device id %i [%4.4s]"
,
i_dev_id
,
(
char
*
)
&
err
);
return
VLC_EGENERIC
;
}
...
...
@@ -1553,17 +1562,26 @@ static int RegisterAudioStreamsCallback(audio_output_t *p_aout, AudioDeviceID i_
for
(
int
i
=
0
;
i
<
i_streams
;
i
++
)
{
/* get notified when physical formats change */
AudioObjectPropertyAddress
physicalFormatsAddress
=
{
kAudioStreamPropertyAvailablePhysicalFormats
,
kAudioObjectPropertyScopeGlobal
,
0
};
err
=
AudioObjectAddPropertyListener
(
p_streams
[
i
],
&
physicalFormatsAddress
,
HardwareListener
,
(
void
*
)
p_aout
);
if
(
err
!=
noErr
)
{
// nope just means that we already have a callback
if
(
err
==
kAudioHardwareIllegalOperationError
)
{
msg_Dbg
(
p_aout
,
"could not set audio stream formats property callback on stream id %i, callback already set? [%4.4s]"
,
p_streams
[
i
],
(
char
*
)
&
err
);
}
else
{
msg_Warn
(
p_aout
,
"could not set audio stream formats property callback on stream id %i [%4.4s]"
,
p_streams
[
i
],
(
char
*
)
&
err
);
if
(
b_register
)
{
err
=
AudioObjectAddPropertyListener
(
p_streams
[
i
],
&
physicalFormatsAddress
,
HardwareListener
,
(
void
*
)
p_aout
);
if
(
err
!=
noErr
)
{
// nope just means that we already have a callback
if
(
err
==
kAudioHardwareIllegalOperationError
)
{
msg_Warn
(
p_aout
,
"could not set audio stream formats property callback on stream id %i, callback already set? [%4.4s]"
,
p_streams
[
i
],
(
char
*
)
&
err
);
}
else
{
msg_Err
(
p_aout
,
"could not set audio stream formats property callback on stream id %i [%4.4s]"
,
p_streams
[
i
],
(
char
*
)
&
err
);
}
}
}
else
{
/* unregister callback */
err
=
AudioObjectRemovePropertyListener
(
p_streams
[
i
],
&
physicalFormatsAddress
,
HardwareListener
,
(
void
*
)
p_aout
);
if
(
err
!=
noErr
)
msg_Err
(
p_aout
,
"failed to remove audio device property streams callback [%4.4s]"
,
(
char
*
)
&
err
);
}
}
free
(
p_streams
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment