librespot-org / librespot-java

The most up-to-date open source Spotify client
Apache License 2.0
375 stars 91 forks source link

Mixer problem #53

Closed Alexays closed 5 years ago

Alexays commented 5 years ago

Hi! I just lauch it on my raspberry and that says that the only mixer available is pulseaudio when it's not even installed There any way to pass directly a device like plughw:CARD=AMP,DEV=0? Thanks!

devgianlu commented 5 years ago

That's strange, I don't have a Raspberry Pi to test it on, but I'll try to figure something out. Does the playback work if you don't edit the settings? Can you provide the logs?

mordax7 commented 5 years ago

Hello @Alexays

what I did is enable the logAvailableMixers option, you should be able to see all the "mixers" in the logs. Afterwards pick the one you want to use, in my case I am using Raspberry with hifiberry and since I am using their sound card, I had to write the mixer name "sndrpihifiberry" in the field "mixerSearchKeywords". I think they use ALSA in the background, works perfectly well.

Regards

PS: I also had to disable the default audio jack in the /boot/config.txt by commenting this out: dtparam=audio=on

giggywithit commented 5 years ago

Hello Is there a discussion thread for this project? I'm wanting to know if this works as a Spotify connect and plays live albums gaplessly.

Thank you and sorry for not finding a discussion thread.

devgianlu commented 5 years ago

@giggywithit It works with Spotify Connect and it is able to play radios, if that's what you're interested in.

Alexays commented 5 years ago

@devgianlu Sorry for the delay, here the log

