Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to coexist with raspotify: Mopidy claims ALSA device. #529

Closed
Borromini opened this issue Apr 25, 2020 · 6 comments
Closed

Unable to coexist with raspotify: Mopidy claims ALSA device. #529

Borromini opened this issue Apr 25, 2020 · 6 comments
Labels
bug waiting on author Further information needed to fix

Comments

@Borromini
Copy link

Describe the bug
I used Mopidy with Moped before Mopidy bumped to 3.x; because Raspotify gave us better results with, we used Mopidy/Moped just for web radio and Raspotify for Spotify. They ran both alongside and that worked fine.

Now with having switched to Mopidy 3 and Iris (for web radio only still), we're seeing Raspotify break once we try to play anything through Spotify (through Raspotify).

Audio device is 0,0; at first I thought I had to specify it through Raspotify's settings but that doesn't make any difference (it worked wonderfully without before the Mopidy/Iris switch as well).

To Reproduce
Steps to reproduce the behavior:

  1. Start the Raspotify service.
  2. Start the Mopidy service with the Iris extension.
  3. Play some music from Spotify through Raspotify (the Spotify app on your smartphone will see it the device running Raspotify as a Spotify device - apologies if terminology is off). Raspotify log will show this, e.g.:
Apr 25 21:47:58 rpi1 librespot[3757]: [2020-04-25T19:47:58Z INFO  librespot_playback::player] Loading <Somebody to Love Me> with Spotify URI <spotify:track:2Tky1eOpdLXo8yYawnTMcj>
Apr 25 21:47:59 rpi1 librespot[3757]: [2020-04-25T19:47:59Z INFO  librespot_playback::player] <Somebody to Love Me> loaded
  1. Pause your Spotify track.
  2. Play some radio stream through the Iris web interface, then pause it.
  3. Try playing another track on your Spotify app; it looks like it's working but there's no sound, and Raspotify throws these errors:
Apr 25 21:47:59 rpi1 librespot[3757]: [2020-04-25T19:47:59Z ERROR librespot_playback::audio_backend::alsa] Alsa error PCM open ALSA function 'snd_pcm_open' failed with error 'EBUSY: Device or resource busy'
Apr 25 21:47:59 rpi1 librespot[3757]: [2020-04-25T19:47:59Z ERROR librespot_playback::player] Could not start audio: Alsa error: PCM open failed

Expected behavior
Coexistence between Raspotify and Mopidy/Iris

Environment details:

  • OS: Raspbian Buster, up to date.
  • Browser: Firefox (probably not relevant)
  • Mopidy / Iris version:
# pip3 list|grep Mopidy
Mopidy         3.0.2    
Mopidy-Iris    3.47.0   
Mopidy-Spotify 4.0.1    
Mopidy-TuneIn  1.0.0

It's a long shot, but maybe having a stop button (like #434) might fix this? Maybe Mopidy is still keeping the ALSA device active because the stream is paused, not stopped?

@Borromini Borromini added the bug label Apr 25, 2020
@jaedb
Copy link
Owner

jaedb commented Apr 26, 2020

Firstly, thanks for the thorough issue report!

The quick way to test if pause is what is causing the issue would be stop Mopidy playback. You can do this in Iris by going to Settings > Debug > Mopidy and enter playback.stop in the Call field. Then try and play from Raspotify and let me know how that goes.

Failing that, it's likely to be a Mopidy issue, rather than an Iris issue.

@jaedb jaedb added the waiting on author Further information needed to fix label May 20, 2020
@ghost
Copy link

ghost commented May 28, 2020

Hi,

I could reproduce the issue only once (on the Android Spotify app), otherwise it seems to work both from the Android app and from the linux Spotify app. Actually I can play two different songs simultaneously which is strange.. I tried playback.stop once but then couldn't reproduce it anymore to try again.

@jaedb
Copy link
Owner

jaedb commented Jun 2, 2020

@clavelc I'm a bit confused about the link between Android Spotify app and Iris. The two are two entirely separate systems, so I don't think it is related to the original issue. Unless I misunderstand your comment?

As a side-note, I have also noticed I can play Spotify from two devices at once which I couldn't previously do.

@kingosticks
Copy link
Contributor

Pause does not release the ALSA device. That's intentional, it hasn't changed with the 3.x release and it's not a bug.

If you still have this issue you need to either issue a stop command when switching (librespot let's you run a command before it's playback starts, you can use that to run mpc stop), or, configure ALSA on your system to use a dmix plug, this let's multiple processes use the same output device at the same time i.e. Mopidy would be paused and silent but still have access to the device while Raspotify was playing. There's lots of info online about how to configure ALSA's dmix plug.

@jaedb
Copy link
Owner

jaedb commented Jun 2, 2020

@Borromini as per @kingosticks comments above, this isn't something that I can fix within Iris. The workaround is to ensure you stop your stream from Iris (keyboard shortcut s) to release ALSA.

@jaedb jaedb closed this as completed Jun 2, 2020
@Borromini
Copy link
Author

@jaedb Sorry about getting back to you on this so late. I've been buried in other stuff...

I tried using s but that pops up the search window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug waiting on author Further information needed to fix
Projects
None yet
Development

No branches or pull requests

3 participants