[pulseaudio] Try to spawn Pulseaudio if it doesn't by itself

Requiring the user to set up Pulseaudio in system mode is not optimal. This
would, however, be required especially on headless systems. This is the
sledgehammer alternative to starting Pulseaudio.
This commit is contained in:
ejurgensen 2016-09-20 22:17:29 +02:00
parent 9355015b3c
commit f202b5d2e9

View File

@ -806,7 +806,26 @@ pulse_init(void)
if (pa_context_connect(p->context, NULL, 0, NULL) < 0)
{
ret = pa_context_errno(p->context);
goto fail;
if (ret == PA_ERR_CONNECTIONREFUSED)
{
DPRINTF(E_LOG, L_LAUDIO, "Connection to Pulseaudio refused, trying to start daemon for our user\n");
ret = system("pulseaudio --start");
if (ret < 0)
{
DPRINTF(E_LOG, L_LAUDIO, "Could not start Pulseaudio\n");
return -1;
}
}
// Try connecting again
if (pa_context_connect(p->context, NULL, 0, NULL) < 0)
{
ret = pa_context_errno(p->context);
goto fail;
}
DPRINTF(E_LOG, L_LAUDIO, "Connection to Pulseaudio established\n");
}
pa_threaded_mainloop_lock(p->mainloop);