2019-03-16 16:29:53 INFO  Utils:83 - Cryptography restrictions removal not needed.
2019-03-16 16:29:53 INFO  ZeroconfServer:318 - Zeroconf HTTP server started successfully on port 47967!
2019-03-16 16:29:53 TRACE ZeroconfServer:165 - Adding addresses of eth0 (displayName: eth0)
2019-03-16 16:29:53 DEBUG ZeroconfServer:107 - Registering service on [/fe80:0:0:0:ba27:ebff:fe62:c10a%eth0, /2a01:e35:8b9e:6d70:ba27:ebff:fe62:c10a%eth0, /192.168.0.1]
2019-03-16 16:29:53 INFO  ZeroconfServer:120 - SpotifyConnect service registered successfully!
2019-03-16 16:30:00 TRACE ZeroconfServer:354 - Handling request: GET /?action=getInfo HTTP/1.1, headers: {Keep-Alive=0, Connection=keep-alive, User-Agent=Spotify/109800078 Linux/0 (PC desktop), Host=192.168.0.1, Accept-Encoding=gzip, Content-Type=application/x-www-form-urlencoded}
2019-03-16 16:30:00 TRACE ZeroconfServer:354 - Handling request: GET /?action=getInfo HTTP/1.1, headers: {Keep-Alive=0, Connection=keep-alive, User-Agent=Spotify/109800078 Linux/0 (PC desktop), Host=192.168.0.1, Accept-Encoding=gzip, Content-Type=application/x-www-form-urlencoded}
2019-03-16 16:30:00 TRACE ZeroconfServer:354 - Handling request: GET /?action=getInfo HTTP/1.1, headers: {Keep-Alive=0, Connection=keep-alive, User-Agent=Spotify/109800078 Linux/0 (PC desktop), Host=192.168.0.1, Accept-Encoding=gzip, Content-Type=application/x-www-form-urlencoded}
2019-03-16 16:30:00 TRACE ZeroconfServer:354 - Handling request: GET /?action=getInfo HTTP/1.1, headers: {Keep-Alive=0, Connection=keep-alive, User-Agent=Spotify/109800078 Linux/0 (PC desktop), Host=192.168.0.1, Accept-Encoding=gzip, Content-Type=application/x-www-form-urlencoded}
2019-03-16 16:30:00 TRACE ZeroconfServer:354 - Handling request: GET /?action=getInfo HTTP/1.1, headers: {Keep-Alive=0, Connection=keep-alive, User-Agent=Spotify/109800078 Linux/0 (PC desktop), Host=192.168.0.1, Accept-Encoding=gzip, Content-Type=application/x-www-form-urlencoded}
2019-03-16 16:30:01 TRACE ZeroconfServer:354 - Handling request: POST / HTTP/1.1, headers: {Keep-Alive=0, Connection=keep-alive, User-Agent=Spotify/109800078 Linux/0 (PC desktop), Host=192.168.0.1, Accept-Encoding=gzip, Content-Length=700, Content-Type=application/x-www-form-urlencoded}
2019-03-16 16:30:03 INFO  Session:65 - Created new session! {deviceId: 62949434-bd9e-4432-99f1-4784fa0da6e1, ap: gew1-accesspoint-b-74sl.ap.spotify.com/104.199.65.239} 
2019-03-16 16:30:03 INFO  ZeroconfServer:278 - Accepted new user. {deviceId: 62949434-bd9e-4432-99f1-4784fa0da6e1}
2019-03-16 16:30:05 INFO  Session:197 - Connected successfully!
2019-03-16 16:30:05 TRACE Session:645 - Handled Ping
2019-03-16 16:30:05 INFO  Session:681 - Skipping SecretBlock
2019-03-16 16:30:05 INFO  Session:661 - Received LicenseVersion: 1, 1.0.1-FR
2019-03-16 16:30:05 INFO  Session:654 - Received CountryCode: FR
2019-03-16 16:30:05 INFO  Session:681 - Skipping ProductInfo
2019-03-16 16:30:05 INFO  Session:681 - Skipping LegacyWelcome
2019-03-16 16:30:05 INFO  Session:681 - Skipping UnknownData_AllZeros
2019-03-16 16:30:05 DEBUG Session:664 - Received 0x10: 85AFD3E989806B825CAEA8015784247E36E4C903
2019-03-16 16:30:05 TRACE Session:651 - Handled PongAck
2019-03-16 16:30:05 TRACE MercuryClient:104 - Send Mercury request, seq: 1, uri: hm://remote/user/alexays/, method: SUB
2019-03-16 16:30:05 TRACE MercuryClient:146 - Handling packet, cmd: MercurySub, seq: 1, flags: 1, parts: 1
2019-03-16 16:30:05 TRACE MercuryClient:52 - Subscribed successfully to hm://remote/user/alexays/!
2019-03-16 16:30:05 TRACE SpotifyIrc:101 - Send frame, type: kMessageTypeHello
2019-03-16 16:30:05 TRACE MercuryClient:104 - Send Mercury request, seq: 2, uri: hm://remote/user/alexays/, method: SEND
2019-03-16 16:30:05 TRACE MercuryClient:146 - Handling packet, cmd: MercuryReq, seq: 2, flags: 1, parts: 1
2019-03-16 16:30:05 TRACE SpotifyIrc:115 - Frame sent successfully, type: kMessageTypeHello
2019-03-16 16:30:05 INFO  Session:211 - Authenticated as alexays!
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercurySubEvent, seq: 1013894856344338432, flags: 1, parts: 2
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercurySubEvent, seq: 1085952450382266368, flags: 1, parts: 2
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercurySubEvent, seq: 1158010044420194304, flags: 1, parts: 2
2019-03-16 16:30:06 TRACE SpotifyIrc:191 - Handling frame, type: kMessageTypeNotify, ident: af1f9cb4780544a0e7dcefbd68faac34092f284a
2019-03-16 16:30:06 TRACE SpotifyIrc:191 - Handling frame, type: kMessageTypeNotify, ident: f61da8974dbcd771a998f11705745e1c8c02cfaf
2019-03-16 16:30:06 TRACE SpotifyIrc:191 - Handling frame, type: kMessageTypeNotify, ident: f69fecd63088c8027fb29bb73dad8e0fd4c62d22
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercurySubEvent, seq: 1230067638458122240, flags: 1, parts: 2
2019-03-16 16:30:06 TRACE SpotifyIrc:191 - Handling frame, type: kMessageTypeLoad, ident: f61da8974dbcd771a998f11705745e1c8c02cfaf
2019-03-16 16:30:06 DEBUG Player:271 - Loading context, uri: spotify:user:alexays:playlist:2FkCgf9hoOhcoPy95HFAIb
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercurySubEvent, seq: 1302125232496050176, flags: 1, parts: 2
2019-03-16 16:30:06 TRACE SpotifyIrc:191 - Handling frame, type: kMessageTypeNotify, ident: f61da8974dbcd771a998f11705745e1c8c02cfaf
2019-03-16 16:30:06 TRACE SpotifyIrc:101 - Send frame, type: kMessageTypeNotify
2019-03-16 16:30:06 TRACE MercuryClient:104 - Send Mercury request, seq: 3, uri: hm://remote/user/alexays/, method: SEND
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercuryReq, seq: 3, flags: 1, parts: 1
2019-03-16 16:30:06 TRACE SpotifyIrc:115 - Frame sent successfully, type: kMessageTypeNotify
2019-03-16 16:30:06 TRACE SpotifyIrc:101 - Send frame, type: kMessageTypeNotify
2019-03-16 16:30:06 TRACE MercuryClient:104 - Send Mercury request, seq: 4, uri: hm://remote/user/alexays/, method: SEND
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercuryReq, seq: 4, flags: 1, parts: 1
2019-03-16 16:30:06 TRACE SpotifyIrc:115 - Frame sent successfully, type: kMessageTypeNotify
2019-03-16 16:30:06 TRACE MercuryClient:104 - Send Mercury request, seq: 5, uri: hm://metadata/4/track/F451DD34B31B442AB6FB9FC746ED3C9F, method: GET
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercurySubEvent, seq: 1446240420571906048, flags: 1, parts: 2
2019-03-16 16:30:06 TRACE SpotifyIrc:191 - Handling frame, type: kMessageTypeNotify, ident: f61da8974dbcd771a998f11705745e1c8c02cfaf
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercuryReq, seq: 5, flags: 1, parts: 2
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercurySubEvent, seq: 1590355608647761920, flags: 1, parts: 2
2019-03-16 16:30:06 TRACE SpotifyIrc:191 - Handling frame, type: kMessageTypeNotify, ident: af1f9cb4780544a0e7dcefbd68faac34092f284a
2019-03-16 16:30:06 INFO  Session:681 - Skipping UnknownData_AllZeros
2019-03-16 16:30:06 TRACE MercuryClient:146 - Handling packet, cmd: MercurySubEvent, seq: 1662413202685689856, flags: 1, parts: 2
2019-03-16 16:30:06 TRACE SpotifyIrc:191 - Handling frame, type: kMessageTypePause, ident: play-token
2019-03-16 16:30:06 TRACE AudioFileStreaming:69 - Track size: 10487928
2019-03-16 16:30:06 TRACE AudioFileStreaming:71 - Track has 81 chunks.
2019-03-16 16:30:07 TRACE AudioFileStreaming:99 - Chunk 0/81 completed, cached: false, fileId: 69D147A3726B64EC111AB97473AD367918C57251
2019-03-16 16:30:07 TRACE StreamFeeder:59 - Loaded normalization data, track_gain: -9.55, track_peak: 1.06, album_gain: -9.56, album_peak: 1.06
2019-03-16 16:30:07 INFO  TrackHandler:50 - Loaded track, name: 'Just Need Your Love', artists: 'Hyphen Hyphen', gid: F451DD34B31B442AB6FB9FC746ED3C9F
2019-03-16 16:30:08 INFO  LinesHolder:102 - Available mixers: 'PulseAudio Mixer'
2019-03-16 16:30:08 INFO  LinesHolder:104 - Mixer for playback 'PulseAudio Mixer', maxLines: -1
2019-03-16 16:30:08 DEBUG LinesHolder:69 - Got first line from mixer 'PulseAudio Mixer'
2019-03-16 16:30:08 TRACE PlayerRunner:77 - Player ready for playback, fileId: 69D147A3726B64EC111AB97473AD367918C57251
2019-03-16 16:30:08 TRACE SpotifyIrc:101 - Send frame, type: kMessageTypeNotify
2019-03-16 16:30:08 TRACE MercuryClient:104 - Send Mercury request, seq: 6, uri: hm://remote/user/alexays/, method: SEND
2019-03-16 16:30:08 DEBUG LinesHolder:112 - Removed closed line, remaining: 0
2019-03-16 16:30:08 TRACE PlayerRunner:271 - Cleaned up player.
Exception in thread "player-runner-22161036" java.lang.UnsatisfiedLinkError: no icedtea-sound in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at org.classpath.icedtea.pulseaudio.SecurityWrapper.loadNativeLibrary(SecurityWrapper.java:66)
    at org.classpath.icedtea.pulseaudio.EventLoop.<clinit>(EventLoop.java:97)
    at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openImpl(PulseAudioMixer.java:654)
    at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openLocal(PulseAudioMixer.java:588)
    at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openLocal(PulseAudioMixer.java:584)
    at org.classpath.icedtea.pulseaudio.PulseAudioMixer.open(PulseAudioMixer.java:579)
    at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.open(PulseAudioDataLine.java:94)
    at org.classpath.icedtea.pulseaudio.PulseAudioSourceDataLine.open(PulseAudioSourceDataLine.java:75)
    at org.classpath.icedtea.pulseaudio.PulseAudioSourceDataLine.open(PulseAudioSourceDataLine.java:90)
    at xyz.gianlu.librespot.player.LinesHolder$LineWrapper.waitAndOpen(LinesHolder.java:139)
    at xyz.gianlu.librespot.player.PlayerRunner.readBody(PlayerRunner.java:160)
    at xyz.gianlu.librespot.player.PlayerRunner.run(PlayerRunner.java:277)
    at java.lang.Thread.run(Thread.java:748)
