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
587d8cd4
Commit
587d8cd4
authored
May 26, 2013
by
David Fuhrmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auhal: locking for access to i_selected_device
parent
14f64a46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
modules/audio_output/auhal.c
modules/audio_output/auhal.c
+17
-10
No files found.
modules/audio_output/auhal.c
View file @
587d8cd4
...
...
@@ -111,7 +111,8 @@ struct aout_sys_t
int
i_bytes_per_sample
;
CFArrayRef
device_list
;
vlc_mutex_t
device_list_lock
;
vlc_mutex_t
var_lock
;
/* protects access to device_list and i_selected_dev */
float
f_volume
;
bool
b_mute
;
...
...
@@ -184,7 +185,7 @@ static int Open(vlc_object_t *obj)
OSStatus
err
=
noErr
;
vlc_mutex_init
(
&
p_sys
->
device_list
_lock
);
vlc_mutex_init
(
&
p_sys
->
var
_lock
);
vlc_mutex_init
(
&
p_sys
->
lock
);
vlc_cond_init
(
&
p_sys
->
cond
);
p_sys
->
b_digital
=
false
;
...
...
@@ -231,7 +232,7 @@ static void Close(vlc_object_t *obj)
if
(
err
!=
noErr
)
msg_Err
(
p_aout
,
"AudioHardwareRemovePropertyListener failed [%4.4s]"
,
(
char
*
)
&
err
);
vlc_mutex_lock
(
&
p_sys
->
device_list
_lock
);
vlc_mutex_lock
(
&
p_sys
->
var
_lock
);
/* remove streams callbacks */
CFIndex
count
=
CFArrayGetCount
(
p_sys
->
device_list
);
if
(
count
>
0
)
{
...
...
@@ -249,13 +250,13 @@ static void Close(vlc_object_t *obj)
}
CFRelease
(
p_sys
->
device_list
);
vlc_mutex_unlock
(
&
p_sys
->
device_list
_lock
);
vlc_mutex_unlock
(
&
p_sys
->
var
_lock
);
char
*
psz_device
=
aout_DeviceGet
(
p_aout
);
config_PutPsz
(
p_aout
,
"auhal-audio-device"
,
psz_device
);
free
(
psz_device
);
vlc_mutex_destroy
(
&
p_sys
->
device_list
_lock
);
vlc_mutex_destroy
(
&
p_sys
->
var
_lock
);
vlc_mutex_destroy
(
&
p_sys
->
lock
);
vlc_cond_destroy
(
&
p_sys
->
cond
);
...
...
@@ -286,6 +287,7 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
p_sys
->
b_changed_mixing
=
false
;
p_sys
->
i_bytes_per_sample
=
0
;
vlc_mutex_lock
(
&
p_sys
->
var_lock
);
p_sys
->
i_selected_dev
=
p_sys
->
i_new_selected_dev
;
aout_FormatPrint
(
p_aout
,
"VLC is looking for:"
,
fmt
);
...
...
@@ -377,6 +379,7 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
b_success
=
true
;
}
}
vlc_mutex_unlock
(
&
p_sys
->
var_lock
);
if
(
b_success
)
{
p_aout
->
play
=
Play
;
...
...
@@ -388,6 +391,7 @@ static int Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
error:
/* If we reach this, this aout has failed */
vlc_mutex_unlock
(
&
p_sys
->
var_lock
);
msg_Err
(
p_aout
,
"opening auhal output failed"
);
return
VLC_EGENERIC
;
}
...
...
@@ -1023,6 +1027,7 @@ static void Stop(audio_output_t *p_aout)
verify_noerr
(
AudioComponentInstanceDispose
(
p_sys
->
au_unit
));
}
vlc_mutex_lock
(
&
p_sys
->
var_lock
);
if
(
p_sys
->
b_digital
)
{
/* Stop device */
err
=
AudioDeviceStop
(
p_sys
->
i_selected_dev
,
...
...
@@ -1077,7 +1082,7 @@ static void Stop(audio_output_t *p_aout)
msg_Warn
(
p_aout
,
"failed to remove audio device life checker [%4.4s]"
,
(
char
*
)
&
err
);
}
vlc_mutex_unlock
(
&
p_sys
->
var_lock
);
p_sys
->
i_bytes_per_sample
=
0
;
p_sys
->
b_digital
=
false
;
...
...
@@ -1196,7 +1201,7 @@ static void RebuildDeviceList(audio_output_t * p_aout)
free
(
psz_name
);
}
vlc_mutex_lock
(
&
p_sys
->
device_list
_lock
);
vlc_mutex_lock
(
&
p_sys
->
var
_lock
);
CFIndex
count
=
0
;
if
(
p_sys
->
device_list
)
count
=
CFArrayGetCount
(
p_sys
->
device_list
);
...
...
@@ -1218,7 +1223,7 @@ static void RebuildDeviceList(audio_output_t * p_aout)
CFRelease
(
p_sys
->
device_list
);
p_sys
->
device_list
=
CFArrayCreateCopy
(
kCFAllocatorDefault
,
currentListOfDevices
);
CFRelease
(
currentListOfDevices
);
vlc_mutex_unlock
(
&
p_sys
->
device_list
_lock
);
vlc_mutex_unlock
(
&
p_sys
->
var
_lock
);
free
(
deviceIDs
);
}
...
...
@@ -1498,10 +1503,10 @@ static OSStatus DevicesListener(AudioObjectID inObjectID, UInt32 inNumberAddres
msg_Dbg
(
p_aout
,
"audio device configuration changed, resetting cache"
);
RebuildDeviceList
(
p_aout
);
vlc_mutex_lock
(
&
p_sys
->
device_list
_lock
);
vlc_mutex_lock
(
&
p_sys
->
var
_lock
);
if
(
!
CFArrayContainsValue
(
p_sys
->
device_list
,
CFRangeMake
(
0
,
CFArrayGetCount
(
p_sys
->
device_list
)),
CFNumberCreate
(
kCFAllocatorDefault
,
kCFNumberSInt32Type
,
&
p_sys
->
i_selected_dev
)))
aout_RestartRequest
(
p_aout
,
AOUT_RESTART_OUTPUT
);
vlc_mutex_unlock
(
&
p_sys
->
device_list
_lock
);
vlc_mutex_unlock
(
&
p_sys
->
var
_lock
);
return
noErr
;
}
...
...
@@ -1550,6 +1555,7 @@ static OSStatus StreamsChangedListener(AudioObjectID inObjectID, UInt32 inNumbe
/*
* check if changed stream id belongs to current device
*/
vlc_mutex_lock
(
&
p_sys
->
var_lock
);
AudioObjectPropertyAddress
streamsAddress
=
{
kAudioDevicePropertyStreams
,
kAudioDevicePropertyScopeOutput
,
kAudioObjectPropertyElementMaster
};
err
=
AudioObjectGetPropertyDataSize
(
p_sys
->
i_selected_dev
,
&
streamsAddress
,
0
,
NULL
,
&
i_param_size
);
if
(
err
!=
noErr
)
{
...
...
@@ -1567,6 +1573,7 @@ static OSStatus StreamsChangedListener(AudioObjectID inObjectID, UInt32 inNumbe
msg_Err
(
p_aout
,
"could not get list of streams [%4.4s]"
,
(
char
*
)
&
err
);
return
VLC_EGENERIC
;
}
vlc_mutex_unlock
(
&
p_sys
->
var_lock
);
for
(
int
i
=
0
;
i
<
i_streams
;
i
++
)
{
if
(
p_streams
[
i
]
==
inObjectID
)
{
...
...
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