summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-09-02 08:38:23 +0200
committerMax Kellermann <max@musicpd.org>2018-09-02 08:38:23 +0200
commitc5c4d4a57e02103b752e6b53330a28c298556f34 (patch)
treefb126f0ee9146da8d7db9341f884d2690bbd63a9 /src
parent2d0b429b6ad558df07719b59ae489df0168db217 (diff)
db/proxy: forward the audio format
Requires libmpdclient 2.15.
Diffstat (limited to 'src')
-rw-r--r--src/db/plugins/ProxyDatabasePlugin.cxx38
1 files changed, 38 insertions, 0 deletions
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);