2019-03-16 16:30:08 INFO  Session:681 - Skipping Pause
2019-03-16 16:30:08 TRACE MercuryClient:146 - Handling packet, cmd: MercuryReq, seq: 6, flags: 1, parts: 1
2019-03-16 16:30:08 TRACE SpotifyIrc:115 - Frame sent successfully, type: kMessageTypeNotify
2019-03-16 16:30:08 TRACE AudioFileStreaming:99 - Chunk 1/81 completed, cached: false, fileId: 69D147A3726B64EC111AB97473AD367918C57251
2019-03-16 16:30:09 TRACE AudioFileStreaming:99 - Chunk 52/81 completed, cached: false, fileId: 69D147A3726B64EC111AB97473AD367918C57251
2019-03-16 16:30:09 TRACE AudioFileStreaming:99 - Chunk 51/81 completed, cached: false, fileId: 69D147A3726B64EC111AB97473AD367918C57251
devgianlu commented 5 years ago

It looks like Java doesn't support PulseAudio, as you said, there should be another audio backend installed. Please follow the instructions provided by @xMordax above.

mordax7 commented 5 years ago

@Alexays I also noticed you have only PulseAudio, if you want to keep using it(although I find ALSA better) you can leave the parameter mixerSearchKeywords empty since it will pick the default one, and you have only one. Like I said, I had more success with ALSA, here is also a short overview of how to set it up: http://blog.scphillips.com/posts/2013/01/sound-configuration-on-raspberry-pi-with-alsa/

