Solved Sharing audio with other apps when using AudioEngine
#16
tknorris, would I just duplicate everything in asound.conf and replace dmix0 with dmix1 or is there a simpler way to make multiple devices in there?
Reply
#17
I think you wouldn't need to duplicate everything. I think you could do something like what I have below. Configure XBMC for digital_dmix1 and configure squeezeslave for digital_dmix2. Note, I'm definitely not an ALSA expert and I'm not even running Frodo yet so there may be something here I'm not aware of that would make this not work.

Also, you may be able to mess w/ the ipc_key to set them to the same value for both pcm's. I know that would mean they share the same shared memory space, but I'm not sure what effect that would have.

What I have today is far more complicated that this because I want to output to all my outputs (HDMI, analog and digital) at the same time AND allow XBMC and MPD to output to all those outputs. So, my .asoundrc is configured with slave outputs and dmix together. It works perfectly (except for a small sample rate issue I cant resolve).

Code:
pcm.digital_hw {
  type hw
  card 0
  device 1
  channels 2
}


pcm.digital_dmix1 {
  type dmix
  ipc_key 1024
  slave {
    pcm "digital_hw"
    rate 48000
  }
}

pcm.digital_dmix2 {
  type dmix
  ipc_key 1025
  slave {
    pcm "digital_hw"
    rate 48000
  }
}
}
Reply
#18
Thanks, I'll give that a try when I get home.
Reply
#19
Well tknorris I tried yours, adjusting it to my system, and I have the same problem. I set up dmix0 and dmix1, both are available to xbmc, as well as the standard digital out. I tried dmix0 and dmix1 in xbmc and both work, but squeezeslave only sees the dmix device being used by xbmc, and can't see the other one at all, nor does it see the digital input, and selecting the dmix device just results in the same "Invalid sample rate" error that I've been seeing. So that strategy doesn't appear effective for my setup.

And I've updated to the latest nightly, so I guess the PR hasn't been pulled yet.
Reply
#20
a new nightly with the lastest patch is available
Reply
#21
I updated and I still don't see the digital output as an available device in squeezeslave when XBMC is running.
Reply
#22
As per the code only forced audio suspend by using external player will free the device. I guess squeezeslave is not configured as external player? Note: I did not test this myself.
Reply
#23
Not really, I want squeezeslave running in the background able to use the audio whenever xbmc isn't playing anything. That's the way I did it with Eden. On a startup I have an init script that gets squeezeslave running. So as it is now, squeezeslave gets running before xbmc is initialized, it grabs the digital output and xbmc won't see it.
Reply
#24
yeah, I'm afraid that probably does not work with current state of things on linux, as there is no auto audio suspend on idle. I know it used to work on Eden, but audio code has changed a real lot since then.
Reply
#25
wsnipex, what do you mean when you say "configured as an external player"? I'm really worried from what you've said that upgrading the Frodo is going to break my situation as well of MPD and XBMC playing on the same machine. As I mentioned earlier, the attached .asoundrc currently allows it to work (and to output to all my audio devices at the same time). Will Frodo break my solution?

Code:
pcm.!default {
  type plug
  slave {
    pcm "both"
  }
}

pcm.both {
  type route
  slave {
    pcm multi
    channels 6
  }
  ttable.0.0 1.0
  ttable.1.1 1.0
  ttable.0.2 1.0
  ttable.1.3 1.0
  ttable.0.4 0.5
  ttable.1.4 0.5
  ttable.0.5 0.5
  ttable.1.5 0.5
}

pcm.multi {
  type multi
  slaves.a {
    pcm "hdmi_dmix"
    channels 2
  }
  slaves.b {
    pcm "digital_dmix"
    channels 2
  }
  slaves.c {
    pcm "analog_dmix"
    channels 2
  }
  bindings.0.slave a
  bindings.0.channel 0
  bindings.1.slave a
  bindings.1.channel 1
  bindings.2.slave b
  bindings.2.channel 0
  bindings.3.slave b
  bindings.3.channel 1
  bindings.4.slave c
  bindings.4.channel 0
  bindings.5.slave c
  bindings.5.channel 1
}

pcm.hdmi_hw {
  type hw
  card 0
  device 3
  channels 2
}

pcm.digital_hw {
  type hw
  card 0
  device 1
  channels 2
}

pcm.analog_hw {
  type hw
  card 0
  device 0
  channels 2
}

pcm.hdmi_dmix {
  type dmix
  ipc_key 1024
  slave {
    pcm "hdmi_hw"
    rate 48000
  }
}

pcm.digital_dmix {
  type dmix
  ipc_key 1025
  slave {
    pcm "digital_hw"
    rate 48000
  }
}

pcm.analog_dmix {
  type dmix
  ipc_key 1026
  slave {
    pcm "analog_hw"
    rate 48000
  }
}
Reply
#26
Rhis is reported to have some success in frodo.

http://forum.xbmc.org/showthread.php?tid=145430

idk how it is though as never tried.

uNi
Reply
#27
I updated to the most recent nightly build and it's working! I don't use an asound.conf file, and I use dmix on squeezeslave and it's doing exactly what I want. Wonderful.

On another machine I'd been doing builds myself, and after the kerfuffle the other night where a bunch of header files were moved I waited a couple days and then there were numerous changes and I noticed it was now XBMC 13 Alpha. On that machine I noticed that squeezeslave was showing available devices that matched what XBMC was using, I think this was Friday or Saturday night (Feb. 8th or 9th). I finally tried it on the machine that just has digital out and where I need both apps running, and after removing asound.conf it worked just fine.

Now I just need to get squeezeslave to start up automatically and all will be well. WoL would be nice too if I can get that figured out.
Reply
#28
Quote:Now I just need to get squeezeslave to start up automatically and all will be well. WoL would be nice too if I can get that figured out.
Depends a bit on your system, but generally putting a .desktop file in ~/.config/autostart should work to get something started on user login.

If you are using xbmcbuntu though I think things are handled a bit differently. Basically xbmc is I think the only thing started on auto login, so you may need to hack the script that starts xbmc.
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
#29
(2013-02-12, 05:15)nickr Wrote:
Quote:Now I just need to get squeezeslave to start up automatically and all will be well. WoL would be nice too if I can get that figured out.
Depends a bit on your system, but generally putting a .desktop file in ~/.config/autostart should work to get something started on user login.

If you are using xbmcbuntu though I think things are handled a bit differently. Basically xbmc is I think the only thing started on auto login, so you may need to hack the script that starts xbmc.

I have that somewhat working with a script in /etc/init

Alas, it appears I was sorely mistaken that this was working. It looks like when I thought it was working that it was perhaps routing the audio out of the TV via HDMI, rather than going to my soundbar. I'm not sure, I swear the volume on the soundbar was working, as was the sub. But at the moment I cannot get this to work again.
Reply
#30
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.

I'm having to use the asound.conf I referenced in my first post, but to get it not to crash I changed rate to 44100. Must be something with my card.

After further testing I believe it has something to do with running it as a service via the /etc/init script. If I stop the service XBMC works, if I start the service back up, XBMC audio is gone again. If I stop the service, then start squeezeslave via the command line, everything seems to work together.

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.
Reply

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