From c5c4d4a57e02103b752e6b53330a28c298556f34 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 2 Sep 2018 08:38:23 +0200 Subject: db/proxy: forward the audio format Requires libmpdclient 2.15. --- src/db/plugins/ProxyDatabasePlugin.cxx | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src') diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index 701b635ed..f9d788a19 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -215,6 +215,44 @@ ProxySong::ProxySong(const mpd_song *song) start_time = SongTime::FromS(mpd_song_get_start(song)); end_time = SongTime::FromS(mpd_song_get_end(song)); +#if LIBMPDCLIENT_CHECK_VERSION(2,15,0) + const auto *af = mpd_song_get_audio_format(song); + if (af != nullptr) { + if (audio_valid_sample_rate(af->sample_rate)) + audio_format.sample_rate = af->sample_rate; + + + switch (af->bits) { + case MPD_SAMPLE_FORMAT_FLOAT: + audio_format.format = SampleFormat::FLOAT; + break; + + case MPD_SAMPLE_FORMAT_DSD: + audio_format.format = SampleFormat::DSD; + break; + + case 8: + audio_format.format = SampleFormat::S8; + break; + + case 16: + audio_format.format = SampleFormat::S16; + break; + + case 24: + audio_format.format = SampleFormat::S24_P32; + break; + + case 32: + audio_format.format = SampleFormat::S32; + break; + } + + if (audio_valid_channel_count(af->channels)) + audio_format.channels = af->channels; + } +#endif + TagBuilder tag_builder; const unsigned duration = mpd_song_get_duration(song); -- cgit v1.2.3