Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
749fa2f4
Commit
749fa2f4
authored
May 31, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aout: simplify input handling, remove dead code
parent
b6717257
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
132 deletions
+55
-132
include/vlc_aout.h
include/vlc_aout.h
+1
-2
src/audio_output/aout_internal.h
src/audio_output/aout_internal.h
+2
-3
src/audio_output/common.c
src/audio_output/common.c
+6
-14
src/audio_output/dec.c
src/audio_output/dec.c
+28
-81
src/audio_output/input.c
src/audio_output/input.c
+2
-3
src/audio_output/intf.c
src/audio_output/intf.c
+12
-25
src/audio_output/mixer.c
src/audio_output/mixer.c
+3
-3
src/audio_output/output.c
src/audio_output/output.c
+1
-1
No files found.
include/vlc_aout.h
View file @
749fa2f4
...
...
@@ -195,8 +195,7 @@ struct aout_instance_t
vlc_mutex_t
volume_vars_lock
;
/* Input streams & pre-filters */
aout_input_t
*
pp_inputs
[
1
];
int
i_nb_inputs
;
aout_input_t
*
p_input
;
/* Mixer */
audio_sample_format_t
mixer_format
;
...
...
src/audio_output/aout_internal.h
View file @
749fa2f4
...
...
@@ -239,10 +239,9 @@ static inline void aout_unlock_volume( aout_instance_t *p_aout )
* possible to take configuration changes into account */
static
inline
void
AoutInputsMarkToRestart
(
aout_instance_t
*
p_aout
)
{
int
i
;
aout_lock_mixer
(
p_aout
);
for
(
i
=
0
;
i
<
p_aout
->
i_nb_inputs
;
i
++
)
p_aout
->
p
p_inputs
[
i
]
->
b_restart
=
true
;
if
(
p_aout
->
p_input
!=
NULL
)
p_aout
->
p
_input
->
b_restart
=
true
;
aout_unlock_mixer
(
p_aout
);
}
...
...
src/audio_output/common.c
View file @
749fa2f4
...
...
@@ -50,19 +50,11 @@ static inline void aout_assert_fifo_locked( aout_instance_t * p_aout, aout_fifo_
if
(
p_fifo
==
&
p_aout
->
output
.
fifo
)
vlc_assert_locked
(
&
p_aout
->
output_fifo_lock
);
else
{
int
i
;
for
(
i
=
0
;
i
<
p_aout
->
i_nb_inputs
;
i
++
)
{
if
(
p_fifo
==
&
p_aout
->
pp_inputs
[
i
]
->
mixer
.
fifo
)
{
vlc_assert_locked
(
&
p_aout
->
input_fifos_lock
);
break
;
}
}
if
(
i
==
p_aout
->
i_nb_inputs
)
vlc_assert_locked
(
&
p_aout
->
mixer_lock
);
}
if
(
p_aout
->
p_input
!=
NULL
&&
p_fifo
==
&
p_aout
->
p_input
->
mixer
.
fifo
)
vlc_assert_locked
(
&
p_aout
->
input_fifos_lock
);
else
vlc_assert_locked
(
&
p_aout
->
mixer_lock
);
#else
(
void
)
p_aout
;
(
void
)
p_fifo
;
...
...
@@ -92,7 +84,7 @@ aout_instance_t * __aout_New( vlc_object_t * p_parent )
vlc_mutex_init
(
&
p_aout
->
mixer_lock
);
vlc_mutex_init
(
&
p_aout
->
volume_vars_lock
);
vlc_mutex_init
(
&
p_aout
->
output_fifo_lock
);
p_aout
->
i_nb_inputs
=
0
;
p_aout
->
p_input
=
NULL
;
p_aout
->
mixer_multiplier
=
1
.
0
;
p_aout
->
p_mixer
=
NULL
;
p_aout
->
output
.
b_starving
=
1
;
...
...
src/audio_output/dec.c
View file @
749fa2f4
...
...
@@ -46,8 +46,6 @@ aout_input_t *aout_DecNew( aout_instance_t *p_aout,
const
audio_replay_gain_t
*
p_replay_gain
,
const
aout_request_vout_t
*
p_request_vout
)
{
aout_input_t
*
p_input
;
/* Sanitize audio format */
if
(
p_format
->
i_channels
>
32
)
{
...
...
@@ -79,17 +77,11 @@ aout_input_t *aout_DecNew( aout_instance_t *p_aout,
return
NULL
;
}
/* We can only be called by the decoder, so no need to lock
* p_input->lock. */
aout_lock_mixer
(
p_aout
);
assert
(
p_aout
->
i_nb_inputs
==
0
);
p_input
=
calloc
(
1
,
sizeof
(
aout_input_t
));
aout_input_t
*
p_input
=
calloc
(
1
,
sizeof
(
aout_input_t
));
if
(
!
p_input
)
goto
error
;
return
NULL
;
vlc_mutex_init
(
&
p_input
->
lock
);
p_input
->
b_error
=
true
;
p_input
->
b_paused
=
false
;
p_input
->
i_pause_date
=
0
;
...
...
@@ -101,64 +93,35 @@ aout_input_t *aout_DecNew( aout_instance_t *p_aout,
if
(
p_replay_gain
)
p_input
->
replay_gain
=
*
p_replay_gain
;
/* We can only be called by the decoder, so no need to lock
* p_input->lock. */
aout_lock_mixer
(
p_aout
);
aout_lock_input_fifos
(
p_aout
);
p_aout
->
pp_inputs
[
p_aout
->
i_nb_inputs
]
=
p_input
;
p_aout
->
i_nb_inputs
++
;
assert
(
p_aout
->
p_input
==
NULL
)
;
p_aout
->
p_input
=
p_input
;
if
(
!
p_aout
->
p_mixer
)
{
int
i
;
var_Destroy
(
p_aout
,
"audio-device"
);
var_Destroy
(
p_aout
,
"audio-channels"
);
/* Recreate the output using the new format. */
if
(
aout_OutputNew
(
p_aout
,
p_format
)
<
0
)
{
for
(
i
=
0
;
i
<
p_aout
->
i_nb_inputs
-
1
;
i
++
)
{
aout_lock_input
(
p_aout
,
p_aout
->
pp_inputs
[
i
]
);
aout_InputDelete
(
p_aout
,
p_aout
->
pp_inputs
[
i
]
);
aout_unlock_input
(
p_aout
,
p_aout
->
pp_inputs
[
i
]
);
}
aout_unlock_input_fifos
(
p_aout
);
aout_unlock_mixer
(
p_aout
);
return
p_input
;
}
var_Destroy
(
p_aout
,
"audio-device"
);
var_Destroy
(
p_aout
,
"audio-channels"
);
/* Create other input streams. */
for
(
i
=
0
;
i
<
p_aout
->
i_nb_inputs
-
1
;
i
++
)
{
aout_input_t
*
p_input
=
p_aout
->
pp_inputs
[
i
];
aout_lock_input
(
p_aout
,
p_input
);
aout_InputDelete
(
p_aout
,
p_input
);
aout_InputNew
(
p_aout
,
p_input
,
&
p_input
->
request_vout
);
aout_unlock_input
(
p_aout
,
p_input
);
}
}
else
{
aout_MixerDelete
(
p_aout
);
}
/* Recreate the output using the new format. */
if
(
aout_OutputNew
(
p_aout
,
p_format
)
<
0
)
#warning Input without output and mixer = bad idea.
goto
out
;
if
(
aout_MixerNew
(
p_aout
)
==
-
1
)
assert
(
p_aout
->
p_mixer
==
NULL
);
if
(
aout_MixerNew
(
p_aout
)
==
-
1
)
{
aout_OutputDelete
(
p_aout
);
aout_unlock_input_fifos
(
p_aout
);
goto
error
;
#warning Memory leak.
p_input
=
NULL
;
goto
out
;
}
aout_InputNew
(
p_aout
,
p_input
,
p_request_vout
);
out:
aout_unlock_input_fifos
(
p_aout
);
aout_unlock_mixer
(
p_aout
);
return
p_input
;
error:
aout_unlock_mixer
(
p_aout
);
return
NULL
;
}
/*****************************************************************************
...
...
@@ -166,46 +129,30 @@ error:
*****************************************************************************/
int
aout_DecDelete
(
aout_instance_t
*
p_aout
,
aout_input_t
*
p_input
)
{
int
i_input
;
/* This function can only be called by the decoder itself, so no need
* to lock p_input->lock. */
aout_lock_mixer
(
p_aout
);
for
(
i_input
=
0
;
i_input
<
p_aout
->
i_nb_inputs
;
i_input
++
)
{
if
(
p_aout
->
pp_inputs
[
i_input
]
==
p_input
)
{
break
;
}
}
if
(
i_input
==
p_aout
->
i_nb_inputs
)
if
(
p_input
!=
p_aout
->
p_input
)
{
msg_Err
(
p_aout
,
"cannot find an input to delete"
);
aout_unlock_mixer
(
p_aout
);
return
-
1
;
}
/* Remove the input from the list. */
p_aout
->
i_nb_inputs
--
;
assert
(
p_aout
->
i_nb_inputs
==
0
);
/* Remove the input. */
p_aout
->
p_input
=
NULL
;
aout_InputDelete
(
p_aout
,
p_input
);
vlc_mutex_destroy
(
&
p_input
->
lock
);
free
(
p_input
);
if
(
!
p_aout
->
i_nb_inputs
)
{
aout_OutputDelete
(
p_aout
);
aout_MixerDelete
(
p_aout
);
var_Destroy
(
p_aout
,
"audio-device"
);
var_Destroy
(
p_aout
,
"audio-channels"
);
}
aout_OutputDelete
(
p_aout
);
aout_MixerDelete
(
p_aout
);
var_Destroy
(
p_aout
,
"audio-device"
);
var_Destroy
(
p_aout
,
"audio-channels"
);
aout_unlock_mixer
(
p_aout
);
vlc_mutex_destroy
(
&
p_input
->
lock
);
free
(
p_input
);
return
0
;
}
...
...
src/audio_output/input.c
View file @
749fa2f4
...
...
@@ -896,11 +896,10 @@ static int ReplayGainCallback( vlc_object_t *p_this, char const *psz_cmd,
VLC_UNUSED
(
psz_cmd
);
VLC_UNUSED
(
oldval
);
VLC_UNUSED
(
newval
);
VLC_UNUSED
(
p_data
);
aout_instance_t
*
p_aout
=
(
aout_instance_t
*
)
p_this
;
int
i
;
aout_lock_mixer
(
p_aout
);
for
(
i
=
0
;
i
<
p_aout
->
i_nb_inputs
;
i
++
)
ReplayGainSelect
(
p_aout
,
p_aout
->
p
p_inputs
[
i
]
);
if
(
p_aout
->
p_input
!=
NULL
)
ReplayGainSelect
(
p_aout
,
p_aout
->
p
_input
);
aout_unlock_mixer
(
p_aout
);
return
VLC_SUCCESS
;
...
...
src/audio_output/intf.c
View file @
749fa2f4
...
...
@@ -291,25 +291,21 @@ void aout_VolumeNoneInit( aout_instance_t * p_aout )
*****************************************************************************/
static
int
aout_Restart
(
aout_instance_t
*
p_aout
)
{
int
i
;
bool
b_error
=
0
;
aout_lock_mixer
(
p_aout
);
if
(
p_aout
->
i_nb_inputs
==
0
)
if
(
p_aout
->
p_input
==
NULL
)
{
aout_unlock_mixer
(
p_aout
);
msg_Err
(
p_aout
,
"no decoder thread"
);
return
-
1
;
}
for
(
i
=
0
;
i
<
p_aout
->
i_nb_inputs
;
i
++
)
{
aout_lock_input
(
p_aout
,
p_aout
->
pp_inputs
[
i
]
);
aout_lock_input_fifos
(
p_aout
);
aout_InputDelete
(
p_aout
,
p_aout
->
pp_inputs
[
i
]
);
aout_unlock_input_fifos
(
p_aout
);
}
aout_lock_input
(
p_aout
,
p_aout
->
p_input
);
aout_lock_input_fifos
(
p_aout
);
aout_InputDelete
(
p_aout
,
p_aout
->
p_input
);
aout_unlock_input_fifos
(
p_aout
);
/* Lock all inputs. */
aout_lock_input_fifos
(
p_aout
);
...
...
@@ -320,13 +316,10 @@ static int aout_Restart( aout_instance_t * p_aout )
/* FIXME: This function is notoriously dangerous/unsafe.
* By the way, if OutputNew or MixerNew fails, we are totally screwed. */
if
(
aout_OutputNew
(
p_aout
,
&
p_aout
->
p
p_inputs
[
0
]
->
input
)
==
-
1
)
if
(
aout_OutputNew
(
p_aout
,
&
p_aout
->
p
_input
->
input
)
==
-
1
)
{
/* Release all locks and report the error. */
for
(
i
=
0
;
i
<
p_aout
->
i_nb_inputs
;
i
++
)
{
vlc_mutex_unlock
(
&
p_aout
->
pp_inputs
[
i
]
->
lock
);
}
vlc_mutex_unlock
(
&
p_aout
->
p_input
->
lock
);
aout_unlock_input_fifos
(
p_aout
);
aout_unlock_mixer
(
p_aout
);
return
-
1
;
...
...
@@ -335,22 +328,16 @@ static int aout_Restart( aout_instance_t * p_aout )
if
(
aout_MixerNew
(
p_aout
)
==
-
1
)
{
aout_OutputDelete
(
p_aout
);
for
(
i
=
0
;
i
<
p_aout
->
i_nb_inputs
;
i
++
)
{
vlc_mutex_unlock
(
&
p_aout
->
pp_inputs
[
i
]
->
lock
);
}
vlc_mutex_unlock
(
&
p_aout
->
p_input
->
lock
);
aout_unlock_input_fifos
(
p_aout
);
aout_unlock_mixer
(
p_aout
);
return
-
1
;
}
/* Re-open all inputs. */
for
(
i
=
0
;
i
<
p_aout
->
i_nb_inputs
;
i
++
)
{
aout_input_t
*
p_input
=
p_aout
->
pp_inputs
[
i
];
b_error
|=
aout_InputNew
(
p_aout
,
p_input
,
&
p_input
->
request_vout
);
aout_unlock_input
(
p_aout
,
p_input
);
}
/* Re-open the input. */
aout_input_t
*
p_input
=
p_aout
->
p_input
;
b_error
|=
aout_InputNew
(
p_aout
,
p_input
,
&
p_input
->
request_vout
);
aout_unlock_input
(
p_aout
,
p_input
);
aout_unlock_input_fifos
(
p_aout
);
aout_unlock_mixer
(
p_aout
);
...
...
src/audio_output/mixer.c
View file @
749fa2f4
...
...
@@ -51,7 +51,7 @@ int aout_MixerNew( aout_instance_t * p_aout )
return
VLC_EGENERIC
;
p_mixer
->
fmt
=
p_aout
->
mixer_format
;
p_mixer
->
input
=
&
p_aout
->
p
p_inputs
[
0
]
->
mixer
;
p_mixer
->
input
=
&
p_aout
->
p
_input
->
mixer
;
p_mixer
->
mix
=
NULL
;
p_mixer
->
sys
=
NULL
;
...
...
@@ -95,9 +95,9 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
{
aout_mixer_t
*
p_mixer
=
p_aout
->
p_mixer
;
assert
(
p_aout
->
i_nb_inputs
==
1
);
assert
(
p_aout
->
p_input
!=
NULL
);
aout_input_t
*
p_input
=
p_aout
->
p
p_inputs
[
0
]
;
aout_input_t
*
p_input
=
p_aout
->
p
_input
;
if
(
p_input
->
b_paused
)
return
-
1
;
...
...
src/audio_output/output.c
View file @
749fa2f4
...
...
@@ -337,7 +337,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout,
aout_unlock_output_fifo
(
p_aout
);
aout_lock_input_fifos
(
p_aout
);
aout_fifo_t
*
p_fifo
=
&
p_aout
->
p
p_inputs
[
0
]
->
mixer
.
fifo
;
aout_fifo_t
*
p_fifo
=
&
p_aout
->
p
_input
->
mixer
.
fifo
;
aout_FifoMoveDates
(
p_aout
,
p_fifo
,
difference
);
aout_unlock_input_fifos
(
p_aout
);
return
p_buffer
;
...
...
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