From patchwork Thu Dec 19 20:07:46 2019 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: 11304349 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4872814E3 for ; Thu, 19 Dec 2019 20:08:33 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 27DA92465E for ; Thu, 19 Dec 2019 20:08:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27DA92465E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ii263-00058P-As for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Dec 2019 15:08:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37739) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ii25T-0004Zn-Ab for qemu-devel@nongnu.org; Thu, 19 Dec 2019 15:07:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ii25S-0000bV-7E for qemu-devel@nongnu.org; Thu, 19 Dec 2019 15:07:55 -0500 Received: from mailout03.t-online.de ([194.25.134.81]:54232) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ii25R-0000UY-UR for qemu-devel@nongnu.org; Thu, 19 Dec 2019 15:07:54 -0500 Received: from fwd13.aul.t-online.de (fwd13.aul.t-online.de [172.20.27.62]) by mailout03.t-online.de (Postfix) with SMTP id 5020342A320C; Thu, 19 Dec 2019 21:07:52 +0100 (CET) Received: from [192.168.211.200] (GD7AcuZrZhKODslQh75k-GKlCninl-DFx7aufMgAhtrGOegIiy71jnGYJEUxQ+Hwu3@[46.86.55.2]) by fwd13.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1ii25K-1F4MrY0; Thu, 19 Dec 2019 21:07:46 +0100 Subject: [PATCH 5/5] paaudio: wait until the recording stream is ready From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann References: Message-ID: Date: Thu, 19 Dec 2019 21:07:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: Content-Language: de-DE X-ID: GD7AcuZrZhKODslQh75k-GKlCninl-DFx7aufMgAhtrGOegIiy71jnGYJEUxQ+Hwu3 X-TOI-MSGID: 09e120e7-5a6c-4bea-960f-31fe89364f37 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.81 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+patchwork-qemu-devel=patchwork.kernel.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 03cf10bb3c..bb4150bc34 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;