Solved Sharing audio with other apps when using AudioEngine
#31
OK, this may be working. At least it's worked for one reboot. In the file /usr/bin/xbmc using the latest xbmcbuntu install plus a nightly build I inserted the following line:
/usr/local/bin/squeezeslave.sh &
before
"$LIBDIR/xbmc/xbmc.bin" $SAVED_ARGS
which is down near the bottom of the script.

I chose to use a script for squeezeslave in case I needed to add a delay so that xbmc could query the audio device first. Right now I have a 30 second delay in there, I don't know if it's needed or not, but I'm tired of dealing with this for now. At this point I've played audio via squeezeslave and video via xbmc, and cycled back and forth between them a few times, and it worked fine.

As I said, I'm using the asound.conf in my first post, and I set the rate to 44100, which is probably a requirement based on my hardware.
Reply
#32
(2013-02-12, 07:26)KeithLM Wrote: Well I'm getting wildly inconsistent results. If start squeezeslave up automatically and delay it so it doesn't start until XBMC is up, both see the audio device. But once I play squeezeslave and then pause it, XBMC can't get to the audio device anymore. It shows up in the list, but when playing video there is no audio, and the video is very glitchy. But if I stop the automatic startup of squeezeslave and start it manually, I can get both to play nice which doesn't make any sense to me whatsoever.

This behaviour was exactly what my dmix .asoundrc solution was meant to fix on Eden. I use both XBMC and MPD on the same box and one would lock out the other one depending on which was the last one to use the sound device. Sometimes (apparently at random) it would work if the last to play released the sound device, but most of them time it wouldn't. The dmix plugin allows them to share the audio device.
Reply
#33
(2013-02-12, 07:51)tknorris Wrote:
(2013-02-12, 07:26)KeithLM Wrote: Well I'm getting wildly inconsistent results. If start squeezeslave up automatically and delay it so it doesn't start until XBMC is up, both see the audio device. But once I play squeezeslave and then pause it, XBMC can't get to the audio device anymore. It shows up in the list, but when playing video there is no audio, and the video is very glitchy. But if I stop the automatic startup of squeezeslave and start it manually, I can get both to play nice which doesn't make any sense to me whatsoever.

This behaviour was exactly what my dmix .asoundrc solution was meant to fix on Eden. I use both XBMC and MPD on the same box and one would lock out the other one depending on which was the last one to use the sound device. Sometimes (apparently at random) it would work if the last to play released the sound device, but most of them time it wouldn't. The dmix plugin allows them to share the audio device.

I didn't have that problem with Eden as I recall. I didn't need two dmix devices for that, nor was it necessary in the end with Frodo. I'm actually wondering if I can eliminate my asound.conf altogether now that I figured out part of my problem was running it out of /etc/init. I may experiment with that later on.

I also need to work on my squeezeslave script, and I probably should look for some other place to start it. While it seems to work from the xbmc script, that will be overwritten anytime I update xbmc. So I'll have to write a script to update that script or something like that. Also I need to double-check that squeezeslave isn't already running before I start it again just to be safe.

Another thing I'd like to do with this system is see if there is a way to get it to restart ok without the TV on. Currently I'm pretty sure XBMC will fail in that case because it can't detect the video. Not sure what to do about that with XBMCbuntu and Intel hardware since I don't even seem to have an xorg.conf.
Reply
#34
@tknorris:
This is fixed in master. Audio Engine releases the sound device 10 seconds after you played the last song. You have to make sure, that mpd is stopped though, when you play the next piece of music / video. I think it is also good to disable menu sounds, so you won't run into trouble, when you forget to stop the mpd.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#35
(2013-02-12, 07:26)KeithLM Wrote: So the goal now is to start squeezeslave via some other scripting method that will run it at the user level rather than as a service.
I have already explained how to do that.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#36
(2013-02-12, 10:19)nickr Wrote:
(2013-02-12, 07:26)KeithLM Wrote: So the goal now is to start squeezeslave via some other scripting method that will run it at the user level rather than as a service.
I have already explained how to do that.

And as I explained I would prefer not to use a modified xbmc script because it could cause conflicts when doing upgrade. I want to find some other place to do this so as not to cause any interference. I believe I've found where the system calls xbmc-standalone, I might be able to change that call to call a script of my own that will execute squeezeplay then call xbmc-standalone.
Reply
#37
I suggested ~/.config/autostart/
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#38
(2013-02-12, 20:34)nickr Wrote: I suggested ~/.config/autostart/

Didn't you also say that might not work for xbmcbuntu?
Reply
#39
You run xbmcbuntu, why not check it?
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#40
No luck with the autostart directory. But here's something I've come up with that appears to work ok.
I changed /usr/share/xsessions/XBMC.desktop and changed the Exec and TryExec lines to call a new script that looks like the following:
Code:
#!/bin/bash

/usr/local/bin/squeezeslave.sh &
xbmc-standalone

squeezeslave.sh starts squeezeslave after a 30 second delay. I used the delay because on my first attempt it failed because it couldn't find the network at that time. That could have been a fluke, but the delay can't really hurt so I'm leaving it.
Reply
#41
Yeah that's what I meant by the script that starts xbmc, as opposed to /usr/bin/xbmc.[1]

However that script will probably also get overwritten by an update.

You could produce another xsession file of your own - call it xbmc-squeeze.desktop, or whatever you choose Smile

EDIT: [1] I just couldn't remember where the script was without access to an xbmcbuntu system
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#42
Alright, I went ahead and made a new user-session. In /etc/lightdm/lightdm.conf I set user-session=XBMC_squeeze. In /usr/share/xsessions I created XBMC_squeeze.desktop with the following:
Code:
[Desktop Entry]
Name=XBMC_Squeeze
Comment=This session will start XBMC Media Center
Exec=squeezeandxbmc
TryExec=squeezeandxbmc
Type=Application

And squeezeandxbmc is a script residing in /usr/bin

So using the asound.conf in the first post and dmix0 for both devices everything seems happy at the moment.
Reply
#43
Good work. This deserves a place in the wiki. Document your work and benefit others Smile
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#44
What exactly changed between Eden and Frodo? I also used to run a MPD server in the background (mopidy) with Eden and that worked fine, although I also used a system-wide pulseaudio but Im not actually sure why I did that any more.

With Eden, I could actually play external stuff at the same time that XBMC was playing sounds. Is this not possible any more, and if so, why? Is XBMC now using ALSA directly? (Which afaik prohibits sharing)

It does actually work as before, but only if I start mopidy first and start playing a song before I open XBMC, which is not a good solution unless I want to start auto-playing music on every boot Sad
Reply
#45
AudioEngine simplifies the interface for selecting audio hardware in XBMC. However with the release of Frodo once it grabbed the audio device it wouldn't release it. But since Frodo they have fixed that problem. Apparently there's going to be a 12.1 release soon, which should include this fix. Or you can switch to using a nightly build.
Reply

Logout Mark Read Team Forum Stats Members Help
Sharing audio with other apps when using AudioEngine0