Commit 7572bfd1 authored by Thomas Guillem's avatar Thomas Guillem

aout: refactor aout_PrepareStereoMode

parent a85ca0ed
...@@ -380,47 +380,17 @@ static void aout_Destructor (vlc_object_t *obj) ...@@ -380,47 +380,17 @@ static void aout_Destructor (vlc_object_t *obj)
vlc_mutex_destroy (&owner->lock); vlc_mutex_destroy (&owner->lock);
} }
/** static void aout_PrepareStereoMode (audio_output_t *aout,
* Starts an audio output stream. audio_sample_format_t *restrict fmt,
* \param fmt audio output stream format [IN/OUT] aout_filters_cfg_t *filters_cfg,
* \warning The caller must hold the audio output lock. int i_forced_stereo_mode,
*/ bool b_stereo_original)
int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt,
aout_filters_cfg_t *filters_cfg)
{ {
aout_OutputAssertLocked (aout);
int i_forced_stereo_mode = var_GetInteger (aout, "stereo-mode");
bool b_stereo_original = fmt->i_physical_channels == AOUT_CHANS_STEREO;
if (i_forced_stereo_mode != AOUT_VAR_CHAN_UNSET)
{
if (i_forced_stereo_mode == AOUT_VAR_CHAN_LEFT
|| i_forced_stereo_mode == AOUT_VAR_CHAN_RIGHT)
fmt->i_physical_channels = AOUT_CHAN_CENTER;
else
fmt->i_physical_channels = AOUT_CHANS_STEREO;
}
/* Ideally, the audio filters would be created before the audio output,
* and the ideal audio format would be the output of the filters chain.
* But that scheme would not really play well with digital pass-through. */
if (AOUT_FMT_LINEAR(fmt))
{ /* Try to stay in integer domain if possible for no/slow FPU. */
fmt->i_format = (fmt->i_bitspersample > 16) ? VLC_CODEC_FL32
: VLC_CODEC_S16N;
aout_FormatPrepare (fmt);
}
if (aout->start (aout, fmt))
{
msg_Err (aout, "module not functional");
return -1;
}
/* Fill Stereo mode choices */ /* Fill Stereo mode choices */
var_Change (aout, "stereo-mode", VLC_VAR_CLEARCHOICES, NULL, NULL); var_Change (aout, "stereo-mode", VLC_VAR_CLEARCHOICES, NULL, NULL);
vlc_value_t val, txt, default_val; vlc_value_t val, txt, default_val;
val.i_int = 0; val.i_int = 0;
if (!b_stereo_original) if (!b_stereo_original)
{ {
val.i_int = AOUT_VAR_CHAN_UNSET; val.i_int = AOUT_VAR_CHAN_UNSET;
...@@ -491,6 +461,48 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt, ...@@ -491,6 +461,48 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt,
NULL); NULL);
break; break;
} }
}
/**
* Starts an audio output stream.
* \param fmt audio output stream format [IN/OUT]
* \warning The caller must hold the audio output lock.
*/
int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt,
aout_filters_cfg_t *filters_cfg)
{
aout_OutputAssertLocked (aout);
int i_forced_stereo_mode = var_GetInteger (aout, "stereo-mode");
bool b_stereo_original = fmt->i_physical_channels == AOUT_CHANS_STEREO;
if (i_forced_stereo_mode != AOUT_VAR_CHAN_UNSET)
{
if (i_forced_stereo_mode == AOUT_VAR_CHAN_LEFT
|| i_forced_stereo_mode == AOUT_VAR_CHAN_RIGHT)
fmt->i_physical_channels = AOUT_CHAN_CENTER;
else
fmt->i_physical_channels = AOUT_CHANS_STEREO;
}
/* Ideally, the audio filters would be created before the audio output,
* and the ideal audio format would be the output of the filters chain.
* But that scheme would not really play well with digital pass-through. */
if (AOUT_FMT_LINEAR(fmt))
{ /* Try to stay in integer domain if possible for no/slow FPU. */
fmt->i_format = (fmt->i_bitspersample > 16) ? VLC_CODEC_FL32
: VLC_CODEC_S16N;
aout_FormatPrepare (fmt);
}
if (aout->start (aout, fmt))
{
msg_Err (aout, "module not functional");
return -1;
}
aout_PrepareStereoMode (aout, fmt, filters_cfg, i_forced_stereo_mode,
b_stereo_original);
aout_FormatPrepare (fmt); aout_FormatPrepare (fmt);
assert (aout_FormatNbChannels(fmt) > 0); assert (aout_FormatNbChannels(fmt) > 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment