Commit b04deb0a authored by Thomas Guillem's avatar Thomas Guillem

pulse: refactor pa_format_info initialisation

parent 359f0799
......@@ -695,8 +695,8 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
aout_sys_t *sys = aout->sys;
/* Sample format specification */
struct pa_sample_spec ss;
pa_encoding_t encoding = PA_ENCODING_INVALID;
struct pa_sample_spec ss = { .format = PA_SAMPLE_INVALID };
pa_encoding_t encoding = PA_ENCODING_PCM;
switch (fmt->i_format)
{
......@@ -722,7 +722,6 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
fmt->i_physical_channels = AOUT_CHANS_2_0;
fmt->i_channels = 2;
encoding = PA_ENCODING_AC3_IEC61937;
ss.format = PA_SAMPLE_S16NE;
break;
case VLC_CODEC_EAC3:
fmt->i_format = VLC_CODEC_SPDIFL;
......@@ -731,12 +730,10 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
fmt->i_physical_channels = AOUT_CHANS_2_0;
fmt->i_channels = 2;
encoding = PA_ENCODING_EAC3_IEC61937;
ss.format = PA_SAMPLE_S16NE;
break;
/* case VLC_CODEC_MPGA:
fmt->i_format = VLC_CODEC_SPDIFL FIXME;
encoding = PA_ENCODING_MPEG_IEC61937;
ss.format = PA_SAMPLE_S16NE;
break;*/
case VLC_CODEC_DTS:
fmt->i_format = VLC_CODEC_SPDIFL;
......@@ -745,7 +742,6 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
fmt->i_physical_channels = AOUT_CHANS_2_0;
fmt->i_channels = 2;
encoding = PA_ENCODING_DTS_IEC61937;
ss.format = PA_SAMPLE_S16NE;
break;
default:
if (!AOUT_FMT_LINEAR(fmt) || aout_FormatNbChannels(fmt) == 0)
......@@ -800,13 +796,14 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
pa_cvolume_init(&sys->cvolume);
sys->first_pts = VLC_TS_INVALID;
pa_format_info *formatv;
pa_format_info *formatv = pa_format_info_new();
formatv->encoding = encoding;
pa_format_info_set_rate(formatv, ss.rate);
if (ss.format != PA_SAMPLE_INVALID)
pa_format_info_set_sample_format(formatv, ss.format);
/* Favor digital pass-through if available*/
if (encoding != PA_ENCODING_INVALID) {
formatv = pa_format_info_new();
formatv->encoding = encoding;
pa_format_info_set_rate(formatv, ss.rate);
if (encoding != PA_ENCODING_PCM)
{
pa_format_info_set_channels(formatv, ss.channels);
/* FIX flags are only permitted for PCM, and there is no way to pass
......@@ -860,11 +857,6 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
msg_Dbg(aout, "using %s channel map", (name != NULL) ? name : "?");
}
/* PCM */
formatv = pa_format_info_new();
formatv->encoding = PA_ENCODING_PCM;
pa_format_info_set_sample_format(formatv, ss.format);
pa_format_info_set_rate(formatv, ss.rate);
pa_format_info_set_channels(formatv, ss.channels);
pa_format_info_set_channel_map(formatv, &map);
}
......@@ -923,7 +915,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
if (pa_stream_connect_playback(s, sys->sink_force, &attr, flags,
cvolume, NULL) < 0
|| stream_wait(s, sys->mainloop)) {
if (encoding != PA_ENCODING_INVALID)
if (encoding != PA_ENCODING_PCM)
vlc_pa_error(aout, "digital pass-through stream connection failure",
sys->context);
else
......@@ -935,7 +927,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
free(sys->sink_force);
sys->sink_force = NULL;
if (encoding == PA_ENCODING_INVALID)
if (encoding == PA_ENCODING_PCM)
{
const struct pa_sample_spec *spec = pa_stream_get_sample_spec(s);
fmt->i_rate = spec->rate;
......
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