~michael-sheldon/ubuntu-touch-session/fix-1659388

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
description "Pulseaudio"
author "Ricardo Mendoza <ricmm@ubuntu.com>"

start on started dbus
stop on session-end

respawn
expect daemon

pre-start script
    # Use the Touch specific Pulseaudio script file
    if [ -z "$PULSE_SCRIPT" ]; then
        initctl set-env --global PULSE_SCRIPT=/etc/pulse/touch.pa
    fi
    if [ -z "$PULSE_CLIENTCONFIG" ]; then
        initctl set-env --global PULSE_CLIENTCONFIG=/etc/pulse/touch-client.conf
    fi

    # Force a default audio role (apps can overwrite this)
    initctl set-env --global PULSE_PROP='media.role=multimedia'

    # Force server-side corking when stalled (playback)
    initctl set-env --global PULSE_PLAYBACK_CORK_STALLED=1

    # Pulseaudio enforces this variable internally, but tries to re-exec itself
    # when enabling it and has difficulty finding its own binary, if in a snap.
    # So let's set it for the daemon, so it won't have to.
    initctl set-env LD_BIND_NOW=1
end script

exec pulseaudio --start --log-target=syslog

# Upstart tracks fork() calls, but what Pulse does is fork early
# and then block on a write to a socket. So Upstart thinks that
# it has started while Pulse is still initializing. This stops
# the started event from happening until the dbus-socket is ready
# for people to connect to it.
post-start script
	while true; do
		[ -S /run/user/`id -u`/pulse/dbus-socket ] && break
		sleep 0.1
	done
end script