Bug 82447

Summary: Custom xbmc.service starts x-session and xbmc before pulseaudio is fully initialized
Product: systemd Reporter: John <da_audiophile>
Component: generalAssignee: systemd-bugs
Status: RESOLVED NOTABUG QA Contact: systemd-bugs
Severity: normal    
Priority: medium CC: da_audiophile
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: proposed xbmc.service

Description John 2014-08-11 05:56:45 UTC
Created attachment 104408 [details]
proposed xbmc.service

Overview: Using the attached service file on an Arch Linux system running pulseaudio, the xsession starts, but xbmc is started before pulseaudio is fully initialized which causes it to miss seeing all audio devices.  I do not believe that the 'After = systemd-user-sessions.service network.target sound.target' line is adequate and am soliciting some feedback from the gurus :)

As a proof of concept, I modified /usr/bin/xbmc-standalone (which is simply a wrapper script) by adding a `sleep 6s` line before it calls the executable.  This is a dirty hack and not broadly applicable to all systems.

Steps to reproduce: 
1) Install Arch Linux with pulseaudio and xbmc.

2) Pull down the AUR package "xbmc-standalone-service" which provides this xbmc.service as well as creates the needed user/groups[1].

3) Start xbmc.service and attempt to change audio sources.

1. https://aur.archlinux.org/packages/xbmc-standalone-service

Actual result: None of the audio sources (system>system>audioAudio output device) are available; the option is simply grayed out.

Expected result: All available outputs should be present and selectiable by the user, eg, [HDMI,Analog,Digital,Optical].

Build date and platform: Verified on two different Arch Linux x86_64 machines.  Both running systemd 215-4.
Comment 1 Zbigniew Jedrzejewski-Szmek 2014-12-17 01:08:06 UTC
There's actually no expectation that systemd-user-sessions.service network.target sound.target are in any way related to all devices being found and initialized. sound.target is closest, but it does not say anything about all devices being initialized, it's just automatically pulled in when at least one device was found (see systemd.special(7)). It is useless for your purpose.

Pulseaudio is prepared for devices to come and go. So pulseaudio being initialized only means that it is ready to accept connections, not that specific hardware is ready. (For example, I have a USB sound card. Sometimes it falls out when I pull on the cable. There's no point in time that devices are initialized. As soon as I plug it back in, pulseaudio let's me use it again.)

So if you know that there's a specific list of devices that xmbc should wait for, you can add specific dependencies on those devices, using systemd dependencies, or use pulseaudio-specific mechanism to enumerate cards or something. But this is a purely local configuration thing. We can't really help with that.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.