From nobody Fri May 3 10:49:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578315270; cv=none; d=zohomail.com; s=zohoarc; b=d1x+vA+ZlTpc/kHL3jHyK4YMWS9SsDHr4omKyOsdSRxEv7+kMVuawK5/uF6Rm74xCNSERWmE/18jjeB4AA4n1/cqORtlY97k3dje9X9sNhn4ACGbNhzeLugSFWE9t0R6tYfzFxigsqFbOeSmu7exAFDMgYhOLQUWyhSaopYczdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578315270; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lXOGosYvPW6jgvcFaLnN32Way/3Noo2iJQc1+mSjxOc=; b=nnaGU8lcty2bCUsXFVqCWf9pOB6xBSAeA7VjnP5zhAoSQx0T6iNuAqNUwazhFhZUD/msIyHVq8P5G7F2+hhndBI5NX72T3U0vjTOOfZKlUMOiOtfRuEwXU/ZrHCeYNZFowIKkh2Zyz0FUWlEosLhjkA1SFivQRiWiLfWZukgdu4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578315270819927.9472811876096; Mon, 6 Jan 2020 04:54:30 -0800 (PST) Received: from localhost ([::1]:51452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRtt-0002bB-1x for importer@patchew.org; Mon, 06 Jan 2020 07:54:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58296) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRsE-0000rS-V7 for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioRsD-0000rc-Sn for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:39298 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ioRsD-0000rP-Oa for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-278-3elVJeAVMmeD-CBR-P-_fw-1; Mon, 06 Jan 2020 07:52:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D3F7800D48; Mon, 6 Jan 2020 12:52:40 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87A3484FE2; Mon, 6 Jan 2020 12:52:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 8ED756DF9; Mon, 6 Jan 2020 13:52:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578315165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lXOGosYvPW6jgvcFaLnN32Way/3Noo2iJQc1+mSjxOc=; b=efqBmje0qIRrrqG1Cqw2IVAZiRtfT/wqKUD0k/BUDIYzQmJ3+2CWBZeQOioYPEyKq6brWZ 58tDChagf73bd60uV40/6sxVfLonFHlBIzQMAZc4lnVpdiYt7LUs758Fm5ebjkpKJDbqRX sVN9qXayKglHgoEWYmE2hpM21wnH1KQ= From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 1/6] hda-codec: fix playback rate control Date: Mon, 6 Jan 2020 13:52:31 +0100 Message-Id: <20200106125236.24132-2-kraxel@redhat.com> In-Reply-To: <20200106125236.24132-1-kraxel@redhat.com> References: <20200106125236.24132-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 3elVJeAVMmeD-CBR-P-_fw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 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?Volker=20R=C3=BCmelin?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Volker R=C3=BCmelin Since commit 1930616b98 "audio: make mixeng optional" the function hda_audio_output_cb can no longer assume the function parameter avail contains the free buffer size. With the playback mixing-engine turned off this leads to a broken playback rate control and playback buffer drops in regular intervals. This patch moves down the rate calculation, so the correct buffer fill level is used for the calculation. Signed-off-by: Volker R=C3=BCmelin Message-id: 20200104091122.13971-1-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann --- hw/audio/hda-codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index f17e8d8dcea2..768ba31e7926 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -338,8 +338,6 @@ static void hda_audio_output_cb(void *opaque, int avail) return; } =20 - hda_timer_sync_adjust(st, (wpos - rpos) - to_transfer - (B_SIZE >> 1)); - while (to_transfer) { uint32_t start =3D (uint32_t) (rpos & B_MASK); uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); @@ -351,6 +349,8 @@ static void hda_audio_output_cb(void *opaque, int avail) break; } } + + hda_timer_sync_adjust(st, (wpos - rpos) - (B_SIZE >> 1)); } =20 static void hda_audio_compat_input_cb(void *opaque, int avail) --=20 2.18.1 From nobody Fri May 3 10:49:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578315261; cv=none; d=zohomail.com; s=zohoarc; b=d8dm/TxGFUCvWqxO2moSlDVdNm5qlo+Hybvxpqunr8X/7AuMbKhzjn7LrWKzeXDb7IuA9oLRLkx5H8Kp9cQLYS43bVg6q7ffCVmPrAEsMEuLkA+K3dSvIpVFRNjb2hO0eB1eDbvakyGF/cgxUH7nK9Hf+zkF1c1Yzp/unDQiSO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578315261; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Kh8HpDlNt551/dDZefIn5BOFL1sqd2pyx1rSXguRPeY=; b=ngnki8lheiNFr3TNeuAxBI6J9oAlWxN4mqS40k8rf9DS4jh2VuQyJzLYSZ2AZ8fPgV/maz06hree8R6G1SF/eM6A13BAKH0U0ZZzAu08+YnhfxBqs0d5vkzfGAdkJ4Do0n3SNLX23FgZi5vGfAvfI7MHDbHQQ3R7UX2/dG12UvA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578315261501490.952524270387; Mon, 6 Jan 2020 04:54:21 -0800 (PST) Received: from localhost ([::1]:51446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRtj-0002Oe-EC for importer@patchew.org; Mon, 06 Jan 2020 07:54:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58251) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRsC-0000qE-L7 for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioRsB-0000ob-Kc for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:44 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:47685 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ioRsB-0000mx-Gw for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:43 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-khPHw9KBPKuEW0nqtghzTQ-1; Mon, 06 Jan 2020 07:52:41 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B9EF801E76; Mon, 6 Jan 2020 12:52:40 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83F247FB4C; Mon, 6 Jan 2020 12:52:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 97BAF491B; Mon, 6 Jan 2020 13:52:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578315162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kh8HpDlNt551/dDZefIn5BOFL1sqd2pyx1rSXguRPeY=; b=BZmhujtTWps0REfD7KMelY3mSRupLRfVe2G288VBuqlNc+3+6deP/FBrjeT8+GLAa/xS8b 3qde0+R5G4Q/XUEiMdhOdkWLWOaEHJUND6IMBCJBoSA5SeUVWtaBKDQO59Wtg7uuRDwSiA DYb5LBEdzDBeiMoASdo+l8TMUKxAdng= From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 2/6] hda-codec: fix recording rate control Date: Mon, 6 Jan 2020 13:52:32 +0100 Message-Id: <20200106125236.24132-3-kraxel@redhat.com> In-Reply-To: <20200106125236.24132-1-kraxel@redhat.com> References: <20200106125236.24132-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: khPHw9KBPKuEW0nqtghzTQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.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: =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Volker R=C3=BCmelin Apply previous commit to hda_audio_input_cb for the same reasons. Signed-off-by: Volker R=C3=BCmelin Message-id: 20200104091122.13971-2-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann --- hw/audio/hda-codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 768ba31e7926..e711a99a414a 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -265,8 +265,6 @@ static void hda_audio_input_cb(void *opaque, int avail) =20 int64_t to_transfer =3D MIN(B_SIZE - (wpos - rpos), avail); =20 - hda_timer_sync_adjust(st, -((wpos - rpos) + to_transfer - (B_SIZE >> 1= ))); - while (to_transfer) { uint32_t start =3D (uint32_t) (wpos & B_MASK); uint32_t chunk =3D (uint32_t) MIN(B_SIZE - start, to_transfer); @@ -278,6 +276,8 @@ static void hda_audio_input_cb(void *opaque, int avail) break; } } + + hda_timer_sync_adjust(st, -((wpos - rpos) - (B_SIZE >> 1))); } =20 static void hda_audio_output_timer(void *opaque) --=20 2.18.1 From nobody Fri May 3 10:49:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578315395; cv=none; d=zohomail.com; s=zohoarc; b=m1u/6FQzE5qVBcWxqnKQrxOsOc+Db97r9Zp/d4C6O2RXH2+rAUlp7YDCJxATUdV3CYIQz5P5RAh6JQwH7RR+4ATNMbC9i1aZEWCyxUIV8P5450E+ykQWdKAs+uUFUfvqSvM+kpR+Gi7LvW756vZfTFxPflISymZWCtFVtRnsO5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578315395; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YtNgYh0UiNRf7SRbxWfm1Y/56HrjV3yGhYAdEcgxHeA=; b=ODTLz0Dh0jxzdkQy0+rKH/qnWe9oWzswyQTupBK91USH1bsy+yQNf6fOdpo6rR1DbgI8Dk/nuhRfWK6pw8U7L7mwqiNLwTeXGK8p5lwC9f0GPZPbVaMpLjaksXKu2Js1BmIIMqzp1RVpXIuywKXj74yXg9ejLPNQwKU6Fl/ZJCk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578315395734976.8763741099497; Mon, 6 Jan 2020 04:56:35 -0800 (PST) Received: from localhost ([::1]:51486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRvu-0006Az-9z for importer@patchew.org; Mon, 06 Jan 2020 07:56:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58335) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRsH-0000v2-3n for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioRsF-0000tT-HZ for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23921 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ioRsF-0000sq-DX for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:47 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-0g2Bz-1YMnydK69Km5suvg-1; Mon, 06 Jan 2020 07:52:41 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 805EB107ACC4; Mon, 6 Jan 2020 12:52:40 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8471460251; Mon, 6 Jan 2020 12:52:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A02C631E46; Mon, 6 Jan 2020 13:52:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578315166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YtNgYh0UiNRf7SRbxWfm1Y/56HrjV3yGhYAdEcgxHeA=; b=Z1F6QFJAhFkaClAfQVJHMV78a13IyA8c+KRk3H/Bj4OoD/L7FbI8oTYireQ0ZhqU4DWejX PyCIFOjO0PHeCZPPQ4P5pDihB93TvwTq2tNGH72k27qU6EH9Y5ZRicIbhkrluY+HZbxhfM JZV41j5rxVZIusNB3paM5K9tZJ/kv5Q= From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 3/6] paaudio: drop recording stream in qpa_fini_in Date: Mon, 6 Jan 2020 13:52:33 +0100 Message-Id: <20200106125236.24132-4-kraxel@redhat.com> In-Reply-To: <20200106125236.24132-1-kraxel@redhat.com> References: <20200106125236.24132-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: 0g2Bz-1YMnydK69Km5suvg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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?Volker=20R=C3=BCmelin?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Volker R=C3=BCmelin Every call to pa_stream_peek which returns a data length > 0 should have a corresponding pa_stream_drop. A call to qpa_read does not necessarily call pa_stream_drop immediately after a call to pa_stream_peek. Test in qpa_fini_in if a last pa_stream_drop is needed. This prevents following messages in the libvirt log file after a recording stream gets closed and a new one opened. pulseaudio: pa_stream_drop failed pulseaudio: Reason: Bad state pulseaudio: pa_stream_drop failed pulseaudio: Reason: Bad state To reproduce start qemu with -audiodev pa,id=3Daudio0,in.mixing-engine=3Doff and in the guest start and stop Audacity several times. Signed-off-by: Volker R=C3=BCmelin Message-id: 20200104091122.13971-3-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 55a91f898073..7db1dc15f09e 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -536,7 +536,6 @@ static void qpa_simple_disconnect(PAConnection *c, pa_s= tream *stream) { int err; =20 - pa_threaded_mainloop_lock(c->mainloop); /* * wait until actually connects. workaround pa bug #247 * https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/247 @@ -550,7 +549,6 @@ static void qpa_simple_disconnect(PAConnection *c, pa_s= tream *stream) dolog("Failed to disconnect! err=3D%d\n", err); } pa_stream_unref(stream); - pa_threaded_mainloop_unlock(c->mainloop); } =20 static void qpa_fini_out (HWVoiceOut *hw) @@ -558,8 +556,12 @@ static void qpa_fini_out (HWVoiceOut *hw) PAVoiceOut *pa =3D (PAVoiceOut *) hw; =20 if (pa->stream) { - qpa_simple_disconnect(pa->g->conn, pa->stream); + PAConnection *c =3D pa->g->conn; + + pa_threaded_mainloop_lock(c->mainloop); + qpa_simple_disconnect(c, pa->stream); pa->stream =3D NULL; + pa_threaded_mainloop_unlock(c->mainloop); } } =20 @@ -568,8 +570,20 @@ static void qpa_fini_in (HWVoiceIn *hw) PAVoiceIn *pa =3D (PAVoiceIn *) hw; =20 if (pa->stream) { - qpa_simple_disconnect(pa->g->conn, pa->stream); + PAConnection *c =3D pa->g->conn; + + pa_threaded_mainloop_lock(c->mainloop); + if (pa->read_length) { + int r =3D pa_stream_drop(pa->stream); + if (r) { + qpa_logerr(pa_context_errno(c->context), + "pa_stream_drop failed\n"); + } + pa->read_length =3D 0; + } + qpa_simple_disconnect(c, pa->stream); pa->stream =3D NULL; + pa_threaded_mainloop_unlock(c->mainloop); } } =20 --=20 2.18.1 From nobody Fri May 3 10:49:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578315267; cv=none; d=zohomail.com; s=zohoarc; b=AtC1PACQNDNaBHjIt1KAj3eF8B7U5naObSRBmv5lqO+Edqa/vweQGO7Px/NWxA1ggYXHmpk/RhCawDXYOPcENDGxQ4SE+tCxWDtRaUuBI1HwcDiwWerr9cJ4PenLm6U+wMsqhwWhmMhkrscqbawzHAlMtN9pVy6kAKUHsGCxRCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578315267; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rUKfZuNd1Qu2lKoFCCnXZ06t/YR98pMi3balpjSIsSo=; b=e+ILTrYoyLMzxtAkxC5LtdWyvYkrbN57V2WTceMweJSKkCqCxgiBcMrDIk2y9W9UpmJqt7tejxp4h/fmDbIwtproWPrGbF9QjDMobw3U2ypKqFReAgCd+qHpmKB0PiD1NWQNxqFfNcsuVF49yQc7z+fZY4Qcs6MMFRAxtMli+z8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578315267226829.27896196475; Mon, 6 Jan 2020 04:54:27 -0800 (PST) Received: from localhost ([::1]:51450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRtp-0002Vf-Ed for importer@patchew.org; Mon, 06 Jan 2020 07:54:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58252) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRsC-0000qF-Lk for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioRsB-0000oh-Kk for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:44 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51214 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ioRsB-0000my-FM for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:43 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-yI2feI0yMZuuG6khj3vIMQ-1; Mon, 06 Jan 2020 07:52:41 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D390800D4E; Mon, 6 Jan 2020 12:52:40 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83FEB5C57C; Mon, 6 Jan 2020 12:52:37 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A8B7831E49; Mon, 6 Jan 2020 13:52:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578315162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rUKfZuNd1Qu2lKoFCCnXZ06t/YR98pMi3balpjSIsSo=; b=Jwk/iMBrck5d2WAVbA7Bv2KYzaRSsCtOu5z6silLz4aXeoFy88VZ88Vts57hqSieZP/495 sMqzGs3kQEEvYoBpbiRiTODlzT+oR6lys8OJ1nWlPEQkoxWDffCJWfDQ/edkAEz/i0kZAz Vy1rLboWBRAt+8WDHFA3Y9nAHO3oJYw= From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 4/6] paaudio: try to drain the recording stream Date: Mon, 6 Jan 2020 13:52:34 +0100 Message-Id: <20200106125236.24132-5-kraxel@redhat.com> In-Reply-To: <20200106125236.24132-1-kraxel@redhat.com> References: <20200106125236.24132-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: yI2feI0yMZuuG6khj3vIMQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 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?Volker=20R=C3=BCmelin?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Volker R=C3=BCmelin There is no guarantee a single call to pa_stream_peek every timer_period microseconds can read a recording stream faster than the data gets produced at the source. Let qpa_read try to drain the recording stream. To reproduce the problem: Start qemu with -audiodev pa,id=3Daudio0,in.mixing-engine=3Doff On the host connect the qemu recording stream to the monitor of a hardware output device. While the problem can also be seen with a hardware input device, it's obvious with the monitor of a hardware output device. In the guest start audio recording with audacity and notice the slow recording data rate. Signed-off-by: Volker R=C3=BCmelin Message-id: 20200104091122.13971-4-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 7db1dc15f09e..b23274550e1c 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -156,34 +156,43 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, siz= e_t length) { PAVoiceIn *p =3D (PAVoiceIn *) hw; PAConnection *c =3D p->g->conn; - size_t l; - int r; + size_t total =3D 0; =20 pa_threaded_mainloop_lock(c->mainloop); =20 CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, "pa_threaded_mainloop_lock failed\n"); =20 - if (!p->read_length) { - r =3D pa_stream_peek(p->stream, &p->read_data, &p->read_length); - CHECK_SUCCESS_GOTO(c, r =3D=3D 0, unlock_and_fail, - "pa_stream_peek failed\n"); - } + while (total < length) { + size_t l; + int r; =20 - l =3D MIN(p->read_length, length); - memcpy(data, p->read_data, l); + if (!p->read_length) { + r =3D pa_stream_peek(p->stream, &p->read_data, &p->read_length= ); + CHECK_SUCCESS_GOTO(c, r =3D=3D 0, unlock_and_fail, + "pa_stream_peek failed\n"); + if (!p->read_length) { + /* buffer is empty */ + break; + } + } =20 - p->read_data +=3D l; - p->read_length -=3D l; + l =3D MIN(p->read_length, length - total); + memcpy((char *)data + total, p->read_data, l); =20 - if (!p->read_length) { - r =3D pa_stream_drop(p->stream); - CHECK_SUCCESS_GOTO(c, r =3D=3D 0, unlock_and_fail, - "pa_stream_drop failed\n"); + p->read_data +=3D l; + p->read_length -=3D l; + total +=3D l; + + if (!p->read_length) { + r =3D pa_stream_drop(p->stream); + CHECK_SUCCESS_GOTO(c, r =3D=3D 0, unlock_and_fail, + "pa_stream_drop failed\n"); + } } =20 pa_threaded_mainloop_unlock(c->mainloop); - return l; + return total; =20 unlock_and_fail: pa_threaded_mainloop_unlock(c->mainloop); --=20 2.18.1 From nobody Fri May 3 10:49:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578315397; cv=none; d=zohomail.com; s=zohoarc; b=ciJ9MoJxuUCcW4G57v9LmDnad0+8+aNxs2dOb0/wQL35KoNK/B/k57tmnlE7OLfsmn2WKWm96QJu8Fb0IENMEutfTjs57JXDt79IQEr7wuwtfwlD2lhg66EMjiVQQee7uSkaBGC44h8arTwk0AilSRYcK996T05lKpdGQCCtemg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578315397; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Te2JijOz57Os2mZyO59E9CRodauE2oIIc487Aq0SD7U=; b=UcuP7e1mGovq5t8003eeXiHgbdxBOZqSweFD9IYdXSFOtKHmH/GPHxWpPi4+sdbX3W5oTo7vrrFi+TNWTs+4bygZ3lzIWxnqazirQ3ee5CNJHfxUdStx/kBPSufD8Rwzmvf9LXDItIh2tMLh3ITW18acnDjASqcSw/0/jV/2fwc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578315397112935.3071612695916; Mon, 6 Jan 2020 04:56:37 -0800 (PST) Received: from localhost ([::1]:51488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRvv-0006DE-Nu for importer@patchew.org; Mon, 06 Jan 2020 07:56:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58302) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRsF-0000rp-8p for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioRsE-0000sE-7J for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:47 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:52069 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ioRsE-0000rY-3r for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-313-yz8t2z8TMsKeK-oGgtberg-1; Mon, 06 Jan 2020 07:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AA9918C8C00; Mon, 6 Jan 2020 12:52:41 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 138CF5C21A; Mon, 6 Jan 2020 12:52:41 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B13E031E8E; Mon, 6 Jan 2020 13:52:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578315165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Te2JijOz57Os2mZyO59E9CRodauE2oIIc487Aq0SD7U=; b=LsH5oMmYymX32oWQ+vseGoXxzAZIt/p7mHFaYupIrqw9lo8LoB0QRQBnTkzE5j2p1kl+i8 f0wAS+fOYOmS4Zr4ZF/cWXRm673X7mRrhilktzXcRsKWY7kUrvoJ6aKHK0emKBFkTsphBf XlShdfc8Lcl9WvWL55Rw1/SkZbLhii0= From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 5/6] paaudio: wait until the recording stream is ready Date: Mon, 6 Jan 2020 13:52:35 +0100 Message-Id: <20200106125236.24132-6-kraxel@redhat.com> In-Reply-To: <20200106125236.24132-1-kraxel@redhat.com> References: <20200106125236.24132-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: yz8t2z8TMsKeK-oGgtberg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.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: =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Volker R=C3=BCmelin 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=3Daudio0,server=3Dlocalhost,out.latency=3D30000, out.mixing-engine=3Doff,in.mixing-engine=3Doff \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny, resourcecontrol=3Ddeny \ -msg timestamp=3Don : Domain id=3D4 is tainted: custom-argv char device redirected to /dev/pts/1 (label charserial0) audio: Device pcspk: audiodev default parameter is deprecated, please specify audiodev=3Daudio0 audio: Device hda: audiodev default parameter is deprecated, please specify audiodev=3Daudio0 pulseaudio: pa_stream_peek failed pulseaudio: Reason: Bad state pulseaudio: pa_stream_peek failed pulseaudio: Reason: Bad state Signed-off-by: Volker R=C3=BCmelin Message-id: 20200104091122.13971-5-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann --- audio/paaudio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/audio/paaudio.c b/audio/paaudio.c index b23274550e1c..dbfe48c03a1d 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) =20 CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, "pa_threaded_mainloop_lock failed\n"); + if (pa_stream_get_state(p->stream) !=3D PA_STREAM_READY) { + /* wait for stream to become ready */ + goto unlock; + } =20 while (total < length) { size_t l; @@ -191,6 +195,7 @@ static size_t qpa_read(HWVoiceIn *hw, void *data, size_= t length) } } =20 +unlock: pa_threaded_mainloop_unlock(c->mainloop); return total; =20 --=20 2.18.1 From nobody Fri May 3 10:49:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1578315396; cv=none; d=zohomail.com; s=zohoarc; b=OX9sj77+Dzz3eNp7vlAmPXuj+l5XEj39JTPJx5b/merjMXOQvPp3CxB2IgE3Fq2g3K5+5ld6l+fDkZbRhBemuwasnj7+q06K63DbEsOUfyPaj4ze+N7hDAcKRuL7N5ziE5fWnANgw1GtAyfLWBsg6mCnuqqZwTsWxNod5XJclKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578315396; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TW5bcEK2mcJf++KaE2c3KEtsJTZNzjVIEZEEOKxkiYE=; b=ZoskEwCyv+3az7auTQJRootTwJeZ0DzFVEntKaQCsCDz0dEYffOaZj27TTZ5shGPlpHGEvW6xM/gUMIA4CpWtrJIokdIHqMK5KvCxcWfwpfjRbWvZIfO14LIK42E6M9aqa4ZVlJpQGys8vJAU+pp02wOUXVnpnaYkwU56Oj1QZs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578315396293846.2815038492146; Mon, 6 Jan 2020 04:56:36 -0800 (PST) Received: from localhost ([::1]:51484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRvv-0006Aq-1M for importer@patchew.org; Mon, 06 Jan 2020 07:56:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58308) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioRsF-0000sN-Il for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioRsE-0000sd-JS for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:47 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:60306 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ioRsE-0000rl-Fi for qemu-devel@nongnu.org; Mon, 06 Jan 2020 07:52:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-MAczsVmoOsiymzpbPNrUsQ-1; Mon, 06 Jan 2020 07:52:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4ED731800D53; Mon, 6 Jan 2020 12:52:41 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 112D584FE2; Mon, 6 Jan 2020 12:52:41 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B9C9E31E9A; Mon, 6 Jan 2020 13:52:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578315165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TW5bcEK2mcJf++KaE2c3KEtsJTZNzjVIEZEEOKxkiYE=; b=Ak2h9KShJLInJDnItTR/OC0nK8SiVwcpgArD41leGsDSv0ocQ3RgPjYgtxpr+nybr+OPnl kNaksqQiaztvjmUij7PGWFF6U2DklGYEpVv/jrHHI359ZFqeHqqtmCk2oWuVPizXgrFRNJ G+kuYjWf0HDd8NvpD+7+DIR+RpWytd8= From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 6/6] audio: fix integer overflow Date: Mon, 6 Jan 2020 13:52:36 +0100 Message-Id: <20200106125236.24132-7-kraxel@redhat.com> In-Reply-To: <20200106125236.24132-1-kraxel@redhat.com> References: <20200106125236.24132-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: MAczsVmoOsiymzpbPNrUsQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 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?Volker=20R=C3=BCmelin?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Volker R=C3=BCmelin Tell the compiler to do a 32bit * 32bit -> 64bit multiplication because period_ticks is a 64bit variable. The overflow occurs for audio timer periods larger than 4294967us. Fixes: be1092afa0 "audio: fix audio timer rate conversion bug" Signed-off-by: Volker R=C3=BCmelin Message-id: 8893a235-66a8-8fbe-7d95-862e29da90b1@t-online.de Signed-off-by: Gerd Hoffmann --- audio/audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/audio.c b/audio/audio.c index 56fae5504710..abea027fdf69 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1738,7 +1738,7 @@ static AudioState *audio_init(Audiodev *dev, const ch= ar *name) if (dev->timer_period <=3D 0) { s->period_ticks =3D 1; } else { - s->period_ticks =3D dev->timer_period * SCALE_US; + s->period_ticks =3D dev->timer_period * (int64_t)SCALE_US; } =20 e =3D qemu_add_vm_change_state_handler (audio_vm_change_state_handler,= s); --=20 2.18.1