Solved Sharing audio with other apps when using AudioEngine
#1
*Possibly solved* See post 39 for information on auto starting. This appears to be working now with the Feb. 10 nightly build. I use the asound.conf file in this post and device dmix0 for both squeezeslave and xbmc.

I'm trying to run squeezeslave in the background when using XBMC and sending audio through my optical output. Unfortunately if I start XBMC first, the digital output is not available to squeezeslave, it just doesn't even show up in it's available output device list. Likewise if I squeezeslave first, XBMC can't see the digital audio output.

I used the info from this thread to create an asound.conf file, and while dmix0 became an available device, the behavior is identical, if either one of the apps is using it, then it is completely unavailable to the other, by that I mean it doesn't appear in the list of available devices.

Here's the relevant output from aplay and squeezeslave -L. This output was generated by starting squeezeslave first, so it works, but XBMC now has no audio.

Code:
keith@xbmc:~$ squeezeslave -L
Output devices:
  0: (ALSA) HDA Intel PCH: ALC892 Analog (hw:0,0) (11/46)
  1: (ALSA) HDA Intel PCH: ALC892 Digital (hw:0,1) (11/46)
  3: (ALSA) HDA Intel PCH: HDMI 0 (hw:0,3) (11/46)
  4: (ALSA) HDA Intel PCH: HDMI 1 (hw:0,7) (11/46)
  5: (ALSA) sysdefault (42/46)
  6: (ALSA) front (11/46)
  7: (ALSA) surround40 (11/46)
  8: (ALSA) surround41 (11/46)
  9: (ALSA) surround50 (11/46)
10: (ALSA) surround51 (11/46)
11: (ALSA) surround71 (11/46)
12: (ALSA) iec958 (11/46)
13: (ALSA) spdif (11/46)
14: (ALSA) hdmi (11/46)
15: (ALSA) dsp0 (170/46)
16: (ALSA) dmix0 (170/170)
17: (ALSA) dmix (42/42)
*18: (ALSA) default (170/46)
keith@xbmc:~$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
default
dsp0
dmix0
sysdefault:CARD=PCH
    HDA Intel PCH, ALC892 Analog
    Default Audio Device
front:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    Front speakers
surround40:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Digital
    IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=PCH,DEV=0
    HDA Intel PCH, HDMI 0
    HDMI Audio Output
hdmi:CARD=PCH,DEV=1
    HDA Intel PCH, HDMI 1
    HDMI Audio Output
hdmi:CARD=PCH,DEV=2
    HDA Intel PCH, HDMI 2
    HDMI Audio Output
dmix:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    Direct sample mixing device
dmix:CARD=PCH,DEV=1
    HDA Intel PCH, ALC892 Digital
    Direct sample mixing device
dmix:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct sample mixing device
dmix:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Direct sample mixing device
dmix:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Direct sample mixing device
dsnoop:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    Direct sample snooping device
dsnoop:CARD=PCH,DEV=1
    HDA Intel PCH, ALC892 Digital
    Direct sample snooping device
dsnoop:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct sample snooping device
dsnoop:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Direct sample snooping device
dsnoop:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Direct sample snooping device
hw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=1
    HDA Intel PCH, ALC892 Digital
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Direct hardware device without any conversions
hw:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0
    HDA Intel PCH, ALC892 Analog
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=1
    HDA Intel PCH, ALC892 Digital
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=3
    HDA Intel PCH, HDMI 0
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=7
    HDA Intel PCH, HDMI 1
    Hardware device with all software conversions
plughw:CARD=PCH,DEV=8
    HDA Intel PCH, HDMI 2
    Hardware device with all software conversions
keith@xbmc:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

If XBMC is run first and using the digital output then squeezeslave -L doesn't show the lines beginning with 1, 12, 13, 15, and 16.

And my /etc/asound.conf file:
Code:
pcm.!default            { type                  plug;
                          slave.pcm             "dmix0"; }
ctl.!default            { type hw; card 0; device 1; }

