From patchwork Mon Jul 15 21:08:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= X-Patchwork-Id: 1132309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gvZ2rAGw"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45nbmL2J0dz9sBt for ; Tue, 16 Jul 2019 07:10:58 +1000 (AEST) Received: from localhost ([::1]:43848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8FM-00014f-6A for incoming@patchwork.ozlabs.org; Mon, 15 Jul 2019 17:10:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42260) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hn8Cx-000895-Um for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hn8Cw-0004kp-PL for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:27 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:53614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hn8Cw-0004kT-Iu for qemu-devel@nongnu.org; Mon, 15 Jul 2019 17:08:26 -0400 Received: by mail-wm1-x341.google.com with SMTP id x15so16554789wmj.3 for ; Mon, 15 Jul 2019 14:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rslzC2c2WDwNlJOxHo//ed6lLff8LJfI6lnQMj5SLIg=; b=gvZ2rAGwGYll66L2uA/1QnS11iJaBCA1qJo2e6uYzKPGd9S4ILkJDKaP0pMCSioonI F1Hd7Z8eLaHJgQPLg4f5FRIkTfJS4nl4kw1QKFRDDs9rPDcibxJmnJJbfhMts0A/ZPhp gqZBAmzTWTtMCA42th908CWCsv/mPVk4/5cw0zOOWFVvun0Z02gYth/v+EL1VTFDJsOs RVFha5twiN8cbhvl6uk8SXhqu/DxgNyyJpeAwiXRd71LNlNjjbQVNbFkQKVjNcVEJJtV Bx7fh/Gw2Q2xSi99wwwe6pZq2v8/pFr+93ag/ZYU/b73WMywAAw5LfY7ArksrNy/xpN5 ImtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rslzC2c2WDwNlJOxHo//ed6lLff8LJfI6lnQMj5SLIg=; b=d4TSwLQd2QuDo/nGqHDqGmiO9t3GyrjZPjlV7zXpL7X+ERj9Na9kb4ploxYQ1OvT0Q oH+g+h3Dpy7eLyj+bVhQZQTzaENW2KRVL8KndJBxfBQ+IovjcpMGRUvoLCEMVFB7zMDn GOvWITUaDYk/CjnTIONqZmtHKUjVQk3Frdowzv1UInrYSgtc8J5J7OZTS/YaLUn+6BtZ 4SE+dL5EIduFLd4MAUw5o+1OySFvzRPQ0V5Ne4TkPQRP7Phe4Ec4U/Ogv4Mj3heyZov9 ug8KqBX+B/1chr9gx5vvdFI1VZx+9qTzDdTVnkUN8OoD4INl4FSseAEZ37q0CVBjiL+f a41w== X-Gm-Message-State: APjAAAVwRD9CPik539crVzdLqraF+guZ8QhY6frgBFGOqKdqEUv/BOVp Tvd3ODyfS+d3bcm6oJPUHAcNGH9g X-Google-Smtp-Source: APXvYqyOJUlXNNtbK2wCK55UL6/Stg6cgrvIWf9da4mbsh/Ed0s2mNhLODx5DIW8lrwhiJCzrIUvnA== X-Received: by 2002:a1c:f61a:: with SMTP id w26mr27552781wmc.75.1563224905483; Mon, 15 Jul 2019 14:08:25 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-31ca-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:31ca::5]) by smtp.gmail.com with ESMTPSA id n8sm11513447wro.89.2019.07.15.14.08.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 14:08:25 -0700 (PDT) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?utf-8?b?S8WRdsOhZ8OzLCBab2x0w6Fu?= To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2019 23:08:10 +0200 Message-Id: X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v2 08/14] paaudio: properly disconnect streams in fini_* X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Currently this needs a workaround due to bug #247 in pulseaudio. Signed-off-by: Kővágó, Zoltán Reviewed-by: Marc-André Lureau --- audio/paaudio.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 24d98b344a..1d68173636 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -685,6 +685,27 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) return -1; } +static void qpa_simple_disconnect(PAConnection *c, pa_stream *stream) +{ + int err; + + pa_threaded_mainloop_lock(c->mainloop); + /* + * wait until actually connects. workaround pa bug #247 + * https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/247 + */ + while (pa_stream_get_state(stream) == PA_STREAM_CREATING) { + pa_threaded_mainloop_wait(c->mainloop); + } + + err = pa_stream_disconnect(stream); + if (err != 0) { + dolog("Failed to disconnect! err=%d\n", err); + } + pa_stream_unref(stream); + pa_threaded_mainloop_unlock(c->mainloop); +} + static void qpa_fini_out (HWVoiceOut *hw) { void *ret; @@ -696,7 +717,7 @@ static void qpa_fini_out (HWVoiceOut *hw) audio_pt_join(&pa->pt, &ret, __func__); if (pa->stream) { - pa_stream_unref (pa->stream); + qpa_simple_disconnect(pa->g->conn, pa->stream); pa->stream = NULL; } @@ -716,7 +737,7 @@ static void qpa_fini_in (HWVoiceIn *hw) audio_pt_join(&pa->pt, &ret, __func__); if (pa->stream) { - pa_stream_unref (pa->stream); + qpa_simple_disconnect(pa->g->conn, pa->stream); pa->stream = NULL; }