From 945ea51bd458adaea4d5fa5b42fa7c5b2001dfca Mon Sep 17 00:00:00 2001 From: borine <32966433+borine@users.noreply.github.com> Date: Wed, 6 Mar 2019 08:39:47 +0000 Subject: [PATCH] decoder/plugins/PcmDecoderPlugin: introduce new internal mime type "audio/x-mpd-alsa-pcm" This mime type is to enable the AlsaInputPlugin to communicate the pcm stream audio format to the decoder --- src/decoder/plugins/PcmDecoderPlugin.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/decoder/plugins/PcmDecoderPlugin.cxx b/src/decoder/plugins/PcmDecoderPlugin.cxx index e114c8a32..8cb24fad0 100644 --- a/src/decoder/plugins/PcmDecoderPlugin.cxx +++ b/src/decoder/plugins/PcmDecoderPlugin.cxx @@ -28,6 +28,7 @@ #include "util/StaticFifoBuffer.hxx" #include "util/NumberParser.hxx" #include "util/MimeType.hxx" +#include "AudioParser.hxx" #include "Log.hxx" #include @@ -133,6 +134,20 @@ pcm_stream_decode(DecoderClient &client, InputStream &is) audio_format.channels = value; } + + if (GetMimeTypeBase(mime) == "audio/x-mpd-alsa-pcm") { + i = mime_parameters.find("format"); + if (i != mime_parameters.end()) { + const char *s = i->second.c_str(); + audio_format = ParseAudioFormat(s, false); + if (!audio_format.IsFullyDefined()) { + FormatWarning(pcm_decoder_domain, + "Invalid audio format specification: %s", + mime); + return; + } + } + } } if (audio_format.sample_rate == 0) { @@ -221,6 +236,9 @@ static const char *const pcm_mime_types[] = { /* same as above, but with reverse byte order */ "audio/x-mpd-cdda-pcm-reverse", + /* for streams obtained by the alsa input plugin */ + "audio/x-mpd-alsa-pcm", + nullptr };