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
7e4e3a43
Commit
7e4e3a43
authored
Feb 27, 2013
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aout: de-inline the locking functions
parent
296debcc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
46 deletions
+53
-46
src/audio_output/aout_internal.h
src/audio_output/aout_internal.h
+2
-14
src/audio_output/dec.c
src/audio_output/dec.c
+13
-15
src/audio_output/output.c
src/audio_output/output.c
+38
-17
No files found.
src/audio_output/aout_internal.h
View file @
7e4e3a43
...
...
@@ -120,6 +120,8 @@ void aout_OutputPlay(audio_output_t *, block_t *);
void
aout_OutputPause
(
audio_output_t
*
p_aout
,
bool
,
mtime_t
);
void
aout_OutputFlush
(
audio_output_t
*
p_aout
,
bool
);
void
aout_OutputDelete
(
audio_output_t
*
p_aout
);
void
aout_OutputLock
(
audio_output_t
*
);
void
aout_OutputUnlock
(
audio_output_t
*
);
/* From common.c : */
...
...
@@ -149,18 +151,4 @@ static inline void aout_InputRequestRestart(audio_output_t *aout)
aout_RequestRestart
(
aout
,
AOUT_RESTART_FILTERS
);
}
/* Audio output locking */
static
inline
void
aout_lock
(
audio_output_t
*
p_aout
)
{
vlc_mutex_lock
(
&
aout_owner
(
p_aout
)
->
lock
);
}
static
inline
void
aout_unlock
(
audio_output_t
*
p_aout
)
{
vlc_mutex_unlock
(
&
aout_owner
(
p_aout
)
->
lock
);
}
#define aout_assert_locked( aout ) \
vlc_assert_locked( &aout_owner(aout)->lock )
#endif
/* !LIBVLC_AOUT_INTERNAL_H */
src/audio_output/dec.c
View file @
7e4e3a43
...
...
@@ -68,7 +68,7 @@ int aout_DecNew( audio_output_t *p_aout,
aout_owner_t
*
owner
=
aout_owner
(
p_aout
);
/* TODO: reduce lock scope depending on decoder's real need */
aout_
lock
(
p_aout
);
aout_
OutputLock
(
p_aout
);
var_Destroy
(
p_aout
,
"stereo-mode"
);
...
...
@@ -90,14 +90,14 @@ int aout_DecNew( audio_output_t *p_aout,
aout_OutputDelete
(
p_aout
);
error:
aout_volume_Delete
(
owner
->
volume
);
aout_
u
nlock
(
p_aout
);
aout_
OutputU
nlock
(
p_aout
);
return
-
1
;
}
owner
->
sync
.
end
=
VLC_TS_INVALID
;
owner
->
sync
.
resamp_type
=
AOUT_RESAMPLING_NONE
;
owner
->
sync
.
discontinuity
=
true
;
aout_
unlock
(
p_aout
);
aout_
OutputUnlock
(
p_aout
);
atomic_init
(
&
owner
->
buffers_lost
,
0
);
return
0
;
...
...
@@ -110,14 +110,14 @@ void aout_DecDelete (audio_output_t *aout)
{
aout_owner_t
*
owner
=
aout_owner
(
aout
);
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
if
(
owner
->
mixer_format
.
i_format
)
{
aout_FiltersDelete
(
aout
);
aout_OutputDelete
(
aout
);
}
aout_volume_Delete
(
owner
->
volume
);
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
var_Destroy
(
aout
,
"stereo-mode"
);
}
...
...
@@ -125,8 +125,6 @@ static int aout_CheckReady (audio_output_t *aout)
{
aout_owner_t
*
owner
=
aout_owner
(
aout
);
aout_assert_locked
(
aout
);
int
restart
=
atomic_exchange
(
&
owner
->
restart
,
0
);
if
(
unlikely
(
restart
))
{
...
...
@@ -365,7 +363,7 @@ int aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate)
block
->
i_length
=
CLOCK_FREQ
*
block
->
i_nb_samples
/
owner
->
input_format
.
i_rate
;
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
if
(
unlikely
(
aout_CheckReady
(
aout
)))
goto
drop
;
/* Pipeline is unrecoverably broken :-( */
...
...
@@ -401,7 +399,7 @@ int aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate)
owner
->
sync
.
discontinuity
=
false
;
aout_OutputPlay
(
aout
,
block
);
out:
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
return
0
;
drop:
owner
->
sync
.
discontinuity
=
true
;
...
...
@@ -421,7 +419,7 @@ void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
{
aout_owner_t
*
owner
=
aout_owner
(
aout
);
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
if
(
owner
->
sync
.
end
!=
VLC_TS_INVALID
)
{
if
(
paused
)
...
...
@@ -431,18 +429,18 @@ void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
}
if
(
owner
->
mixer_format
.
i_format
)
aout_OutputPause
(
aout
,
paused
,
date
);
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
}
void
aout_DecFlush
(
audio_output_t
*
aout
)
{
aout_owner_t
*
owner
=
aout_owner
(
aout
);
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
owner
->
sync
.
end
=
VLC_TS_INVALID
;
if
(
owner
->
mixer_format
.
i_format
)
aout_OutputFlush
(
aout
,
false
);
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
}
bool
aout_DecIsEmpty
(
audio_output_t
*
aout
)
...
...
@@ -451,7 +449,7 @@ bool aout_DecIsEmpty (audio_output_t *aout)
mtime_t
now
=
mdate
();
bool
empty
=
true
;
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
if
(
owner
->
sync
.
end
!=
VLC_TS_INVALID
)
empty
=
owner
->
sync
.
end
<=
now
;
if
(
empty
&&
owner
->
mixer_format
.
i_format
)
...
...
@@ -459,6 +457,6 @@ bool aout_DecIsEmpty (audio_output_t *aout)
* buffer should be empty or almost. Thus draining should be fast
* and will not block the caller too long. */
aout_OutputFlush
(
aout
,
true
);
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
return
empty
;
}
src/audio_output/output.c
View file @
7e4e3a43
...
...
@@ -33,6 +33,13 @@
#include "aout_internal.h"
/* Local functions */
static
void
aout_OutputAssertLocked
(
audio_output_t
*
aout
)
{
aout_owner_t
*
owner
=
aout_owner
(
aout
);
vlc_assert_locked
(
&
owner
->
lock
);
}
static
void
aout_Destructor
(
vlc_object_t
*
p_this
);
static
int
var_Copy
(
vlc_object_t
*
src
,
const
char
*
name
,
vlc_value_t
prev
,
...
...
@@ -83,7 +90,7 @@ static int aout_GainNotify (audio_output_t *aout, float gain)
{
aout_owner_t
*
owner
=
aout_owner
(
aout
);
aout_
assert_l
ocked
(
aout
);
aout_
OutputAssertL
ocked
(
aout
);
aout_volume_SetVolume
(
owner
->
volume
,
gain
);
/* XXX: ideally, return -1 if format cannot be amplified */
return
0
;
...
...
@@ -239,12 +246,12 @@ void aout_Destroy (audio_output_t *aout)
{
aout_owner_t
*
owner
=
aout_owner
(
aout
);
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
module_unneed
(
aout
,
owner
->
module
);
/* Protect against late call from intf.c */
aout
->
volume_set
=
NULL
;
aout
->
mute_set
=
NULL
;
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
var_DelCallback
(
aout
,
"mute"
,
var_Copy
,
aout
->
p_parent
);
var_SetFloat
(
aout
,
"volume"
,
-
1
.
f
);
...
...
@@ -282,10 +289,10 @@ int aout_VolumeSet (audio_output_t *aout, float vol)
{
int
ret
=
-
1
;
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
if
(
aout
->
volume_set
!=
NULL
)
ret
=
aout
->
volume_set
(
aout
,
vol
);
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
return
ret
;
}
...
...
@@ -306,10 +313,10 @@ int aout_MuteSet (audio_output_t *aout, bool mute)
{
int
ret
=
-
1
;
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
if
(
aout
->
mute_set
!=
NULL
)
ret
=
aout
->
mute_set
(
aout
,
mute
);
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
return
ret
;
}
...
...
@@ -332,10 +339,10 @@ int aout_DeviceSet (audio_output_t *aout, const char *id)
{
int
ret
=
-
1
;
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
if
(
aout
->
device_select
!=
NULL
)
ret
=
aout
->
device_select
(
aout
,
id
);
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
return
ret
;
}
...
...
@@ -354,10 +361,10 @@ int aout_DevicesList (audio_output_t *aout, char ***ids, char ***names)
{
int
ret
=
-
1
;
aout_
l
ock
(
aout
);
aout_
OutputL
ock
(
aout
);
if
(
aout
->
device_enum
!=
NULL
)
ret
=
aout
->
device_enum
(
aout
,
ids
,
names
);
aout_
u
nlock
(
aout
);
aout_
OutputU
nlock
(
aout
);
return
ret
;
}
...
...
@@ -369,7 +376,7 @@ int aout_DevicesList (audio_output_t *aout, char ***ids, char ***names)
*/
int
aout_OutputNew
(
audio_output_t
*
aout
,
audio_sample_format_t
*
restrict
fmt
)
{
aout_
assert_l
ocked
(
aout
);
aout_
OutputAssertL
ocked
(
aout
);
/* Ideally, the audio filters would be created before the audio output,
* and the ideal audio format would be the output of the filters chain.
...
...
@@ -462,7 +469,7 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
*/
void
aout_OutputDelete
(
audio_output_t
*
aout
)
{
aout_
assert_l
ocked
(
aout
);
aout_
OutputAssertL
ocked
(
aout
);
var_DelCallback
(
aout
,
"stereo-mode"
,
aout_ChannelsRestart
,
NULL
);
if
(
aout
->
stop
!=
NULL
)
...
...
@@ -471,7 +478,7 @@ void aout_OutputDelete (audio_output_t *aout)
int
aout_OutputTimeGet
(
audio_output_t
*
aout
,
mtime_t
*
delay
)
{
aout_
assert_l
ocked
(
aout
);
aout_
OutputAssertL
ocked
(
aout
);
if
(
aout
->
time_get
==
NULL
)
return
-
1
;
...
...
@@ -485,7 +492,7 @@ int aout_OutputTimeGet (audio_output_t *aout, mtime_t *delay)
*/
void
aout_OutputPlay
(
audio_output_t
*
aout
,
block_t
*
block
)
{
aout_
assert_l
ocked
(
aout
);
aout_
OutputAssertL
ocked
(
aout
);
aout
->
play
(
aout
,
block
);
}
...
...
@@ -505,7 +512,7 @@ static void PauseDefault (audio_output_t *aout, bool pause, mtime_t date)
*/
void
aout_OutputPause
(
audio_output_t
*
aout
,
bool
pause
,
mtime_t
date
)
{
aout_
assert_l
ocked
(
aout
);
aout_
OutputAssertL
ocked
(
aout
);
((
aout
->
pause
!=
NULL
)
?
aout
->
pause
:
PauseDefault
)
(
aout
,
pause
,
date
);
}
...
...
@@ -519,6 +526,20 @@ void aout_OutputPause( audio_output_t *aout, bool pause, mtime_t date )
*/
void
aout_OutputFlush
(
audio_output_t
*
aout
,
bool
wait
)
{
aout_
assert_l
ocked
(
aout
);
aout_
OutputAssertL
ocked
(
aout
);
aout
->
flush
(
aout
,
wait
);
}
void
aout_OutputLock
(
audio_output_t
*
aout
)
{
aout_owner_t
*
owner
=
aout_owner
(
aout
);
vlc_mutex_lock
(
&
owner
->
lock
);
}
void
aout_OutputUnlock
(
audio_output_t
*
aout
)
{
aout_owner_t
*
owner
=
aout_owner
(
aout
);
vlc_mutex_unlock
(
&
owner
->
lock
);
}
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