From patchwork Thu Jan 23 07:49:35 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: 11346947 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 C43BF92A for ; Thu, 23 Jan 2020 07:50:50 +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 A35FC24125 for ; Thu, 23 Jan 2020 07:50:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A35FC24125 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]:52376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXGL-00079V-Bi for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 02:50:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46001) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXFL-0005h2-NE for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXFK-0004Om-PE for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:47 -0500 Received: from mailout08.t-online.de ([194.25.134.20]:45332) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXFK-0004NX-JY for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:46 -0500 Received: from fwd21.aul.t-online.de (fwd21.aul.t-online.de [172.20.27.66]) by mailout08.t-online.de (Postfix) with SMTP id 2005D41D32A5; Thu, 23 Jan 2020 08:49:44 +0100 (CET) Received: from linpower.localnet (bNEJ2sZQwhPdF053p99rOr5eUOxzP1RKhWfabVigViNXshI5fz3GEbZxOaUAu9YwCt@[46.86.62.122]) by fwd21.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iuXFH-2K3ybo0; Thu, 23 Jan 2020 08:49:43 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 53C20200602; Thu, 23 Jan 2020 08:49:43 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 1/9] audio: fix audio_generic_write Date: Thu, 23 Jan 2020 08:49:35 +0100 Message-Id: <20200123074943.6699-1-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> References: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> MIME-Version: 1.0 X-ID: bNEJ2sZQwhPdF053p99rOr5eUOxzP1RKhWfabVigViNXshI5fz3GEbZxOaUAu9YwCt X-TOI-MSGID: 1d46e7d3-5dca-40f8-b7d1-b8b55b8cbcbc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.25.134.20 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" The pcm_ops function put_buffer_out expects the returned pointer of function get_buffer_out as argument. Fix this. Signed-off-by: Volker Rümelin --- audio/audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/audio.c b/audio/audio.c index abea027fdf..db44482342 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1475,7 +1475,7 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size) copy_size = MIN(size, dst_size); memcpy(dst, buf, copy_size); - return hw->pcm_ops->put_buffer_out(hw, buf, copy_size); + return hw->pcm_ops->put_buffer_out(hw, dst, copy_size); } size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) From patchwork Thu Jan 23 07:49:36 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: 11346949 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 B516C17EA for ; Thu, 23 Jan 2020 07:50:53 +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 94E1624125 for ; Thu, 23 Jan 2020 07:50:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94E1624125 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]:52378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXGO-0007DF-9G for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 02:50:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46026) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXFN-0005hA-Nc for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXFM-0004Px-QZ for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:49 -0500 Received: from mailout01.t-online.de ([194.25.134.80]:36340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXFM-0004P9-Ku for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:48 -0500 Received: from fwd28.aul.t-online.de (fwd28.aul.t-online.de [172.20.26.133]) by mailout01.t-online.de (Postfix) with SMTP id 5BBAC42DD470; Thu, 23 Jan 2020 08:49:47 +0100 (CET) Received: from linpower.localnet (GvE5AwZawhyHpEISWGUAR6yEAWHXtdmV5fAU0TtZcH1uphGC7+rltvL1mYr6Y36QlL@[46.86.62.122]) by fwd28.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iuXFK-468UOO0; Thu, 23 Jan 2020 08:49:46 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 55E302006F4; Thu, 23 Jan 2020 08:49:43 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 2/9] audio: fix audio_generic_read Date: Thu, 23 Jan 2020 08:49:36 +0100 Message-Id: <20200123074943.6699-2-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> References: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> MIME-Version: 1.0 X-ID: GvE5AwZawhyHpEISWGUAR6yEAWHXtdmV5fAU0TtZcH1uphGC7+rltvL1mYr6Y36QlL X-TOI-MSGID: aaa557f0-0931-451b-b1ee-f95a482e22fe X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.25.134.80 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" It seems the function audio_generic_read started as a copy of function audio_generic_write and some necessary changes were forgotten. Fix the mixed up source and destination pointers and rename misnamed variables. Signed-off-by: Volker Rümelin --- audio/audio.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index db44482342..bf0f01e17f 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1480,12 +1480,12 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size) size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) { - size_t dst_size, copy_size; - void *dst = hw->pcm_ops->get_buffer_in(hw, &dst_size); - copy_size = MIN(size, dst_size); + size_t src_size, copy_size; + void *src = hw->pcm_ops->get_buffer_in(hw, &src_size); + copy_size = MIN(size, src_size); - memcpy(dst, buf, copy_size); - hw->pcm_ops->put_buffer_in(hw, buf, copy_size); + memcpy(buf, src, copy_size); + hw->pcm_ops->put_buffer_in(hw, src, copy_size); return copy_size; } From patchwork Thu Jan 23 07:49:37 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: 11346957 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 EA20392A for ; Thu, 23 Jan 2020 07:53:18 +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 CA4F224655 for ; Thu, 23 Jan 2020 07:53:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA4F224655 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]:52402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXIj-00021o-Ky for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 02:53:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46051) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXFP-0005j2-79 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXFO-0004Qn-0a for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:51 -0500 Received: from mailout08.t-online.de ([194.25.134.20]:46088) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXFN-0004QA-R6 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:49 -0500 Received: from fwd22.aul.t-online.de (fwd22.aul.t-online.de [172.20.26.127]) by mailout08.t-online.de (Postfix) with SMTP id CE67941D32A5; Thu, 23 Jan 2020 08:49:48 +0100 (CET) Received: from linpower.localnet (GWuX+2ZbYhZMP2LnDvdsdzW1bFHbiQ56L2Ypt+hmmL1J6fwYxXlj+OxkMz0rwroZ5x@[46.86.62.122]) by fwd22.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iuXFM-20d0IS0; Thu, 23 Jan 2020 08:49:48 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 567AA200F4D; Thu, 23 Jan 2020 08:49:43 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 3/9] paaudio: remove unused variables Date: Thu, 23 Jan 2020 08:49:37 +0100 Message-Id: <20200123074943.6699-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> References: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> MIME-Version: 1.0 X-ID: GWuX+2ZbYhZMP2LnDvdsdzW1bFHbiQ56L2Ypt+hmmL1J6fwYxXlj+OxkMz0rwroZ5x X-TOI-MSGID: 4ed9fe2e-aa59-4e09-8147-285958c7a8cc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.25.134.20 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" The unused variables were last used before commit 49ddd7e122 "paaudio: port to the new audio backend api". Signed-off-by: Volker Rümelin --- audio/paaudio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index dbfe48c03a..8f37c61851 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -32,7 +32,6 @@ typedef struct { HWVoiceOut hw; pa_stream *stream; paaudio *g; - size_t samples; } PAVoiceOut; typedef struct { @@ -41,7 +40,6 @@ typedef struct { const void *read_data; size_t read_length; paaudio *g; - size_t samples; } PAVoiceIn; static void qpa_conn_fini(PAConnection *c); @@ -488,7 +486,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsettings *as, } audio_pcm_init_info (&hw->info, &obt_as); - hw->samples = pa->samples = audio_buffer_samples( + hw->samples = audio_buffer_samples( qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, ppdo->buffer_length); @@ -536,7 +534,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) } audio_pcm_init_info (&hw->info, &obt_as); - hw->samples = pa->samples = audio_buffer_samples( + hw->samples = audio_buffer_samples( qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, ppdo->buffer_length); From patchwork Thu Jan 23 07:49:38 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: 11346961 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 B4A1892A for ; Thu, 23 Jan 2020 07:55:19 +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 94F4324655 for ; Thu, 23 Jan 2020 07:55:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94F4324655 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]:52428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXKg-0004bO-FE for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 02:55:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46135) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXFa-0005yF-Fg for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXFZ-0004fu-G8 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:02 -0500 Received: from mailout10.t-online.de ([194.25.134.21]:51690) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXFZ-0004cw-9s for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:01 -0500 Received: from fwd10.aul.t-online.de (fwd10.aul.t-online.de [172.20.26.152]) by mailout10.t-online.de (Postfix) with SMTP id 67E89415E823; Thu, 23 Jan 2020 08:49:58 +0100 (CET) Received: from linpower.localnet (TlKvyEZTYhur9DAPGEYWKidjGj6J0KObIIHEdW-kC4SbcWks057M-zzpxngbDOSZgo@[46.86.62.122]) by fwd10.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iuXFP-1KaRhg0; Thu, 23 Jan 2020 08:49:51 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 58C6A200F54; Thu, 23 Jan 2020 08:49:43 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 4/9] audio: prevent SIGSEGV in AUD_get_buffer_size_out Date: Thu, 23 Jan 2020 08:49:38 +0100 Message-Id: <20200123074943.6699-4-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> References: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> MIME-Version: 1.0 X-ID: TlKvyEZTYhur9DAPGEYWKidjGj6J0KObIIHEdW-kC4SbcWks057M-zzpxngbDOSZgo X-TOI-MSGID: 8551bd31-6fca-49ca-a085-88876a6ea7fb X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.25.134.21 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" With audiodev parameter out.mixing-engine=off hw->mix_buf is NULL. This leads to a segmentation fault in AUD_get_buffer_size_out. This patch reverts a small part of dc88e38fa7 "audio: unify input and output mixeng buffer management". To reproduce the problem start qemu with -soundhw adlib -audiodev pa,id=audio0,out.mixing-engine=off Signed-off-by: Volker Rümelin --- audio/audio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index bf0f01e17f..922e95011c 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -878,9 +878,9 @@ size_t AUD_read(SWVoiceIn *sw, void *buf, size_t size) } } -int AUD_get_buffer_size_out (SWVoiceOut *sw) +int AUD_get_buffer_size_out(SWVoiceOut *sw) { - return sw->hw->mix_buf->size * sw->hw->info.bytes_per_frame; + return sw->hw->samples * sw->hw->info.bytes_per_frame; } void AUD_set_active_out (SWVoiceOut *sw, int on) From patchwork Thu Jan 23 07:49:39 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: 11346955 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 3CBF692A for ; Thu, 23 Jan 2020 07:53:17 +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 1CB0624655 for ; Thu, 23 Jan 2020 07:53:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CB0624655 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]:52400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXIi-0001yr-4d for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 02:53:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46101) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXFY-0005uX-Dt for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXFT-0004Vu-Ls for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:57 -0500 Received: from mailout11.t-online.de ([194.25.134.85]:52744) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXFT-0004VK-CI for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:49:55 -0500 Received: from fwd40.aul.t-online.de (fwd40.aul.t-online.de [172.20.26.139]) by mailout11.t-online.de (Postfix) with SMTP id 30954420CDFB; Thu, 23 Jan 2020 08:49:54 +0100 (CET) Received: from linpower.localnet (VrguKZZOoh40tqYGygox7FLrBknOndn7kcFfFB18UsCLDaDN3qBd5ezq3imjsjEZ+1@[46.86.62.122]) by fwd40.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iuXFR-1DOQNM0; Thu, 23 Jan 2020 08:49:53 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 5ACA9200F62; Thu, 23 Jan 2020 08:49:43 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 5/9] audio: fix bug 1858488 Date: Thu, 23 Jan 2020 08:49:39 +0100 Message-Id: <20200123074943.6699-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> References: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> MIME-Version: 1.0 X-ID: VrguKZZOoh40tqYGygox7FLrBknOndn7kcFfFB18UsCLDaDN3qBd5ezq3imjsjEZ+1 X-TOI-MSGID: c6c8b1db-2cc9-4b1d-8350-9a559601e7f8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.25.134.85 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" The combined generic buffer management code and buffer run out code in function audio_generic_put_buffer_out has a problematic behaviour. A few hundred milliseconds after playback starts the mixing buffer and the generic buffer are nearly full and the following pattern can be seen. On first call of audio_pcm_hw_run_out the buffer run code in audio_generic_put_buffer_out writes some data to the audio hardware but the generic buffer will fill faster and is full when audio_pcm_hw_run_out returns. This is because emulated audio devices can produce playback data at a higher rate than the audio backend hardware consumes this data. On next call of audio_pcm_hw_run_out the buffer run code in audio_generic_put_buffer_out writes some data to the audio hardware but no audio data is transferred to the generic buffer because the buffer is already full. Then the pattern repeats. For the emulated audio device this looks like the audio timer period has doubled. This patch splits the combined generic buffer management code and buffer run out code and calls the buffer run out code after buffer management code to break this pattern. The bug report is for the wav audio backend. But the problem is not limited to this backend. All audio backends which use the audio_generic_put_buffer_out function show this problem. Signed-off-by: Volker Rümelin --- audio/alsaaudio.c | 1 + audio/audio.c | 58 ++++++++++++++++++++++++++----------------------------- audio/audio_int.h | 4 ++-- audio/coreaudio.c | 7 +++++-- audio/noaudio.c | 1 + audio/ossaudio.c | 10 ++++++++++ audio/sdlaudio.c | 7 +++++-- audio/wavaudio.c | 1 + 8 files changed, 52 insertions(+), 37 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index f37ce1ce85..4ef26818be 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -906,6 +906,7 @@ static struct audio_pcm_ops alsa_pcm_ops = { .init_out = alsa_init_out, .fini_out = alsa_fini_out, .write = alsa_write, + .run_buffer_out = audio_generic_run_buffer_out, .enable_out = alsa_enable_out, .init_in = alsa_init_in, diff --git a/audio/audio.c b/audio/audio.c index 922e95011c..81822bfec9 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1096,6 +1096,10 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live) } } + if (hw->pcm_ops->run_buffer_out) { + hw->pcm_ops->run_buffer_out(hw); + } + return clipped; } @@ -1412,6 +1416,28 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size) hw->pending_emul -= size; } +void audio_generic_run_buffer_out(HWVoiceOut *hw) +{ + while (hw->pending_emul) { + size_t write_len, written; + ssize_t start = ((ssize_t) hw->pos_emul) - hw->pending_emul; + + if (start < 0) { + start += hw->size_emul; + } + assert(start >= 0 && start < hw->size_emul); + + write_len = MIN(hw->pending_emul, hw->size_emul - start); + + written = hw->pcm_ops->write(hw, hw->buf_emul + start, write_len); + hw->pending_emul -= written; + + if (written < write_len) { + break; + } + } +} + void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size) { if (unlikely(!hw->buf_emul)) { @@ -1427,8 +1453,7 @@ void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size) return hw->buf_emul + hw->pos_emul; } -size_t audio_generic_put_buffer_out_nowrite(HWVoiceOut *hw, void *buf, - size_t size) +size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) { assert(buf == hw->buf_emul + hw->pos_emul && size + hw->pending_emul <= hw->size_emul); @@ -1439,35 +1464,6 @@ size_t audio_generic_put_buffer_out_nowrite(HWVoiceOut *hw, void *buf, return size; } -size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) -{ - audio_generic_put_buffer_out_nowrite(hw, buf, size); - - while (hw->pending_emul) { - size_t write_len, written; - ssize_t start = ((ssize_t) hw->pos_emul) - hw->pending_emul; - if (start < 0) { - start += hw->size_emul; - } - assert(start >= 0 && start < hw->size_emul); - - write_len = MIN(hw->pending_emul, hw->size_emul - start); - - written = hw->pcm_ops->write(hw, hw->buf_emul + start, write_len); - hw->pending_emul -= written; - - if (written < write_len) { - break; - } - } - - /* - * fake we have written everything. non-written data remain in pending_emul, - * so we do not have to clip them multiple times - */ - return size; -} - size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size) { size_t dst_size, copy_size; diff --git a/audio/audio_int.h b/audio/audio_int.h index 5ba2078346..3c8e48b55b 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -152,6 +152,7 @@ struct audio_pcm_ops { int (*init_out)(HWVoiceOut *hw, audsettings *as, void *drv_opaque); void (*fini_out)(HWVoiceOut *hw); size_t (*write) (HWVoiceOut *hw, void *buf, size_t size); + void (*run_buffer_out)(HWVoiceOut *hw); /* * get a buffer that after later can be passed to put_buffer_out; optional * returns the buffer, and writes it's size to size (in bytes) @@ -178,10 +179,9 @@ struct audio_pcm_ops { void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size); void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size); +void audio_generic_run_buffer_out(HWVoiceOut *hw); void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size); size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size); -size_t audio_generic_put_buffer_out_nowrite(HWVoiceOut *hw, void *buf, - size_t size); size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size); size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size); diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 66f0f459cf..c7a7196c2d 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -411,7 +411,7 @@ static int coreaudio_unlock (coreaudioVoiceOut *core, const char *fn_name) } COREAUDIO_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), (hw, size)) -COREAUDIO_WRAPPER_FUNC(put_buffer_out_nowrite, size_t, +COREAUDIO_WRAPPER_FUNC(put_buffer_out, size_t, (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size)) COREAUDIO_WRAPPER_FUNC(write, size_t, (HWVoiceOut *hw, void *buf, size_t size), @@ -687,9 +687,12 @@ static void coreaudio_audio_fini (void *opaque) static struct audio_pcm_ops coreaudio_pcm_ops = { .init_out = coreaudio_init_out, .fini_out = coreaudio_fini_out, + /* wrapper for audio_generic_write */ .write = coreaudio_write, + /* wrapper for audio_generic_get_buffer_out */ .get_buffer_out = coreaudio_get_buffer_out, - .put_buffer_out = coreaudio_put_buffer_out_nowrite, + /* wrapper for audio_generic_put_buffer_out */ + .put_buffer_out = coreaudio_put_buffer_out, .enable_out = coreaudio_enable_out }; diff --git a/audio/noaudio.c b/audio/noaudio.c index ff99b253ff..05798ea210 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -118,6 +118,7 @@ static struct audio_pcm_ops no_pcm_ops = { .init_out = no_init_out, .fini_out = no_fini_out, .write = no_write, + .run_buffer_out = audio_generic_run_buffer_out, .enable_out = no_enable_out, .init_in = no_init_in, diff --git a/audio/ossaudio.c b/audio/ossaudio.c index c43faeeea4..4965084a5a 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -382,6 +382,15 @@ static size_t oss_get_available_bytes(OSSVoiceOut *oss) return audio_ring_dist(cntinfo.ptr, oss->hw.pos_emul, oss->hw.size_emul); } +static void oss_run_buffer_out(HWVoiceOut *hw) +{ + OSSVoiceOut *oss = (OSSVoiceOut *)hw; + + if (!oss->mmapped) { + audio_generic_run_buffer_out(hw); + } +} + static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size) { OSSVoiceOut *oss = (OSSVoiceOut *) hw; @@ -748,6 +757,7 @@ static struct audio_pcm_ops oss_pcm_ops = { .init_out = oss_init_out, .fini_out = oss_fini_out, .write = oss_write, + .run_buffer_out = oss_run_buffer_out, .get_buffer_out = oss_get_buffer_out, .put_buffer_out = oss_put_buffer_out, .enable_out = oss_enable_out, diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 5c6bcfcb3e..c00e7d7845 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -227,7 +227,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len) SDL_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), (hw, size), *size = 0, sdl_unlock) -SDL_WRAPPER_FUNC(put_buffer_out_nowrite, size_t, +SDL_WRAPPER_FUNC(put_buffer_out, size_t, (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size), /*nothing*/, sdl_unlock_and_post) SDL_WRAPPER_FUNC(write, size_t, @@ -320,9 +320,12 @@ static void sdl_audio_fini (void *opaque) static struct audio_pcm_ops sdl_pcm_ops = { .init_out = sdl_init_out, .fini_out = sdl_fini_out, + /* wrapper for audio_generic_write */ .write = sdl_write, + /* wrapper for audio_generic_get_buffer_out */ .get_buffer_out = sdl_get_buffer_out, - .put_buffer_out = sdl_put_buffer_out_nowrite, + /* wrapper for audio_generic_put_buffer_out */ + .put_buffer_out = sdl_put_buffer_out, .enable_out = sdl_enable_out, }; diff --git a/audio/wavaudio.c b/audio/wavaudio.c index e46d834bd3..20e6853f85 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -197,6 +197,7 @@ static struct audio_pcm_ops wav_pcm_ops = { .init_out = wav_init_out, .fini_out = wav_fini_out, .write = wav_write_out, + .run_buffer_out = audio_generic_run_buffer_out, .enable_out = wav_enable_out, }; From patchwork Thu Jan 23 07:49:40 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: 11346963 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 CEDA214B4 for ; Thu, 23 Jan 2020 07:57:02 +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 6B02E24655 for ; Thu, 23 Jan 2020 07:57:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B02E24655 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]:52460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXML-000692-DE for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 02:57:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46175) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXFd-00061d-R3 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXFc-0004j0-UB for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:05 -0500 Received: from mailout03.t-online.de ([194.25.134.81]:50686) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXFc-0004hu-OE for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:04 -0500 Received: from fwd06.aul.t-online.de (fwd06.aul.t-online.de [172.20.26.150]) by mailout03.t-online.de (Postfix) with SMTP id CAC18426D4ED; Thu, 23 Jan 2020 08:50:02 +0100 (CET) Received: from linpower.localnet (bdOpmsZawhWbFhK9XojQt-0+cJTgGNpHSj4-Vdy8o65QU2oaeQz3Suo1r9mdc4wwHq@[46.86.62.122]) by fwd06.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iuXFU-12fW7M0; Thu, 23 Jan 2020 08:49:56 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 5CBB8200F75; Thu, 23 Jan 2020 08:49:43 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 6/9] ossaudio: prevent SIGSEGV in oss_enable_out Date: Thu, 23 Jan 2020 08:49:40 +0100 Message-Id: <20200123074943.6699-6-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> References: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> MIME-Version: 1.0 X-ID: bdOpmsZawhWbFhK9XojQt-0+cJTgGNpHSj4-Vdy8o65QU2oaeQz3Suo1r9mdc4wwHq X-TOI-MSGID: ca8aec17-591c-475c-b00f-b6ac2ae58548 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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" With audiodev parameter out.mixing-engine=off hw->mix_buf is NULL. This patch reverts a small part of dc88e38fa7 "audio: unify input and output mixeng buffer management". To reproduce the problem start qemu with -audiodev oss,id=audio0,try-mmap=on,out.mixing-engine=off Signed-off-by: Volker Rümelin --- audio/ossaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 4965084a5a..6a3b78b381 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -592,7 +592,7 @@ static void oss_enable_out(HWVoiceOut *hw, bool enable) return; } - audio_pcm_info_clear_buf(&hw->info, hw->buf_emul, hw->mix_buf->size); + audio_pcm_info_clear_buf(&hw->info, hw->buf_emul, hw->samples); trig = PCM_ENABLE_OUTPUT; if (ioctl(oss->fd, SNDCTL_DSP_SETTRIGGER, &trig) < 0) { oss_logerr(errno, From patchwork Thu Jan 23 07:49:41 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: 11346959 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 A998A17EA for ; Thu, 23 Jan 2020 07:55:18 +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 872B724655 for ; Thu, 23 Jan 2020 07:55:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 872B724655 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]:52426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXKf-0004aZ-Mc for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 02:55:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46136) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXFa-0005yI-G2 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXFZ-0004g1-H3 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:02 -0500 Received: from mailout04.t-online.de ([194.25.134.18]:51794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXFZ-0004dZ-Ah for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:01 -0500 Received: from fwd29.aul.t-online.de (fwd29.aul.t-online.de [172.20.26.134]) by mailout04.t-online.de (Postfix) with SMTP id 18D9541FCB1C; Thu, 23 Jan 2020 08:50:00 +0100 (CET) Received: from linpower.localnet (GFWNiEZAQhrdd42r1V37Wi9PdfyQtCetwxZWB5SNhsPudsjem+dOmwhMp9907QJQ9u@[46.86.62.122]) by fwd29.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iuXFW-3e3Ii80; Thu, 23 Jan 2020 08:49:58 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 5EF22200F7A; Thu, 23 Jan 2020 08:49:43 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 7/9] ossaudio: prevent SIGPFE in oss_write Date: Thu, 23 Jan 2020 08:49:41 +0100 Message-Id: <20200123074943.6699-7-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> References: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> MIME-Version: 1.0 X-ID: GFWNiEZAQhrdd42r1V37Wi9PdfyQtCetwxZWB5SNhsPudsjem+dOmwhMp9907QJQ9u X-TOI-MSGID: 10dee584-7dad-4154-905c-87869e450261 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.25.134.18 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" The new buffer write position is modulo the buffer size. To reproduce start qemu with: -audiodev oss,id=audio0,try-mmap=on,out.mixing-engine=off Signed-off-by: Volker Rümelin --- audio/ossaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 6a3b78b381..39a6fc09e5 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -429,7 +429,7 @@ static size_t oss_write(HWVoiceOut *hw, void *buf, size_t len) size_t to_copy = MIN(len, hw->size_emul - hw->pos_emul); memcpy(hw->buf_emul + hw->pos_emul, buf, to_copy); - hw->pos_emul = (hw->pos_emul + to_copy) % hw->pos_emul; + hw->pos_emul = (hw->pos_emul + to_copy) % hw->size_emul; buf += to_copy; len -= to_copy; } From patchwork Thu Jan 23 07:49:42 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: 11346951 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 9622F17EA for ; Thu, 23 Jan 2020 07:51:22 +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 31C7824125 for ; Thu, 23 Jan 2020 07:51:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31C7824125 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]:52380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXGq-0007vp-EN for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 02:51:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46171) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXFd-00061L-Lc for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXFb-0004iV-NC for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:05 -0500 Received: from mailout07.t-online.de ([194.25.134.83]:56294) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXFb-0004hB-HP for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:03 -0500 Received: from fwd35.aul.t-online.de (fwd35.aul.t-online.de [172.20.27.145]) by mailout07.t-online.de (Postfix) with SMTP id 0D7E6420C3D4; Thu, 23 Jan 2020 08:50:02 +0100 (CET) Received: from linpower.localnet (EG4kSMZfQh937Ei9W3xhVB+UPLFVHknNBDFVSK8dnWKC+wMwWpejyJtib4H-JrwQfY@[46.86.62.122]) by fwd35.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iuXFZ-32WwxE0; Thu, 23 Jan 2020 08:50:01 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 60EF9200F7D; Thu, 23 Jan 2020 08:49:43 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 8/9] ossaudio: disable poll mode can't be reached Date: Thu, 23 Jan 2020 08:49:42 +0100 Message-Id: <20200123074943.6699-8-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> References: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> MIME-Version: 1.0 X-ID: EG4kSMZfQh937Ei9W3xhVB+UPLFVHknNBDFVSK8dnWKC+wMwWpejyJtib4H-JrwQfY X-TOI-MSGID: 98d184ff-a104-44b3-b651-0d2090ea5e6b X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.25.134.83 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" Currently there is no way to disable poll mode in oss_enable_out and oss_enable_in when it was enabled before. The enable code path always resets the poll mode state variable. Fixes: b027a538c6 "oss: Remove unused error handling of qemu_set_fd_handler" Signed-off-by: Volker Rümelin --- audio/ossaudio.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 39a6fc09e5..f88d076ec2 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -579,14 +579,12 @@ static void oss_enable_out(HWVoiceOut *hw, bool enable) AudiodevOssPerDirectionOptions *opdo = oss->dev->u.oss.out; if (enable) { - bool poll_mode = opdo->try_poll; + hw->poll_mode = opdo->try_poll; ldebug("enabling voice\n"); - if (poll_mode) { + if (hw->poll_mode) { oss_poll_out(hw); - poll_mode = 0; } - hw->poll_mode = poll_mode; if (!oss->mmapped) { return; @@ -708,17 +706,15 @@ static void oss_enable_in(HWVoiceIn *hw, bool enable) AudiodevOssPerDirectionOptions *opdo = oss->dev->u.oss.out; if (enable) { - bool poll_mode = opdo->try_poll; + hw->poll_mode = opdo->try_poll; - if (poll_mode) { + if (hw->poll_mode) { oss_poll_in(hw); - poll_mode = 0; } - hw->poll_mode = poll_mode; } else { if (hw->poll_mode) { - hw->poll_mode = 0; qemu_set_fd_handler (oss->fd, NULL, NULL, NULL); + hw->poll_mode = 0; } } } From patchwork Thu Jan 23 07:49:43 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: 11346953 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 431E592A for ; Thu, 23 Jan 2020 07:51:23 +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 235D824673 for ; Thu, 23 Jan 2020 07:51:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 235D824673 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]:52382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXGs-0007xe-21 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 02:51:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46203) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXFe-00064E-Tr for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXFd-0004k4-Or for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:06 -0500 Received: from mailout11.t-online.de ([194.25.134.85]:52880) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXFd-0004iw-If for qemu-devel@nongnu.org; Thu, 23 Jan 2020 02:50:05 -0500 Received: from fwd28.aul.t-online.de (fwd28.aul.t-online.de [172.20.26.133]) by mailout11.t-online.de (Postfix) with SMTP id AB0C7420CE02; Thu, 23 Jan 2020 08:50:04 +0100 (CET) Received: from linpower.localnet (bHQziOZJ8hihzvynLX2VZ7WNABYdTbkckmy6-wzT15PRNqmXAUFxGBvKiAAcuHcw2P@[46.86.62.122]) by fwd28.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1iuXFb-4bEfKa0; Thu, 23 Jan 2020 08:50:03 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 62E8420109E; Thu, 23 Jan 2020 08:49:43 +0100 (CET) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 9/9] audio: audio_generic_get_buffer_in should honor *size Date: Thu, 23 Jan 2020 08:49:43 +0100 Message-Id: <20200123074943.6699-9-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> References: <1e29e1d3-b59b-fcd6-cdff-a680bcdbffa4@t-online.de> MIME-Version: 1.0 X-ID: bHQziOZJ8hihzvynLX2VZ7WNABYdTbkckmy6-wzT15PRNqmXAUFxGBvKiAAcuHcw2P X-TOI-MSGID: 2e6beee5-9e20-489a-9183-2aa25db3e52f X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.25.134.85 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" The function generic_get_buffer_in currently ignores the *size parameter and may return a buffer larger than *size. As a result the variable samples in function audio_pcm_hw_run_in may underflow. The while loop then most likely will never termiate. This bug was reported at http://bugs.debian.org/948658. Signed-off-by: Volker Rümelin --- audio/audio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audio/audio.c b/audio/audio.c index 81822bfec9..f5fb6cbf53 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1406,7 +1406,8 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size) } assert(start >= 0 && start < hw->size_emul); - *size = MIN(hw->pending_emul, hw->size_emul - start); + *size = MIN(*size, hw->pending_emul); + *size = MIN(*size, hw->size_emul - start); return hw->buf_emul + start; }