diff options
author | Max Kellermann <max@duempel.org> | 2011-10-10 09:40:46 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-10-10 10:13:43 +0200 |
commit | 4c9782ee2897e8491e4a3590f3eb8db7de9d12b9 (patch) | |
tree | 3f80ea31d23f439a8e8dc228a727820fe7cf28ce /src/decoder | |
parent | 26225307d30d91c9a33166f775b00775c4d2802e (diff) | |
download | mpd-4c9782ee2897e8491e4a3590f3eb8db7de9d12b9.tar.gz mpd-4c9782ee2897e8491e4a3590f3eb8db7de9d12b9.tar.xz mpd-4c9782ee2897e8491e4a3590f3eb8db7de9d12b9.zip |
decoder/pcm: support reverse byte order
Diffstat (limited to '')
-rw-r--r-- | src/decoder/pcm_decoder_plugin.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/decoder/pcm_decoder_plugin.c b/src/decoder/pcm_decoder_plugin.c index abf3e7276..545f7fc82 100644 --- a/src/decoder/pcm_decoder_plugin.c +++ b/src/decoder/pcm_decoder_plugin.c @@ -31,21 +31,35 @@ static void pcm_stream_decode(struct decoder *decoder, struct input_stream *is) { - static const struct audio_format audio_format = { + static const struct audio_format host_audio_format = { .sample_rate = 44100, .format = SAMPLE_FORMAT_S16, .channels = 2, }; + + static const struct audio_format reverse_audio_format = { + .sample_rate = 44100, + .format = SAMPLE_FORMAT_S16, + .channels = 2, + .reverse_endian = true, + }; + + const struct audio_format *audio_format = + (is->mime == NULL || + strcmp(is->mime, "audio/x-mpd-cdda-pcm-reverse") != 0) + ? &host_audio_format + : &reverse_audio_format; + GError *error = NULL; enum decoder_command cmd; - double time_to_size = audio_format_time_to_size(&audio_format); + double time_to_size = audio_format_time_to_size(audio_format); float total_time = -1; if (is->size >= 0) total_time = is->size / time_to_size; - decoder_initialized(decoder, &audio_format, is->seekable, total_time); + decoder_initialized(decoder, audio_format, is->seekable, total_time); do { char buffer[4096]; @@ -80,6 +94,10 @@ pcm_stream_decode(struct decoder *decoder, struct input_stream *is) static const char *const pcm_mime_types[] = { /* for streams obtained by the cdio_paranoia input plugin */ "audio/x-mpd-cdda-pcm", + + /* same as above, but with reverse byte order */ + "audio/x-mpd-cdda-pcm-reverse", + NULL }; |