[vlc-commits] pulse: refactor pa_format_info initialisation
Thomas Guillem
git at videolan.org
Tue Jul 18 16:58:52 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jun 23 17:25:50 2017 +0200| [b04deb0af25eb692059ffec98c746ab307cea68a] | committer: Thomas Guillem
pulse: refactor pa_format_info initialisation
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b04deb0af25eb692059ffec98c746ab307cea68a
---
modules/audio_output/pulse.c | 30 +++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index e9c70c562d..81dd586658 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -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;
More information about the vlc-commits
mailing list