From 5d30ccfaff8bcff0e985c0b448cac6f57c5c7ca6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 7 Jun 2018 10:18:33 +0200 Subject: [PATCH] alsa: avoid crash when connection fails Set the client api in properties --- alsa-plugins/pcm_pipewire.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/alsa-plugins/pcm_pipewire.c b/alsa-plugins/pcm_pipewire.c index fed3f3e07..3985aae51 100644 --- a/alsa-plugins/pcm_pipewire.c +++ b/alsa-plugins/pcm_pipewire.c @@ -370,7 +370,7 @@ static int snd_pcm_pipewire_prepare(snd_pcm_ioplug_t *io) pw->stream = NULL; } - props = pw_properties_new(NULL, NULL); + props = pw_properties_new("client.api", "alsa", NULL); pw_properties_setf(props, "node.latency", "%lu", io->period_size); pw->stream = pw_stream_new(pw->remote, pw->node_name, props); @@ -583,7 +583,8 @@ static void on_remote_state_changed(void *data, enum pw_remote_state old, pw_log_error("error %s", error); case PW_REMOTE_STATE_UNCONNECTED: pw->error = true; - pcm_poll_unblock_check(&pw->io); + if (pw->fd != -1) + pcm_poll_unblock_check(&pw->io); /* fallthrough */ case PW_REMOTE_STATE_CONNECTED: pw_thread_loop_signal(pw->main_loop, false);