ralph-irving / squeezelite

Lightweight headless squeezebox player for Lyrion Media Server
https://sourceforge.net/projects/lmsclients/files/squeezelite/
Other
391 stars 98 forks source link

Issue with mp3 playback on Alpine Linux with recent squeezelite versions #221

Closed sodface closed 7 months ago

sodface commented 7 months ago

First reported on the slimdevices forum.

I updated squeezelite to latest master (1481) and subsequently couldn't natively playback mp3. Testing previous versions, 1479 is ok and then 1480 breaks.

1479:

[07:34:34.559016] output_thread:685 open output device: default
[07:34:34.559031] alsa_open:354 opening device at: 44100
[07:34:34.559058] register_dsd:908 using dsd to decode dsf,dff
[07:34:34.559156] load_faad:633 loaded libfaad.so.2
[07:34:34.559162] register_faad:663 using faad to decode aac
[07:34:34.559353] load_vorbis:349 loaded libvorbisfile.so.3
[07:34:34.559360] register_vorbis:378 using vorbis to decode ogg
[07:34:34.559495] load_opus:294 loaded libopusfile.so.0
[07:34:34.559501] register_opus:324 using opus to decode ops
[07:34:34.559592] load_flac:354 loaded libFLAC.so.12
[07:34:34.559597] register_flac:382 using flac to decode ogf,flc
[07:34:34.559602] register_pcm:483 using pcm to decode aif,pcm
[07:34:34.559669] load_mad:394 loaded libmad.so.0
[07:34:34.559675] register_mad:423 using mad to decode mp3
[07:34:34.559680] decode_init:202 include codecs: exclude codecs:
[07:34:34.559721] discover_server:800 sending discovery
[07:34:34.560911] alsa_open:425 opened device default using format: S32_LE sample rate: 44100 mmap: 1
[07:34:34.560932] alsa_open:516 buffer: 40 period: 4 -> buffer size: 1764 period size: 441
[07:34:34.584381] slimproto:942 connected
[07:34:34.584718] sendHELO:150 cap: CanHTTPS=1,Model=squeezelite,AccuratePlayPoints=1, HasDigitalOut=1,HasPolarityInversion=1,Balance=1,F irmware=v2.0.0-1479,ModelName=SqueezeLite,MaxSampleRate=384000,ds f,dff,aac,ogg,ops,ogf,flc,aif,pcm,mp3

1480:

[07:39:03.524646] output_thread:685 open output device: default
[07:39:03.524663] alsa_open:354 opening device at: 44100
[07:39:03.524707] register_dsd:908 using dsd to decode dsf,dff
[07:39:03.524824] load_faad:633 loaded libfaad.so.2
[07:39:03.524832] register_faad:663 using faad to decode aac
[07:39:03.525075] load_vorbis:349 loaded libvorbisfile.so.3
[07:39:03.525083] register_vorbis:378 using vorbis to decode ogg
[07:39:03.525256] load_opus:294 loaded libopusfile.so.0
[07:39:03.525265] register_opus:324 using opus to decode ops
[07:39:03.525375] load_flac:349 OggFlac chaining disabled
[07:39:03.525381] load_flac:352 loaded libFLAC.so.12
[07:39:03.525388] register_flac:382 using flac to decode ogf,flc
[07:39:03.525394] register_pcm:483 using pcm to decode aif,pcm
[07:39:03.525473] load_mad:390 dlerror: Symbol not found: FLAC__stream_decoder_set_ogg_chaining
[07:39:03.525482] decode_init:202 include codecs: exclude codecs:
[07:39:03.525533] discover_server:800 sending discovery
[07:39:03.526999] alsa_open:425 opened device default using format: S32_LE sample rate: 44100 mmap: 1
[07:39:03.527024] alsa_open:516 buffer: 40 period: 4 -> buffer size: 1764 period size: 441
[07:39:03.545902] slimproto:942 connected
[07:39:03.546067] sendHELO:150 cap: CanHTTPS=1,Model=squeezelite,AccuratePlayPoints=1, HasDigitalOut=1,HasPolarityInversion=1,Balance=1,F irmware=v2.0.0-1480,ModelName=SqueezeLite,MaxSampleRate=384000,ds f,dff,aac,ogg,ops,ogf,flc,aif,pcm

