LMS-Community / plugin-Qobuz

Squeebox plugin to stream from qobuz.com
31 stars 16 forks source link

Samplerate/samplesize always show the maximum available when playing tracks imported to the library #55

Closed michaelherger closed 1 year ago

michaelherger commented 1 year ago

When using the library integration feature with Qobuz, FLAC tracks would always report the maximum available samplerate/-size, not the actual values. When playing from the Qobuz menus directly this doesn't happen. This is due to storing the data at scan time in the library.db. LMS would prefer that stored data over the data provided by the plugin at playtime.

See https://forums.slimdevices.com/forum/user-forums/3rd-party-software/94305-qobuz-com-streaming-plugin?p=1643707#post1643707.

Data is imported here:

https://github.com/pierrepoulpe/SqueezeboxQobuz/blob/788b16a9f640d22cce6f6976336242874fdad428/Importer.pm#L359-L361

But it would be correctly reported by the API at playtime here:

https://github.com/pierrepoulpe/SqueezeboxQobuz/blob/788b16a9f640d22cce6f6976336242874fdad428/API.pm#L572-L586

And consumed here:

https://github.com/pierrepoulpe/SqueezeboxQobuz/blob/788b16a9f640d22cce6f6976336242874fdad428/ProtocolHandler.pm#L377-L385

We might be able to update the stored record here using something like the following (not really tested):

diff --git a/ProtocolHandler.pm b/ProtocolHandler.pm
index b79123e..2322c85 100644
--- a/ProtocolHandler.pm
+++ b/ProtocolHandler.pm
@@ -383,6 +384,12 @@ sub getNextTrack {
                        $song->pluginData(samplesize => $streamData->{bit_depth});
                        $song->pluginData(samplerate => $streamData->{sampling_rate});

+                       if (my $track = Slim::Schema->rs('Track')->single({ url => $url })) {
+                               $track->samplerate($streamData->{sampling_rate}) * 1000;
+                               $track->samplesize($streamData->{bit_depth});
+                               $track->update();
+                       }
+
                        Plugins::Qobuz::API->getFileUrl(sub {
                                $song->streamUrl(shift);

To be followed up...

SamInPgh commented 1 year ago

The problem was actually due to LMS not passing the updated sample rate/size metadata to clients in status query responses. That problem has been fixed in LMS PR #898.