pcm.dsp0                { type                  plug;
                          slave.pcm             "dmix0"; }
ctl.dsp0                { type hw; card 0; device 1; }
ctl.mixer0              { type hw; card 0; device 1; }

pcm.dmix0               { type                  dmix;
                          ipc_key               13759;

                          slave.pcm             "hw:0,1";
                          slave.channels        2;

                          slave.rate            44100;
#                          slave.period_size     4096;
#                          slave.buffer_size     16384;


                          slave.period_time     84000;
                          slave.buffer_time     340000;

                          # Map only the first two channels
                          bindings.0            0;
                          bindings.1            1; }
Reply
#2
What you might be able to do is create two dmix devices that both output to the optical output. Then configure XBMC for one of them and Squeezeslave for the other one. I've never tried it, but I think it would work.
Reply
#3
Known problem in Frodo RC3 - although you don't say what you are using.
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
#4
I'm using RC3. Is this the final thing they are working out for release?
Reply
#5
One of them, but I understand this is a show stopper. At least I think it is this ...
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
#6
please try a nightly, it should be fixed there.
Reply
#7
(2013-01-21, 09:42)wsnipex Wrote: please try a nightly, it should be fixed there.

I'll see about getting that machine set up to do a build, right now it's just running a basic xbmcbuntu install.
Reply
#8
no need to compile, just add the nightly ppa, see my sig
Reply
#9
Thanks wnsipex. I have added the ppa and installed the nightly. I'm at work at the moment, but logged in remotely and after installing the nightly and making sure squeezeslave wasn't set to autostart, I rebooted. But xbmc won't start, I guess because the display isn't on and I'm using HDMI for video. I'll have to wait until I get home to see if it works.
Reply
#10
Well upon starting it up with no asound.conf file and xbmc running, squeezeslave was able to get the audio device and play. However then I checked the xbmc settings and it had the wrong device selected. So I selected the digital output, and played a few videos, and then squeezeslave couldn't run. I put the asound.conf file back, selected dmix0 in xbmc, and it works, however I keep getting that Invalid sample rate error in squeezeslave when I try to use dmix0, with or without the rate lines in asound.conf. So now I've taken a step backwards. Also, squeezeslave can't see the digital output, only the ones defined in asound.conf.
Reply
#11
well, two programs cannot access the same audio device directly at the same time. Xbmc must suspend audio first, then your other prog can access it. In Xbmc audio should be suspended after 10 secs of inactivity or when an external player is called.
Reply
#12
Much of that functionality has been gutted for Linux due to issues with ALSA suspending. Forced suspend should still work (when launching an external player) but the idle suspend after 10 sec is Windows-only for now.
System: XBMC HTPC with HDMI WASAPI & AudioEngine - Denon  AVR-3808CI  - Denon DVD-5900 Universal Player  - Denon DCM-27 CD-Changer
- Sony BDP-S580 Blu-Ray  - X-Box 360  - Android tablet wireless remote - 7.1 Streem/Axiom/Velodyne Surround System
If I have been able to help feel free to add to my reputation +/- below - thanks!
Reply
#13
(2013-01-22, 10:36)wsnipex Wrote: well, two programs cannot access the same audio device directly at the same time. Xbmc must suspend audio first, then your other prog can access it. In Xbmc audio should be suspended after 10 secs of inactivity or when an external player is called.

Well this used to work under Eden, granted I was doing that with different hardware. Still I'm guessing this means no more running game emulators out of XBMC on linux. I certainly hope some sort of solution is found, as that was something else I was hoping to do some day.
Reply
#14
there is a new PR up that at least allows for releasing audio for external players, lets see if it works out.
Reply
#15
Would my suggestion earlier of making two dmix devices for the optical output and pointing XBMC at one and one for the other not work? Today using Eden this is similiar to what I do run MPD and XBMC on the same box though I have it setup to output to multiple outputs. When I first set it up, I had problems where MPD would get a "device busy" erorr and I fixed it by adding a dmix plugin into the device chain in .asoundrc for each device.
Reply

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