I'm out of my depth here, but as a reminder, Alpine uses musl libc and there is a page that details some of the differences with glibc which may or may not be relevant:

https://wiki.musl-libc.org/functional-differences-from-glibc.html#Dynamic-linker

I'd appreciate any help and standing by to test. Thanks!!

paul-1 commented 7 months ago

Can you upgrade your flac package to support ogg chaining?

sodface commented 7 months ago

Can you upgrade your flac package to support ogg chaining?

Is there a version that does or are you saying patch it? I haven't really been following this ogg chaining feature but there are still open PRs I see upstream for it:

https://github.com/xiph/flac/pull/261 https://github.com/xiph/flac/pull/667

paul-1 commented 7 months ago

1.4.3 plus this patch. https://sourceforge.net/projects/lmsclients/files/source/flac.patch

Using the updated flac would make the symbol available. It appears the musl dl loader is not happy with the way it's currently trapped.

paul-1 commented 7 months ago

I think the error is caused by this. https://github.com/ralph-irving/squeezelite/blob/c751ef146265c243cdbd7c0353dd0b70ab51730c/flac.c#L346-L350 This section traps the ogg error, but does not call dlerror(). dlerror will report whatever error occurred since it's last call. Since the next call to dlerror happens when mad is loading, that's when the error shows up. So perhaps not a musl specific problem either.

paul-1 commented 7 months ago

You could try this patch.

diff --git a/flac.c b/flac.c
index 4667461..c4e8bb4 100644
--- a/flac.c
+++ b/flac.c
@@ -346,9 +346,12 @@ static bool load_flac() {
        // ignore error for this new API
        f->FLAC__stream_decoder_set_ogg_chaining = dlsym(handle, "FLAC__stream_decoder_set_ogg_chaining");
        if (!f->FLAC__stream_decoder_set_ogg_chaining) {
+               if ((err = dlerror()) != NULL) {
+                       LOG_INFO("dlerror: %s", err);
+               }
                LOG_INFO("OggFlac chaining disabled");
        }
-
+
        LOG_INFO("loaded %s", name);
 #elif !defined(FLAC__OGG_CHAINING)
        LOG_INFO("OggFlac chaining disabled");
sodface commented 7 months ago

Yes, that seems to fix it!

[10:56:47.085080] register_dsd:908 using dsd to decode dsf,dff
[10:56:47.085208] load_faad:633 loaded libfaad.so.2
[10:56:47.085217] register_faad:663 using faad to decode aac
[10:56:47.085452] load_vorbis:349 loaded libvorbisfile.so.3
[10:56:47.085460] register_vorbis:378 using vorbis to decode ogg
[10:56:47.085607] load_opus:294 loaded libopusfile.so.0
[10:56:47.085614] register_opus:324 using opus to decode ops
[10:56:47.085748] load_flac:350 dlerror: Symbol not found: FLAC__stream_decoder_set_ogg_chaining
[10:56:47.085757] load_flac:352 OggFlac chaining disabled
[10:56:47.085764] load_flac:355 loaded libFLAC.so.12
[10:56:47.085771] register_flac:385 using flac to decode ogf,flc
[10:56:47.085777] register_pcm:483 using pcm to decode aif,pcm
[10:56:47.085895] load_mad:394 loaded libmad.so.0
[10:56:47.085902] register_mad:423 using mad to decode mp3
[10:56:47.085909] decode_init:202 include codecs:  exclude codecs: 
[10:56:47.085957] discover_server:800 sending discovery
[10:56:47.087415] alsa_open:425 opened device default using format: S32_LE sample rate: 44100 mmap: 1
[10:56:47.087440] alsa_open:516 buffer: 40 period: 4 -> buffer size: 1764 period size: 441
[10:56:47.101356] slimproto:942 connected
[10:56:47.101388] sendHELO:150 cap: CanHTTPS=1,Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Balance=1,Firmware=v2.0.0-1481,ModelName=SqueezeLite,MaxSampleRate=384000,dsf,dff,aac,ogg,ops,ogf,flc,aif,pcm,mp3
ralph-irving commented 7 months ago

@paul-1 Thanks for tracking down the problem.

sodface commented 7 months ago

1486 tested and working, please close at your discretion. Thanks for the support @paul-1 and @ralph-irving !