From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:54560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmewB-0006Ed-BJ for qemu-devel@nongnu.org; Thu, 24 Jan 2019 08:20:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gmew5-0007YL-65 for qemu-devel@nongnu.org; Thu, 24 Jan 2019 08:20:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59848) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gmew1-0007Nu-6s for qemu-devel@nongnu.org; Thu, 24 Jan 2019 08:20:47 -0500 From: Gerd Hoffmann Date: Thu, 24 Jan 2019 14:20:18 +0100 Message-Id: <20190124132020.13571-6-kraxel@redhat.com> In-Reply-To: <20190124132020.13571-1-kraxel@redhat.com> References: <20190124132020.13571-1-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 5/7] audio: check for pulseaudio daemon pidfile List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Brad Smith , Gerd Hoffmann Check whenever the pulseaudio daemon pidfile is present before trying to initialize the pulseaudio backend. Just return NULL if that is not the case, so qemu will check the next backend in line. In case the user explicitly configured a non-default pulseaudio server skip the check. Signed-off-by: Gerd Hoffmann Message-id: 20190124112055.547-5-kraxel@redhat.com --- audio/paaudio.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/audio/paaudio.c b/audio/paaudio.c index 4c100bc318..6153b908da 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -814,6 +814,21 @@ static PAConf glob_conf = { static void *qpa_audio_init (void) { + if (glob_conf.server == NULL) { + char pidfile[64]; + char *runtime; + struct stat st; + + runtime = getenv("XDG_RUNTIME_DIR"); + if (!runtime) { + return NULL; + } + snprintf(pidfile, sizeof(pidfile), "%s/pulse/pid", runtime); + if (stat(pidfile, &st) != 0) { + return NULL; + } + } + paaudio *g = g_malloc(sizeof(paaudio)); g->conf = glob_conf; g->mainloop = NULL; -- 2.9.3