Support S24_P32/S32/FLOAT sample formats on Pulse

This is based on a patch from Ian Scott in 2014. It was never committed,
so I figured I'd fix the outstanding issue and resubmit it.

https://www.mail-archive.com/mpd-devel%40musicpd.org/msg00139.html
This commit is contained in:
Nils Schneider 2016-08-14 18:45:32 +02:00 committed by Max Kellermann
parent ac49043fbb
commit 62000670e3
2 changed files with 24 additions and 4 deletions

2
NEWS
View File

@ -1,4 +1,6 @@
ver 0.19.19 (not yet released) ver 0.19.19 (not yet released)
* output
- pulse: support 32 bit, 24 bit and floating point playback
ver 0.19.18 (2016/08/05) ver 0.19.18 (2016/08/05)
* decoder * decoder

View File

@ -574,12 +574,30 @@ pulse_output_open(AudioOutput *ao, AudioFormat &audio_format,
return false; return false;
} }
/* MPD doesn't support the other pulseaudio sample formats, so /* Use the sample formats that our version of PulseAudio and MPD
we just force MPD to send us everything as 16 bit */ have in common, otherwise force MPD to send 16 bit */
audio_format.format = SampleFormat::S16;
pa_sample_spec ss; pa_sample_spec ss;
switch (audio_format.format) {
case SampleFormat::FLOAT:
ss.format = PA_SAMPLE_FLOAT32NE;
break;
case SampleFormat::S32:
ss.format = PA_SAMPLE_S32NE;
break;
case SampleFormat::S24_P32:
ss.format = PA_SAMPLE_S24_32NE;
break;
case SampleFormat::S16:
ss.format = PA_SAMPLE_S16NE; ss.format = PA_SAMPLE_S16NE;
break;
default:
audio_format.format = SampleFormat::S16;
ss.format = PA_SAMPLE_S16NE;
break;
}
ss.rate = audio_format.sample_rate; ss.rate = audio_format.sample_rate;
ss.channels = audio_format.channels; ss.channels = audio_format.channels;