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
bea839c1
Commit
bea839c1
authored
Apr 24, 2013
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auhal: correctly remove devices from list when being unplugged at runtime (close #8476)
parent
19200d56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletion
+35
-1
modules/audio_output/auhal.c
modules/audio_output/auhal.c
+35
-1
No files found.
modules/audio_output/auhal.c
View file @
bea839c1
...
...
@@ -110,6 +110,8 @@ struct aout_sys_t
int
i_rate
;
/* media sample rate */
int
i_bytes_per_sample
;
CFArrayRef
device_list
;
vlc_mutex_t
lock
;
vlc_cond_t
cond
;
};
...
...
@@ -185,6 +187,7 @@ static int Open(vlc_object_t *obj)
p_aout
->
volume_set
=
VolumeSet
;
p_aout
->
mute_set
=
MuteSet
;
p_aout
->
device_select
=
SwitchAudioDevice
;
p_sys
->
device_list
=
CFArrayCreate
(
kCFAllocatorDefault
,
NULL
,
0
,
NULL
);
/* Attach a Listener so that we are notified of a change in the Device setup */
AudioObjectPropertyAddress
audioDevicesAddress
=
{
kAudioHardwarePropertyDevices
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
...
...
@@ -233,6 +236,8 @@ static void Close(vlc_object_t *obj)
config_PutPsz
(
p_aout
,
"auhal-audio-device"
,
aout_DeviceGet
(
p_aout
));
CFRelease
(
p_sys
->
device_list
);
vlc_mutex_destroy
(
&
p_sys
->
lock
);
vlc_cond_destroy
(
&
p_sys
->
cond
);
...
...
@@ -969,9 +974,13 @@ static void RebuildDeviceList(audio_output_t * p_aout)
AudioObjectID
defaultDeviceID
=
0
;
AudioObjectID
*
deviceIDs
;
UInt32
numberOfDevices
;
CFMutableArrayRef
currentListOfDevices
;
struct
aout_sys_t
*
p_sys
=
p_aout
->
sys
;
/* setup local array */
currentListOfDevices
=
CFArrayCreateMutable
(
kCFAllocatorDefault
,
0
,
NULL
);
/* Get number of devices */
AudioObjectPropertyAddress
audioDevicesAddress
=
{
kAudioHardwarePropertyDevices
,
kAudioObjectPropertyScopeGlobal
,
kAudioObjectPropertyElementMaster
};
err
=
AudioObjectGetPropertyDataSize
(
kAudioObjectSystemObject
,
&
audioDevicesAddress
,
0
,
NULL
,
&
propertySize
);
...
...
@@ -1046,6 +1055,7 @@ static void RebuildDeviceList(audio_output_t * p_aout)
}
ReportDevice
(
p_aout
,
i_id
,
psz_name
);
CFArrayAppendValue
(
currentListOfDevices
,
CFNumberCreate
(
kCFAllocatorDefault
,
kCFNumberSInt32Type
,
&
i_id
));
if
(
AudioDeviceSupportsDigital
(
p_aout
,
deviceIDs
[
i
]))
{
b_digital
=
true
;
...
...
@@ -1054,6 +1064,7 @@ static void RebuildDeviceList(audio_output_t * p_aout)
asprintf
(
&
psz_encoded_name
,
_
(
"%s (Encoded Output)"
),
psz_name
);
i_id
=
i_id
|
AOUT_VAR_SPDIF_FLAG
;
ReportDevice
(
p_aout
,
i_id
,
psz_encoded_name
);
CFArrayAppendValue
(
currentListOfDevices
,
CFNumberCreate
(
kCFAllocatorDefault
,
kCFNumberSInt32Type
,
&
i_id
));
free
(
psz_encoded_name
);
}
...
...
@@ -1064,7 +1075,30 @@ static void RebuildDeviceList(audio_output_t * p_aout)
free
(
psz_name
);
}
// TODO: fix default audio device
CFIndex
count
=
0
;
if
(
p_sys
->
device_list
)
count
=
CFArrayGetCount
(
p_sys
->
device_list
);
if
(
count
>
0
)
{
CFShow
(
currentListOfDevices
);
CFShow
(
p_sys
->
device_list
);
CFNumberRef
cfn_device_id
;
int
i_device_id
=
0
;
for
(
CFIndex
x
=
0
;
x
<
count
;
x
++
)
{
if
(
!
CFArrayContainsValue
(
currentListOfDevices
,
CFRangeMake
(
0
,
count
),
CFArrayGetValueAtIndex
(
p_sys
->
device_list
,
x
)))
{
cfn_device_id
=
CFArrayGetValueAtIndex
(
p_sys
->
device_list
,
x
);
if
(
cfn_device_id
)
{
CFNumberGetValue
(
cfn_device_id
,
kCFNumberSInt32Type
,
&
i_device_id
);
ReportDevice
(
p_aout
,
i_device_id
,
NULL
);
}
}
}
}
CFRelease
(
p_sys
->
device_list
);
p_sys
->
device_list
=
CFArrayCreateCopy
(
kCFAllocatorDefault
,
currentListOfDevices
);
CFRelease
(
currentListOfDevices
);
ReportDevice
(
p_aout
,
0
,
_
(
"System Sound Output Device"
));
free
(
deviceIDs
);
...
...
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