From patchwork Sat Jan 4 09:11:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 1217519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=none (p=none dis=none) header.from=t-online.de 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 47qbdM6jylz9sR4 for ; Sat, 4 Jan 2020 20:12:23 +1100 (AEDT) Received: from localhost ([::1]:60824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1infTp-0001uR-KL for incoming@patchwork.ozlabs.org; Sat, 04 Jan 2020 04:12:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34368) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1infTC-0001qR-5o for qemu-devel@nongnu.org; Sat, 04 Jan 2020 04:11:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1infTA-0007TL-R2 for qemu-devel@nongnu.org; Sat, 04 Jan 2020 04:11:42 -0500 Received: from mailout12.t-online.de ([194.25.134.22]:33140) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1infTA-0007NT-Jc for qemu-devel@nongnu.org; Sat, 04 Jan 2020 04:11:40 -0500 Received: from fwd21.aul.t-online.de (fwd21.aul.t-online.de [172.20.27.66]) by mailout12.t-online.de (Postfix) with SMTP id 30B6A41E652F; Sat, 4 Jan 2020 10:11:39 +0100 (CET) Received: from linpower.localnet (EZWeFBZfghF69dEMnIqJRorvOHbAgVQGZh4eOH2FBL4NRM7JDnFHVw+xIron87bgSS@[46.86.52.107]) by fwd21.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1infT2-0fp5CC0; Sat, 4 Jan 2020 10:11:32 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 2723E202791; Sat, 4 Jan 2020 10:11:22 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH v2 5/5] paaudio: wait until the recording stream is ready Date: Sat, 4 Jan 2020 10:11:22 +0100 Message-Id: <20200104091122.13971-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <07d61da6-51fb-8599-ea27-dae828fbdb3c@t-online.de> References: <07d61da6-51fb-8599-ea27-dae828fbdb3c@t-online.de> MIME-Version: 1.0 X-ID: EZWeFBZfghF69dEMnIqJRorvOHbAgVQGZh4eOH2FBL4NRM7JDnFHVw+xIron87bgSS X-TOI-MSGID: adab2745-9ac0-43f4-9e76-d06ad377268a X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.22 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: QEMU , =?utf-8?b?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Don't call pa_stream_peek before the recording stream is ready. Information to reproduce the problem. Start and stop Audacity in the guest several times because the problem is racy. libvirt log file: -audiodev pa,id=audio0,server=localhost,out.latency=30000, out.mixing-engine=off,in.mixing-engine=off \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny, resourcecontrol=deny \ -msg timestamp=on : Domain id=4 is tainted: custom-argv char device redirected to /dev/pts/1 (label charserial0) audio: Device pcspk: audiodev default parameter is deprecated, please specify audiodev=audio0 audio: Device hda: audiodev default parameter is deprecated, please specify audiodev=audio0 pulseaudio: pa_stream_peek failed pulseaudio: Reason: Bad state pulseaudio: pa_stream_peek failed pulseaudio: Reason: Bad state Signed-off-by: Volker RĂ¼melin --- audio/paaudio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/audio/paaudio.c b/audio/paaudio.c index b23274550e..dbfe48c03a 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -162,6 +162,10 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, size_t length) CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, "pa_threaded_mainloop_lock failed\n"); + if (pa_stream_get_state(p->stream) != PA_STREAM_READY) { + /* wait for stream to become ready */ + goto unlock; + } while (total < length) { size_t l; @@ -191,6 +195,7 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, size_t length) } } +unlock: pa_threaded_mainloop_unlock(c->mainloop); return total;