devgianlu commented 5 years ago

Closing for inactivity.

loeffelpan commented 4 years ago

Just had to reinstall my RPi with an new image. Before I used ALSA for Librespot and PulseAudio (by default) for Kodi on that device.

I reconfigured ALSA the same way as before, but Librespot shows only the Pulseaudio Mixer, what is not supported in java (exeption as above). Kodi shows ALSA devices and I can use them in Kodi (unless this doesn‘t make sense).

Any help?

devgianlu commented 4 years ago

I see a couple of solutions:

loeffelpan commented 4 years ago

Must be an issue with the JDK. But I am confused that it has worked before with same package installed.

IcedTeaJDK is not an option cause I want to use ALSA instead of PulseAudio for this purpose.

Changes in sound.conf didn't do the trick. Looks like librespot pulls only the icedtea audio classes to get mixer. But cannot be true, as it worked before the same way without any configuration from my side.

devgianlu commented 4 years ago

Maybe the new image changed some configuration files. I use ALSA on my Banana Pi R1, but it doesn't even have a configuration file (??). I found this page which has a lot on information, including some debugging steps. As a last resort I'd check the changelogs of the RPi image.

loeffelpan commented 4 years ago

No hint to changed config files in any Image. But I will try an older one to proof.

Alsa by itself is fine. Aplay, Amixer and speaker-test give expected results.

devgianlu commented 4 years ago

Can you drop the image link here? I'll try to emulated an RPi with QEMU and see if I can reproduce your issue. This should also be a better way to test librespot-java with restricted resources.

loeffelpan commented 4 years ago

Images from here: https://osmc.tv/download/

Fresh 2019.07-1: Java doensn't get the alsa mixers

2018.12-1 (image I used initial); Upgraded with apt dist-upgrade: Java doensn't get the alsa mixers

Fresh 2018.12-1; Without upgrading via apt: Java doensn't get the alsa mixers

Must have something do to with the JDK-package I get from apt repo. I will try another JDK later.

crsmoro commented 4 years ago

i dont run spotify connect on the same hardware as OSMC anymore, but i had these instructions on scplayer, i dont know if they are still valid, but here it is

If you are running on OSMC you have to run this command to enable alsa drivers
for older versions from ssh type sudo modprobe snd_bcm2835 , no need to reboot
for newer versions add this line dtparam=audio=on to /boot/config.txt
loeffelpan commented 4 years ago

That's not the issue. Was something with latest jdk from debian stretch repo.

Got this working again with openjdk11 from stretch-backports repo. Thanks for advice.