From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273094; cv=none; d=zohomail.com; s=zohoarc; b=RC4uZmJKTxEwMFFvrgWz4jQzNBNUTfhlWGOFwX9HYKqJK+PGRKDfn4jbFAOif4tGwPaoyhcvdQawZlN63ZNas4qQ16zWd4Vat8nCH8iGRjxnPww54reoZK68NngdZNZ0o16w+tCPSChSHs/baFed7uvEvRXpx2WyzhjJvJrUfGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273094; 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=8QmXna6M4jkI/JWvWkDb+8I1ImtgQv0FVANYxb5a/zs=; b=TlGXSmkjy4XBVJDV13vaJnlAt0k/QgeFeFYglyLdBl+oQOTn7TDDWCN8u3Klaye2vrV+DuEAH5wWBpEg/a4dgq5UMG0ekpVrESci9Yx+bQOXWkXH/jZHF8/CKrAKb6JnSfALAW5TVoUdBy6jazmYzGbePgjMD+mL+zLsR5GtWqQ= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161027309413140.61193509923737; Sun, 10 Jan 2021 02:04:54 -0800 (PST) Received: from localhost ([::1]:56850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXae-00033U-33 for importer@patchew.org; Sun, 10 Jan 2021 05:04:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYg-0001DL-NE for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:02:50 -0500 Received: from mailout02.t-online.de ([194.25.134.17]:47304) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYf-0005Gn-3O for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:02:50 -0500 Received: from fwd05.aul.t-online.de (fwd05.aul.t-online.de [172.20.27.149]) by mailout02.t-online.de (Postfix) with SMTP id 9E48341BBE3A; Sun, 10 Jan 2021 11:02:46 +0100 (CET) Received: from linpower.localnet (ZZ4B+EZdoheBFqCKvGzaHXSWmtWglRZDPhjzb4w2t8vqRko9bQ4mNLUhO6YakwkQWx@[93.236.152.29]) by fwd05.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYW-1Qu1Lc0; Sun, 10 Jan 2021 11:02:40 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id DECF0200611; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 01/23] sdlaudio: remove leftover SDL1.2 code Date: Sun, 10 Jan 2021 11:02:17 +0100 Message-Id: <20210110100239.27588-1-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: ZZ4B+EZdoheBFqCKvGzaHXSWmtWglRZDPhjzb4w2t8vqRko9bQ4mNLUhO6YakwkQWx X-TOI-EXPURGATEID: 150726::1610272960-000174C8-111B19AD/0/0 CLEAN NORMAL X-TOI-MSGID: e41d6245-f53d-4bea-89aa-6feb0c65990b 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; Received-SPF: none client-ip=194.25.134.17; envelope-from=volker.ruemelin@t-online.de; helo=mailout02.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Thomas Huth --- audio/sdlaudio.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 21b7a0484b..bf3cfb8456 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -240,28 +240,24 @@ static void sdl_callback (void *opaque, Uint8 *buf, i= nt len) } } =20 -#define SDL_WRAPPER_FUNC(name, ret_type, args_decl, args, fail, unlock) \ - static ret_type glue(sdl_, name)args_decl \ - { \ - ret_type ret; \ - \ - SDL_LockAudio(); \ - \ - ret =3D glue(audio_generic_, name)args; \ - \ - SDL_UnlockAudio(); \ - return ret; \ +#define SDL_WRAPPER_FUNC(name, ret_type, args_decl, args) \ + static ret_type glue(sdl_, name)args_decl \ + { \ + ret_type ret; \ + \ + SDL_LockAudio(); \ + ret =3D glue(audio_generic_, name)args; \ + SDL_UnlockAudio(); \ + \ + return ret; \ } =20 SDL_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), - (hw, size), *size =3D 0, sdl_unlock) + (hw, size)) SDL_WRAPPER_FUNC(put_buffer_out, size_t, - (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size), - /*nothing*/, sdl_unlock_and_post) + (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size)) SDL_WRAPPER_FUNC(write, size_t, - (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size), - /*nothing*/, sdl_unlock_and_post) - + (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size)) #undef SDL_WRAPPER_FUNC =20 static void sdl_fini_out (HWVoiceOut *hw) --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273080; cv=none; d=zohomail.com; s=zohoarc; b=PkkyJNNl2fkgLqm6VIT/imeEUrZr4mlzusmTRAnuGg9EJliM32ElxghHWTzr1M6Vo597DdoPQIqcDPEiicJZwTCoguRQyW+bSGdkiPjvChFXUbcRYmWvKjG9BEm4hHOYI/953qQclq9hSzcfAvXuD4JD2jiE3ECNAepD6maC7JA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273080; 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=lnIMdvcpzZLRH9CfU7kdQLMwnJZuXzqFjwiFyS/9eqE=; b=Zioi2sOqnZ2sx9usjyZ0/Z6JSKMBQi/Kw2vOG9yC3LZIUMsfkpRKP3XTNajlMYR6q84jU1hg7mahE/09v8TD5/9aFU7hAhdtzt/0mtcEP30mTDnrFDRCwB69dTALVruqvBR0fzsNYLUWl3kB+jmJIj7aFqGBbJMeVWETWOVBIe0= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273080264363.95064186435286; Sun, 10 Jan 2021 02:04:40 -0800 (PST) Received: from localhost ([::1]:56454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXaR-0002pU-0s for importer@patchew.org; Sun, 10 Jan 2021 05:04:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYf-0001CW-Ux for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:02:49 -0500 Received: from mailout07.t-online.de ([194.25.134.83]:59462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYe-0005Fb-8e for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:02:49 -0500 Received: from fwd31.aul.t-online.de (fwd31.aul.t-online.de [172.20.26.136]) by mailout07.t-online.de (Postfix) with SMTP id D10D14216FC2; Sun, 10 Jan 2021 11:02:43 +0100 (CET) Received: from linpower.localnet (GiLLFmZfohD+UvhiJzQeOFl-PdIKtJ2hO0GpG4YJG3hsdzTs17VFE6icjDSBmCgZMm@[93.236.152.29]) by fwd31.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYZ-0iVAjg0; Sun, 10 Jan 2021 11:02:43 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E0C1A200613; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 02/23] audio: fix bit-rotted code Date: Sun, 10 Jan 2021 11:02:18 +0100 Message-Id: <20210110100239.27588-2-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: GiLLFmZfohD+UvhiJzQeOFl-PdIKtJ2hO0GpG4YJG3hsdzTs17VFE6icjDSBmCgZMm X-TOI-EXPURGATEID: 150726::1610272963-0000B028-35DDAE5E/0/0 CLEAN NORMAL X-TOI-MSGID: 0523b961-a39f-441e-a95c-e77f9271d30d 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; Received-SPF: none client-ip=194.25.134.83; envelope-from=volker.ruemelin@t-online.de; helo=mailout07.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Volker R=C3=BCmelin --- audio/alsaaudio.c | 2 +- audio/sdlaudio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index a8e62542f9..6787e91bc1 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -599,7 +599,7 @@ static int alsa_open(bool in, struct alsa_params_req *r= eq, } =20 #ifdef DEBUG - alsa_dump_info(req, obt, obtfmt, pdo); + alsa_dump_info(req, obt, obtfmt, apdo); #endif return 0; =20 diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index bf3cfb8456..00cd12ba66 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -215,7 +215,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int= len) return; } =20 - /* dolog ("in callback samples=3D%zu live=3D%zu\n", samples, sdl->live= ); */ + /* dolog("callback: len=3D%d avail=3D%zu\n", len, hw->pending_emul); */ =20 while (hw->pending_emul && len) { size_t write_len; --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273338; cv=none; d=zohomail.com; s=zohoarc; b=XkNWD8TRRO2tt8nnBhZxMCyh0Bu9Qf7H+lYzhvb6iASdbswUG2E/O3y9CZ6bVGCVSyssi6UMISXq+I/ghJckvXQg1qEbQUd1Uje8edLrmkQW81ytkSm4WoGC6Ce/d74MfomRrtO/MEOZt/33I1disSNC0dfgYzIygD12vj8vk+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273338; 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=iSN2EzrMBdwe9aKZusG74DvPBgjai9dvP+98KPDzM+I=; b=X/imxFTrykZtIJNlbTyfq9NJNjWVtu5uRs50tYgZZH7hJvp3CC6BrLIexmph/M8J4mfp6lbCOLSPGu+ALBmxwMiIJ4K0QEHyAEDMcRUmfKFh2+I5/FDD8I+1/kjbWTCFC9mmezdQ43Fehh9lLUygA0yLKEIzk5q50GOMvPbA8Yk= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273338418142.0547327794526; Sun, 10 Jan 2021 02:08:58 -0800 (PST) Received: from localhost ([::1]:37866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXeb-000703-64 for importer@patchew.org; Sun, 10 Jan 2021 05:08:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYt-0001ZK-VJ for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:04 -0500 Received: from mailout08.t-online.de ([194.25.134.20]:33082) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYr-0005MJ-AR for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:03 -0500 Received: from fwd26.aul.t-online.de (fwd26.aul.t-online.de [172.20.26.131]) by mailout08.t-online.de (Postfix) with SMTP id 8D1B441E6B15; Sun, 10 Jan 2021 11:02:59 +0100 (CET) Received: from linpower.localnet (bdeIpwZ6rhZJpIutZrIYnjIo40nnG1I+vfuiVDsGjdz4AX-Ly+pK2ADyTZQWNU4QPi@[93.236.152.29]) by fwd26.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYb-3qbE4O0; Sun, 10 Jan 2021 11:02:45 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E196120062D; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 03/23] sdlaudio: add -audiodev sdl,out.buffer-count option Date: Sun, 10 Jan 2021 11:02:19 +0100 Message-Id: <20210110100239.27588-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: bdeIpwZ6rhZJpIutZrIYnjIo40nnG1I+vfuiVDsGjdz4AX-Ly+pK2ADyTZQWNU4QPi X-TOI-EXPURGATEID: 150726::1610272965-0000FB7B-2AF666C2/0/0 CLEAN NORMAL X-TOI-MSGID: bfdc5d63-1419-4a83-a1c8-3fcfe3d9497e 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; Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Markus Armbruster , QEMU , =?UTF-8?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Currently there is a crackling noise with SDL2 audio playback. Commit bcf19777df: "audio/sdlaudio: Allow audio playback with SDL2" already mentioned the crackling noise. Add an out.buffer-count option to give users a chance to select sane settings for glitch free audio playback. The idea was taken from the coreaudio backend. The in.buffer-count option will be used with one of the next patches. Signed-off-by: Volker R=C3=BCmelin Acked-by: Markus Armbruster --- audio/audio.c | 2 +- audio/audio_legacy.c | 3 ++- audio/audio_template.h | 2 +- audio/sdlaudio.c | 11 +++++++++-- qapi/audio.json | 33 ++++++++++++++++++++++++++++++++- qemu-options.hx | 8 +++++++- 6 files changed, 52 insertions(+), 7 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index b48471bb3f..d048d26283 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -2003,7 +2003,7 @@ void audio_create_pdos(Audiodev *dev) CASE(JACK, jack, Jack); CASE(OSS, oss, Oss); CASE(PA, pa, Pa); - CASE(SDL, sdl, ); + CASE(SDL, sdl, Sdl); CASE(SPICE, spice, ); CASE(WAV, wav, ); =20 diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index ffdbd0bcce..0fe827b057 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -286,7 +286,8 @@ static void handle_sdl(Audiodev *dev) { /* SDL is output only */ get_samples_to_usecs("QEMU_SDL_SAMPLES", &dev->u.sdl.out->buffer_lengt= h, - &dev->u.sdl.out->has_buffer_length, dev->u.sdl.ou= t); + &dev->u.sdl.out->has_buffer_length, + qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.out)); } =20 /* wav */ diff --git a/audio/audio_template.h b/audio/audio_template.h index 8dd48ce14e..434df5d5e7 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -337,7 +337,7 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)= (Audiodev *dev) case AUDIODEV_DRIVER_PA: return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.TYPE); case AUDIODEV_DRIVER_SDL: - return dev->u.sdl.TYPE; + return qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.TYPE); case AUDIODEV_DRIVER_SPICE: return dev->u.spice.TYPE; case AUDIODEV_DRIVER_WAV: diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 00cd12ba66..431bfcfddd 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -276,12 +276,18 @@ static int sdl_init_out(HWVoiceOut *hw, struct audset= tings *as, int endianness; int err; AudioFormat effective_fmt; + AudiodevSdlPerDirectionOptions *spdo =3D s->dev->u.sdl.out; struct audsettings obt_as; =20 req.freq =3D as->freq; req.format =3D aud_to_sdlfmt (as->fmt); req.channels =3D as->nchannels; - req.samples =3D audio_buffer_samples(s->dev->u.sdl.out, as, 11610); + /* + * This is wrong. SDL samples are QEMU frames. The buffer size will be + * the requested buffer size multiplied by the number of channels. + */ + req.samples =3D audio_buffer_samples( + qapi_AudiodevSdlPerDirectionOptions_base(spdo), as, 11610); req.callback =3D sdl_callback; req.userdata =3D sdl; =20 @@ -301,7 +307,8 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, obt_as.endianness =3D endianness; =20 audio_pcm_init_info (&hw->info, &obt_as); - hw->samples =3D obt.samples; + hw->samples =3D (spdo->has_buffer_count ? spdo->buffer_count : 4) * + obt.samples; =20 s->initialized =3D 1; s->exit =3D 0; diff --git a/qapi/audio.json b/qapi/audio.json index 072ed79def..9cba0df8a4 100644 --- a/qapi/audio.json +++ b/qapi/audio.json @@ -301,6 +301,37 @@ '*out': 'AudiodevPaPerDirectionOptions', '*server': 'str' } } =20 +## +# @AudiodevSdlPerDirectionOptions: +# +# Options of the SDL audio backend that are used for both playback and +# recording. +# +# @buffer-count: number of buffers (default 4) +# +# Since: 6.0 +## +{ 'struct': 'AudiodevSdlPerDirectionOptions', + 'base': 'AudiodevPerDirectionOptions', + 'data': { + '*buffer-count': 'uint32' } } + +## +# @AudiodevSdlOptions: +# +# Options of the SDL audio backend. +# +# @in: options of the recording stream +# +# @out: options of the playback stream +# +# Since: 6.0 +## +{ 'struct': 'AudiodevSdlOptions', + 'data': { + '*in': 'AudiodevSdlPerDirectionOptions', + '*out': 'AudiodevSdlPerDirectionOptions' } } + ## # @AudiodevWavOptions: # @@ -385,6 +416,6 @@ 'jack': 'AudiodevJackOptions', 'oss': 'AudiodevOssOptions', 'pa': 'AudiodevPaOptions', - 'sdl': 'AudiodevGenericOptions', + 'sdl': 'AudiodevSdlOptions', 'spice': 'AudiodevGenericOptions', 'wav': 'AudiodevWavOptions' } } diff --git a/qemu-options.hx b/qemu-options.hx index 1698a0c751..4e02e9bd76 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -588,6 +588,7 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, #endif #ifdef CONFIG_AUDIO_SDL "-audiodev sdl,id=3Did[,prop[=3Dvalue][,...]]\n" + " in|out.buffer-count=3D number of buffers\n" #endif #ifdef CONFIG_SPICE "-audiodev spice,id=3Did[,prop[=3Dvalue][,...]]\n" @@ -745,7 +746,12 @@ SRST ``-audiodev sdl,id=3Did[,prop[=3Dvalue][,...]]`` Creates a backend using SDL. This backend is available on most systems, but you should use your platform's native backend if - possible. This backend has no backend specific properties. + possible. + + SDL specific options are: + + ``in|out.buffer-count=3Dcount`` + Sets the count of the buffers. =20 ``-audiodev spice,id=3Did[,prop[=3Dvalue][,...]]`` Creates a backend that sends audio through SPICE. This backend --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273099; cv=none; d=zohomail.com; s=zohoarc; b=PP+2V9kbU6SHbljopRb4klVpaoAz4cfhWKdL9HxbiNbCPnm8rIJFN4ewLPkIleTekM2WUvG94ayHozuq/Xbf6jbRWHin6TivMKWsczsWrpD2NiFNququrZxSbUxJXcr5fENw13rzhqEq/NHQOnsZsD5zd8wfUcJrCpzz4dsb9UI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273099; 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=BoBZKkx9NxcA2E5TvYjLWv7m9tUxfUw6gk0xlmiWdfU=; b=bZEMcL1Jns1pIQHuUoa1cxKflJAtP8O00O8z4XfANEdIeCBUIstFJLYmDY7tgVdIdtkk5i/qB2zZFhGUMp0Cw61Ha1pdWKXNrpxpuyq8Fc+CMppA4UU4gXrxheps4G1PcnABarAe0wsRTkhaWqHq7tMYx23ysdpiX9m3OJuK5jg= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273099493143.45814655572633; Sun, 10 Jan 2021 02:04:59 -0800 (PST) Received: from localhost ([::1]:57052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXak-00038H-5Z for importer@patchew.org; Sun, 10 Jan 2021 05:04:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYj-0001HY-3a for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:02:53 -0500 Received: from mailout03.t-online.de ([194.25.134.81]:56922) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYg-0005Hh-NW for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:02:52 -0500 Received: from fwd35.aul.t-online.de (fwd35.aul.t-online.de [172.20.27.145]) by mailout03.t-online.de (Postfix) with SMTP id 072F4421777D; Sun, 10 Jan 2021 11:02:49 +0100 (CET) Received: from linpower.localnet (VmketMZrwhoswgcPFZurWi59NS6tsuKxEQsjRzt296okXSPip21r9j9IsSiQfMUZvr@[93.236.152.29]) by fwd35.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYe-4KB5EW0; Sun, 10 Jan 2021 11:02:48 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E374D20062E; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 04/23] sdlaudio: don't start playback in init routine Date: Sun, 10 Jan 2021 11:02:20 +0100 Message-Id: <20210110100239.27588-4-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: VmketMZrwhoswgcPFZurWi59NS6tsuKxEQsjRzt296okXSPip21r9j9IsSiQfMUZvr X-TOI-EXPURGATEID: 150726::1610272968-0000E07B-F1A38D55/0/0 CLEAN NORMAL X-TOI-MSGID: 7891b11f-6b09-4441-b497-528b523efa94 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; Received-SPF: none client-ip=194.25.134.81; envelope-from=volker.ruemelin@t-online.de; helo=mailout03.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Every emulated audio device has a way to enable audio playback. Don't start playback until the guest enables the audio device. This patch keeps the SDL2 device pause state in sync with hw->enabled. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Thomas Huth Tested-by: Thomas Huth --- audio/sdlaudio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 431bfcfddd..68126a99ab 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -312,7 +312,6 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, =20 s->initialized =3D 1; s->exit =3D 0; - SDL_PauseAudio (0); return 0; } =20 --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273309; cv=none; d=zohomail.com; s=zohoarc; b=LrlB3c2Ji+D6Bvhus1jzMiGYApWLOLMlmeVQf/cFUBmImfQDlbStv6Qyr21Q1R75dmxqJJEbdfG1puZL0MZAkayFCNPO7cVkAuJe+zaSgkhyPHOEa7vlt9eLZDcSNRzO8nltoWaKMTpjQ0NEJ5tA9b6hdbhy4hV/RXcb097jNNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273309; 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=UpaF0XXEDxjBn5LhYM/eKvpHZzsEUWuXz7qTzCmMBZY=; b=ZCdjS5vFu50xwvhBwaljiXK/IwP5PWyRC4MVNfd+1zWU7Vw2J8iNqOiDtwSs1AHXzfpn6YEOJj3yndtyRmpMoOcBelKKau7CowwyhD6+/Hxr1ziS/CTs/3H9w/uNQCyvYy/CHZ1e+DXdaw1j1BhLOiO7NPH+9ZGhbwOfcGCS1N8= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273309625177.85680593906477; Sun, 10 Jan 2021 02:08:29 -0800 (PST) Received: from localhost ([::1]:37182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXe8-0006h4-7i for importer@patchew.org; Sun, 10 Jan 2021 05:08:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYl-0001MF-BJ for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:02:55 -0500 Received: from mailout12.t-online.de ([194.25.134.22]:40080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYj-0005JC-IT for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:02:55 -0500 Received: from fwd08.aul.t-online.de (fwd08.aul.t-online.de [172.20.26.151]) by mailout12.t-online.de (Postfix) with SMTP id CC79341F9695; Sun, 10 Jan 2021 11:02:51 +0100 (CET) Received: from linpower.localnet (bdeIpmZJZhMcYYo0UNJ3G5bCjY+afcMXevlJ4INqW2oZga-WHYEdbG3BWxp8AFuZAx@[93.236.152.29]) by fwd08.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYg-3qgj320; Sun, 10 Jan 2021 11:02:50 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E5A0820062F; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 05/23] sdlaudio: always clear the sample buffer Date: Sun, 10 Jan 2021 11:02:21 +0100 Message-Id: <20210110100239.27588-5-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: bdeIpmZJZhMcYYo0UNJ3G5bCjY+afcMXevlJ4INqW2oZga-WHYEdbG3BWxp8AFuZAx X-TOI-EXPURGATEID: 150726::1610272970-000072E4-E3B700D0/0/0 CLEAN NORMAL X-TOI-MSGID: 31d29c6c-8155-4a2a-bb6e-2fc7191aa9d2 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; Received-SPF: none client-ip=194.25.134.22; envelope-from=volker.ruemelin@t-online.de; helo=mailout12.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Always fill the remaining audio callback buffer with silence. SDL 2.0 doesn't initialize the audio callback buffer. This was an incompatible change compared to SDL 1.2. For reference read the SDL 1.2 to 2.0 migration guide. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Thomas Huth --- audio/sdlaudio.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 68126a99ab..79eed23849 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -211,27 +211,26 @@ static void sdl_callback (void *opaque, Uint8 *buf, i= nt len) SDLAudioState *s =3D &glob_sdl; HWVoiceOut *hw =3D &sdl->hw; =20 - if (s->exit) { - return; - } + if (!s->exit) { =20 - /* dolog("callback: len=3D%d avail=3D%zu\n", len, hw->pending_emul); */ + /* dolog("callback: len=3D%d avail=3D%zu\n", len, hw->pending_emul= ); */ =20 - while (hw->pending_emul && len) { - size_t write_len; - ssize_t start =3D ((ssize_t) hw->pos_emul) - hw->pending_emul; - if (start < 0) { - start +=3D hw->size_emul; - } - assert(start >=3D 0 && start < hw->size_emul); + while (hw->pending_emul && len) { + size_t write_len; + ssize_t start =3D (ssize_t)hw->pos_emul - hw->pending_emul; + if (start < 0) { + start +=3D hw->size_emul; + } + assert(start >=3D 0 && start < hw->size_emul); =20 - write_len =3D MIN(MIN(hw->pending_emul, len), - hw->size_emul - start); + write_len =3D MIN(MIN(hw->pending_emul, len), + hw->size_emul - start); =20 - memcpy(buf, hw->buf_emul + start, write_len); - hw->pending_emul -=3D write_len; - len -=3D write_len; - buf +=3D write_len; + memcpy(buf, hw->buf_emul + start, write_len); + hw->pending_emul -=3D write_len; + len -=3D write_len; + buf +=3D write_len; + } } =20 /* clear remaining buffer that we couldn't fill with data */ --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273104; cv=none; d=zohomail.com; s=zohoarc; b=Uhret/BKRTnYNxXdwI9Ld5pmXjY9VpHfRyyzlpfNUHUuLIfLV9iTl2k7wJTUXeE0YWUt7hyks+HV/Eh/OD2m9TL+gGrm5I85aLmEtujLPyWmkQW6yAEYLoQZpFOB/cADiEs0/sR61AkOFL7Df04IhV3iQIMwAtqrbjzxpLDpbaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273104; 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=tZwbsfBDz6F6SYtTA/Sr4scHD7VjO/Lnj1+olug/GMc=; b=nCr+8DfDW58Q3j97eacGffjd/RI0U9Un5OTm9nVkbyniHCrD+AQxGjM4bMFHANAY6Z9HMDKjReGhiZe9BCQ71HIxG6rMXo6ZvZ+rnVuDbsHCymwLHrGfd5oocHYWp/Q1jL8+nO3RdZ116uwrUvcuPabgCCufPvCX2EOU+V460jI= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273104119474.22530978593204; Sun, 10 Jan 2021 02:05:04 -0800 (PST) Received: from localhost ([::1]:57586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXao-0003Le-R9 for importer@patchew.org; Sun, 10 Jan 2021 05:05:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYp-0001TR-HH for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:00 -0500 Received: from mailout09.t-online.de ([194.25.134.84]:40272) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYm-0005KY-PY for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:02:59 -0500 Received: from fwd25.aul.t-online.de (fwd25.aul.t-online.de [172.20.26.130]) by mailout09.t-online.de (Postfix) with SMTP id 0F6D142B8C84; Sun, 10 Jan 2021 11:02:55 +0100 (CET) Received: from linpower.localnet (TtyMxMZOgh9YM6EchCbilY3HjO4cpubcuP+464FrA0qpDMKdEjOTddVtZxaKlFygaG@[93.236.152.29]) by fwd25.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYj-1nUmTw0; Sun, 10 Jan 2021 11:02:53 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E7CF3200630; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 06/23] sdlaudio: fill remaining sample buffer with silence Date: Sun, 10 Jan 2021 11:02:22 +0100 Message-Id: <20210110100239.27588-6-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: TtyMxMZOgh9YM6EchCbilY3HjO4cpubcuP+464FrA0qpDMKdEjOTddVtZxaKlFygaG X-TOI-EXPURGATEID: 150726::1610272973-00015F3A-8180E6F4/0/0 CLEAN NORMAL X-TOI-MSGID: 9d6dc805-0078-4051-adc2-7e7fc154eb03 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; Received-SPF: none client-ip=194.25.134.84; envelope-from=volker.ruemelin@t-online.de; helo=mailout09.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Fill the remaining sample buffer with silence. To fill it with zeroes is wrong for unsigned samples because this is silence with a DC bias. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Thomas Huth --- audio/sdlaudio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 79eed23849..01ae4c600e 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -235,7 +235,8 @@ static void sdl_callback (void *opaque, Uint8 *buf, int= len) =20 /* clear remaining buffer that we couldn't fill with data */ if (len) { - memset(buf, 0, len); + audio_pcm_info_clear_buf(&hw->info, buf, + len / hw->info.bytes_per_frame); } } =20 --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273326; cv=none; d=zohomail.com; s=zohoarc; b=YuVHtDGMknPxq8WLE0I7goFvUaPqjix0RC5wd/eyEFK3I4qi5NbKiXFkqQk8vqTlVHZmh1NFmI/n38ZLeUuxdBg+GWjSjhzHhNlojrnmDwjZfa2ZIh1arPWgJwoNKiSf5mRWMDQ5vYIQ5y8xztrXRzkwIrN44/aUrK7kp1BPAv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273326; 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=TZVqo+f5IDg/B740uOi7dbMGytyuzU1/bKuozhOgj9U=; b=RIkof+U9X198xtV/5wURPGaT57xKD6eY5bSsf/N/VVQn+MxRy7VvdsBummMoW4/35ZBZOTWxDvV9kE6EWIRG/pOdqhNSEv8fW8X6Ab+MHugCqpWs3QanQwJbHsT0lEwJ7Wd+C9noZZIlCaiuApEO208/HKVAnGmGzr1S3Dmi2Vs= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273326118319.6444978971314; Sun, 10 Jan 2021 02:08:46 -0800 (PST) Received: from localhost ([::1]:37406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXeO-0006on-TU for importer@patchew.org; Sun, 10 Jan 2021 05:08:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYr-0001VT-DL for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:01 -0500 Received: from mailout07.t-online.de ([194.25.134.83]:59598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYp-0005Lt-2s for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:01 -0500 Received: from fwd23.aul.t-online.de (fwd23.aul.t-online.de [172.20.26.128]) by mailout07.t-online.de (Postfix) with SMTP id 0C5AA4247837; Sun, 10 Jan 2021 11:02:57 +0100 (CET) Received: from linpower.localnet (T5t2MiZBghFEvzwSUpQxdi9SERm6HEmwO7HHWODV6EjD0UvsWQEawFcWlzcE3H0w9a@[93.236.152.29]) by fwd23.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYl-0H7hpY0; Sun, 10 Jan 2021 11:02:55 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id EA2D4200631; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 07/23] sdlaudio: replace legacy functions with modern ones Date: Sun, 10 Jan 2021 11:02:23 +0100 Message-Id: <20210110100239.27588-7-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: T5t2MiZBghFEvzwSUpQxdi9SERm6HEmwO7HHWODV6EjD0UvsWQEawFcWlzcE3H0w9a X-TOI-EXPURGATEID: 150726::1610272976-00017F06-29458977/0/0 CLEAN NORMAL X-TOI-MSGID: e212f7f5-b999-43c4-a68b-8b005ccbeb71 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; Received-SPF: none client-ip=194.25.134.83; envelope-from=volker.ruemelin@t-online.de; helo=mailout07.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" With the modern audio functions it's possible to add new features like audio recording. As a side effect this patch fixes a bug where SDL2 can't be used on Windows. This bug was reported on the qemu-devel mailing list at https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg04043.html Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Thomas Huth --- audio/sdlaudio.c | 107 ++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 57 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 01ae4c600e..47968c5020 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -41,15 +41,11 @@ =20 typedef struct SDLVoiceOut { HWVoiceOut hw; -} SDLVoiceOut; - -static struct SDLAudioState { int exit; int initialized; - bool driver_created; Audiodev *dev; -} glob_sdl; -typedef struct SDLAudioState SDLAudioState; + SDL_AudioDeviceID devid; +} SDLVoiceOut; =20 static void GCC_FMT_ATTR (1, 2) sdl_logerr (const char *fmt, ...) { @@ -155,9 +151,10 @@ static int sdl_to_audfmt(int sdlfmt, AudioFormat *fmt,= int *endianness) return 0; } =20 -static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpec *obt) +static SDL_AudioDeviceID sdl_open(SDL_AudioSpec *req, SDL_AudioSpec *obt, + int rec) { - int status; + SDL_AudioDeviceID devid; #ifndef _WIN32 int err; sigset_t new, old; @@ -166,18 +163,19 @@ static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpe= c *obt) err =3D sigfillset (&new); if (err) { dolog ("sdl_open: sigfillset failed: %s\n", strerror (errno)); - return -1; + return 0; } err =3D pthread_sigmask (SIG_BLOCK, &new, &old); if (err) { dolog ("sdl_open: pthread_sigmask failed: %s\n", strerror (err)); - return -1; + return 0; } #endif =20 - status =3D SDL_OpenAudio (req, obt); - if (status) { - sdl_logerr ("SDL_OpenAudio failed\n"); + devid =3D SDL_OpenAudioDevice(NULL, rec, req, obt, 0); + if (!devid) { + sdl_logerr("SDL_OpenAudioDevice for %s failed\n", + rec ? "recording" : "playback"); } =20 #ifndef _WIN32 @@ -190,30 +188,32 @@ static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpe= c *obt) exit (EXIT_FAILURE); } #endif - return status; + return devid; } =20 -static void sdl_close (SDLAudioState *s) +static void sdl_close_out(SDLVoiceOut *sdl) { - if (s->initialized) { - SDL_LockAudio(); - s->exit =3D 1; - SDL_UnlockAudio(); - SDL_PauseAudio (1); - SDL_CloseAudio (); - s->initialized =3D 0; + if (sdl->initialized) { + SDL_LockAudioDevice(sdl->devid); + sdl->exit =3D 1; + SDL_UnlockAudioDevice(sdl->devid); + SDL_PauseAudioDevice(sdl->devid, 1); + sdl->initialized =3D 0; + } + if (sdl->devid) { + SDL_CloseAudioDevice(sdl->devid); + sdl->devid =3D 0; } } =20 -static void sdl_callback (void *opaque, Uint8 *buf, int len) +static void sdl_callback_out(void *opaque, Uint8 *buf, int len) { SDLVoiceOut *sdl =3D opaque; - SDLAudioState *s =3D &glob_sdl; HWVoiceOut *hw =3D &sdl->hw; =20 - if (!s->exit) { + if (!sdl->exit) { =20 - /* dolog("callback: len=3D%d avail=3D%zu\n", len, hw->pending_emul= ); */ + /* dolog("callback_out: len=3D%d avail=3D%zu\n", len, hw->pending_= emul); */ =20 while (hw->pending_emul && len) { size_t write_len; @@ -240,43 +240,44 @@ static void sdl_callback (void *opaque, Uint8 *buf, i= nt len) } } =20 -#define SDL_WRAPPER_FUNC(name, ret_type, args_decl, args) \ +#define SDL_WRAPPER_FUNC(name, ret_type, args_decl, args, dir) \ static ret_type glue(sdl_, name)args_decl \ { \ ret_type ret; \ + glue(SDLVoice, dir) *sdl =3D (glue(SDLVoice, dir) *)hw; \ \ - SDL_LockAudio(); \ + SDL_LockAudioDevice(sdl->devid); \ ret =3D glue(audio_generic_, name)args; \ - SDL_UnlockAudio(); \ + SDL_UnlockAudioDevice(sdl->devid); \ \ return ret; \ } =20 SDL_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), - (hw, size)) + (hw, size), Out) SDL_WRAPPER_FUNC(put_buffer_out, size_t, - (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size)) + (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size)= , Out) SDL_WRAPPER_FUNC(write, size_t, - (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size)) + (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size)= , Out) #undef SDL_WRAPPER_FUNC =20 -static void sdl_fini_out (HWVoiceOut *hw) +static void sdl_fini_out(HWVoiceOut *hw) { - (void) hw; + SDLVoiceOut *sdl =3D (SDLVoiceOut *)hw; =20 - sdl_close (&glob_sdl); + sdl_close_out(sdl); } =20 static int sdl_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) { - SDLVoiceOut *sdl =3D (SDLVoiceOut *) hw; - SDLAudioState *s =3D &glob_sdl; + SDLVoiceOut *sdl =3D (SDLVoiceOut *)hw; SDL_AudioSpec req, obt; int endianness; int err; AudioFormat effective_fmt; - AudiodevSdlPerDirectionOptions *spdo =3D s->dev->u.sdl.out; + Audiodev *dev =3D drv_opaque; + AudiodevSdlPerDirectionOptions *spdo =3D dev->u.sdl.out; struct audsettings obt_as; =20 req.freq =3D as->freq; @@ -288,16 +289,18 @@ static int sdl_init_out(HWVoiceOut *hw, struct audset= tings *as, */ req.samples =3D audio_buffer_samples( qapi_AudiodevSdlPerDirectionOptions_base(spdo), as, 11610); - req.callback =3D sdl_callback; + req.callback =3D sdl_callback_out; req.userdata =3D sdl; =20 - if (sdl_open (&req, &obt)) { + sdl->dev =3D dev; + sdl->devid =3D sdl_open(&req, &obt, 0); + if (!sdl->devid) { return -1; } =20 err =3D sdl_to_audfmt(obt.format, &effective_fmt, &endianness); if (err) { - sdl_close (s); + sdl_close_out(sdl); return -1; } =20 @@ -310,41 +313,31 @@ static int sdl_init_out(HWVoiceOut *hw, struct audset= tings *as, hw->samples =3D (spdo->has_buffer_count ? spdo->buffer_count : 4) * obt.samples; =20 - s->initialized =3D 1; - s->exit =3D 0; + sdl->initialized =3D 1; + sdl->exit =3D 0; return 0; } =20 static void sdl_enable_out(HWVoiceOut *hw, bool enable) { - SDL_PauseAudio(!enable); + SDLVoiceOut *sdl =3D (SDLVoiceOut *)hw; + + SDL_PauseAudioDevice(sdl->devid, !enable); } =20 static void *sdl_audio_init(Audiodev *dev) { - SDLAudioState *s =3D &glob_sdl; - if (s->driver_created) { - sdl_logerr("Can't create multiple sdl backends\n"); - return NULL; - } - if (SDL_InitSubSystem (SDL_INIT_AUDIO)) { sdl_logerr ("SDL failed to initialize audio subsystem\n"); return NULL; } =20 - s->driver_created =3D true; - s->dev =3D dev; - return s; + return dev; } =20 static void sdl_audio_fini (void *opaque) { - SDLAudioState *s =3D opaque; - sdl_close (s); SDL_QuitSubSystem (SDL_INIT_AUDIO); - s->driver_created =3D false; - s->dev =3D NULL; } =20 static struct audio_pcm_ops sdl_pcm_ops =3D { --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273517; cv=none; d=zohomail.com; s=zohoarc; b=G+qmF52ddRIDkEYi/JIr5aSXY2xPAnHiHcY+lLTVUAPYYEk+ZveJzsZC2EXFbVEvxABQ4AcH+WJvSK0aj8Z5g6mwlrrZF1ws6RhjlKpP2gumhuNSyH5/XMbsPFQFP0jfLRe2S3u4OEjNzHuh2I2HeyahC5bS2f4te+P7AsWqalY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273517; 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=kqL3Rp/QEl4d9zQxLDC9ax/0LaFqh2YF5B88TbgETHw=; b=FVmByxKU1glI1oAX1no1BgiAUN/44RDd9OYAM+E3hMcC04ZqTUj1mRb0m80YmB9x7wF3Wag0iFfI8QonMM8KUd9AP4VLSr7312DLK+V1sSTaIfgH9yvRUvq/AedbEaU4WBHoQ02oaBEPy/c+rBPutRMSSYoEnjUbJ3cu320FojI= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273517366699.7558355698538; Sun, 10 Jan 2021 02:11:57 -0800 (PST) Received: from localhost ([::1]:45006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXhT-0001kv-3d for importer@patchew.org; Sun, 10 Jan 2021 05:11:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYy-0001eF-Fi for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:09 -0500 Received: from mailout05.t-online.de ([194.25.134.82]:42452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYv-0005Nx-Jn for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:08 -0500 Received: from fwd02.aul.t-online.de (fwd02.aul.t-online.de [172.20.26.148]) by mailout05.t-online.de (Postfix) with SMTP id C1C8F42030A9; Sun, 10 Jan 2021 11:03:03 +0100 (CET) Received: from linpower.localnet (S+XvpwZJQhn0wpPsj8C6QVk4zdB7+SGXuP+JxvfgEkHo0Y2apZkzGQeOAslIsJ6g5D@[93.236.152.29]) by fwd02.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYo-0oGNGa0; Sun, 10 Jan 2021 11:02:58 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id EC5FE200632; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 08/23] audio: split pcm_ops function get_buffer_in Date: Sun, 10 Jan 2021 11:02:24 +0100 Message-Id: <20210110100239.27588-8-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: S+XvpwZJQhn0wpPsj8C6QVk4zdB7+SGXuP+JxvfgEkHo0Y2apZkzGQeOAslIsJ6g5D X-TOI-EXPURGATEID: 150726::1610272978-0000F958-3D93CCA5/0/0 CLEAN NORMAL X-TOI-MSGID: dcba654d-95cf-469e-bb85-3dbe2e9c8345 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; Received-SPF: none client-ip=194.25.134.82; envelope-from=volker.ruemelin@t-online.de; helo=mailout05.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Split off pcm_ops function run_buffer_in from get_buffer_in and call run_buffer_in before get_buffer_in. The next patch only needs the generic buffer management part from audio_generic_get_buffer_in(). Signed-off-by: Volker R=C3=BCmelin --- audio/alsaaudio.c | 1 + audio/audio.c | 18 ++++++++++++++---- audio/audio_int.h | 2 ++ audio/jackaudio.c | 1 + audio/noaudio.c | 1 + audio/ossaudio.c | 1 + audio/spiceaudio.c | 1 + 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 6787e91bc1..5a871aaf6b 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -929,6 +929,7 @@ static struct audio_pcm_ops alsa_pcm_ops =3D { .init_in =3D alsa_init_in, .fini_in =3D alsa_fini_in, .read =3D alsa_read, + .run_buffer_in =3D audio_generic_run_buffer_in, .enable_in =3D alsa_enable_in, }; =20 diff --git a/audio/audio.c b/audio/audio.c index d048d26283..480b3cce1f 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1241,6 +1241,10 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, siz= e_t samples) size_t conv =3D 0; STSampleBuffer *conv_buf =3D hw->conv_buf; =20 + if (hw->pcm_ops->run_buffer_in) { + hw->pcm_ops->run_buffer_in(hw); + } + while (samples) { size_t proc; size_t size =3D samples * hw->info.bytes_per_frame; @@ -1381,10 +1385,8 @@ void audio_run(AudioState *s, const char *msg) #endif } =20 -void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size) +void audio_generic_run_buffer_in(HWVoiceIn *hw) { - ssize_t start; - if (unlikely(!hw->buf_emul)) { size_t calc_size =3D hw->conv_buf->size * hw->info.bytes_per_frame; hw->buf_emul =3D g_malloc(calc_size); @@ -1403,8 +1405,12 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, siz= e_t *size) break; } } +} + +void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size) +{ + ssize_t start =3D (ssize_t)hw->pos_emul - hw->pending_emul; =20 - start =3D ((ssize_t) hw->pos_emul) - hw->pending_emul; if (start < 0) { start +=3D hw->size_emul; } @@ -1505,6 +1511,10 @@ size_t audio_generic_read(HWVoiceIn *hw, void *buf, = size_t size) { size_t total =3D 0; =20 + if (hw->pcm_ops->run_buffer_in) { + hw->pcm_ops->run_buffer_in(hw); + } + while (total < size) { size_t src_size =3D size - total; void *src =3D hw->pcm_ops->get_buffer_in(hw, &src_size); diff --git a/audio/audio_int.h b/audio/audio_int.h index 4775857bf2..06f0913835 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -172,12 +172,14 @@ struct audio_pcm_ops { int (*init_in) (HWVoiceIn *hw, audsettings *as, void *drv_opaque); void (*fini_in) (HWVoiceIn *hw); size_t (*read) (HWVoiceIn *hw, void *buf, size_t size); + void (*run_buffer_in)(HWVoiceIn *hw); void *(*get_buffer_in)(HWVoiceIn *hw, size_t *size); void (*put_buffer_in)(HWVoiceIn *hw, void *buf, size_t size); void (*enable_in)(HWVoiceIn *hw, bool enable); void (*volume_in)(HWVoiceIn *hw, Volume *vol); }; =20 +void audio_generic_run_buffer_in(HWVoiceIn *hw); 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); diff --git a/audio/jackaudio.c b/audio/jackaudio.c index 3b7c18443d..f8afb5cc31 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -657,6 +657,7 @@ static struct audio_pcm_ops jack_pcm_ops =3D { .init_in =3D qjack_init_in, .fini_in =3D qjack_fini_in, .read =3D qjack_read, + .run_buffer_in =3D audio_generic_run_buffer_in, .enable_in =3D qjack_enable_in }; =20 diff --git a/audio/noaudio.c b/audio/noaudio.c index 05798ea210..aac87dbc93 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -124,6 +124,7 @@ static struct audio_pcm_ops no_pcm_ops =3D { .init_in =3D no_init_in, .fini_in =3D no_fini_in, .read =3D no_read, + .run_buffer_in =3D audio_generic_run_buffer_in, .enable_in =3D no_enable_in }; =20 diff --git a/audio/ossaudio.c b/audio/ossaudio.c index a7dcaa31ad..c1db89f233 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -762,6 +762,7 @@ static struct audio_pcm_ops oss_pcm_ops =3D { .init_in =3D oss_init_in, .fini_in =3D oss_fini_in, .read =3D oss_read, + .run_buffer_in =3D audio_generic_run_buffer_in, .enable_in =3D oss_enable_in }; =20 diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 8967cca129..999bfbde47 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -293,6 +293,7 @@ static struct audio_pcm_ops audio_callbacks =3D { .init_in =3D line_in_init, .fini_in =3D line_in_fini, .read =3D line_in_read, + .run_buffer_in =3D audio_generic_run_buffer_in, .enable_in =3D line_in_enable, #if ((SPICE_INTERFACE_RECORD_MAJOR >=3D 2) && (SPICE_INTERFACE_RECORD_MINO= R >=3D 2)) .volume_in =3D line_in_volume, --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273524; cv=none; d=zohomail.com; s=zohoarc; b=UeUxy638GOIc1ydmVT/l0agk6CiSEa906HShqkS0A+QsbQl2qRWmOGffCAmg9TeTrDQZe5nh7MHcupnLFj1U5r65YVXanHLOvG0W8YLxP16wEu57IjQfbWzCPog1umQdCJcMlHCx6AFCASD8UEdxbR540eWRJmU3ssvQXPMZsxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273524; 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=RNUeyDVW8hKywZ3jSZdI/yKKC0dUfrX6/P3I1goV8Kw=; b=aFs3OLfnJna9ADnRjhxjWUgRZBo1eNbrCONxqw74xlL/8h06VlzRMRQpkhhAQX/B9Jgk2XXIV1aXfkKXDPfsaImIZJZJ71KDwTfZL1m+b7l50x47FmbvnUh6lDpv79UDbEmwvsk5ie6w9YK9vmzgwkpC26jW5YUxGqIyL+wMd2Q= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273524860365.56221477705355; Sun, 10 Jan 2021 02:12:04 -0800 (PST) Received: from localhost ([::1]:45782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXhb-00029E-Iv for importer@patchew.org; Sun, 10 Jan 2021 05:12:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYy-0001eO-HM for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:09 -0500 Received: from mailout02.t-online.de ([194.25.134.17]:47530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYw-0005OX-6t for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:08 -0500 Received: from fwd24.aul.t-online.de (fwd24.aul.t-online.de [172.20.26.129]) by mailout02.t-online.de (Postfix) with SMTP id 4DFCA41E6F16; Sun, 10 Jan 2021 11:03:04 +0100 (CET) Received: from linpower.localnet (TlWkeiZEohU29xyeIn2SauYaNY4ilCVq2kijrcTGwRmiLgJCC4d2tVCiw6x0lpRZvu@[93.236.152.29]) by fwd24.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYr-4Omn320; Sun, 10 Jan 2021 11:03:01 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id EE9E8200633; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 09/23] sdlaudio: add recording functions Date: Sun, 10 Jan 2021 11:02:25 +0100 Message-Id: <20210110100239.27588-9-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: TlWkeiZEohU29xyeIn2SauYaNY4ilCVq2kijrcTGwRmiLgJCC4d2tVCiw6x0lpRZvu X-TOI-EXPURGATEID: 150726::1610272981-00005513-6D7F08C5/0/0 CLEAN NORMAL X-TOI-MSGID: 3296169b-f124-4822-99a7-22f125d5dbbb 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; Received-SPF: none client-ip=194.25.134.17; envelope-from=volker.ruemelin@t-online.de; helo=mailout02.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Add audio recording functions. SDL 2.0.5 or later is required to use the recording functions. Playback continues to work with earlier SDL 2.0 versions. Signed-off-by: Volker R=C3=BCmelin --- audio/sdlaudio.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 139 insertions(+), 3 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 47968c5020..445cae8de5 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -47,6 +47,14 @@ typedef struct SDLVoiceOut { SDL_AudioDeviceID devid; } SDLVoiceOut; =20 +typedef struct SDLVoiceIn { + HWVoiceIn hw; + int exit; + int initialized; + Audiodev *dev; + SDL_AudioDeviceID devid; +} SDLVoiceIn; + static void GCC_FMT_ATTR (1, 2) sdl_logerr (const char *fmt, ...) { va_list ap; @@ -240,6 +248,45 @@ static void sdl_callback_out(void *opaque, Uint8 *buf,= int len) } } =20 +static void sdl_close_in(SDLVoiceIn *sdl) +{ + if (sdl->initialized) { + SDL_LockAudioDevice(sdl->devid); + sdl->exit =3D 1; + SDL_UnlockAudioDevice(sdl->devid); + SDL_PauseAudioDevice(sdl->devid, 1); + sdl->initialized =3D 0; + } + if (sdl->devid) { + SDL_CloseAudioDevice(sdl->devid); + sdl->devid =3D 0; + } +} + +static void sdl_callback_in(void *opaque, Uint8 *buf, int len) +{ + SDLVoiceIn *sdl =3D opaque; + HWVoiceIn *hw =3D &sdl->hw; + + if (sdl->exit) { + return; + } + + /* dolog("callback_in: len=3D%d pending=3D%zu\n", len, hw->pending_emu= l); */ + + while (hw->pending_emul < hw->size_emul && len) { + size_t read_len =3D MIN(len, MIN(hw->size_emul - hw->pos_emul, + hw->size_emul - hw->pending_emul)); + + memcpy(hw->buf_emul + hw->pos_emul, buf, read_len); + + hw->pending_emul +=3D read_len; + hw->pos_emul =3D (hw->pos_emul + read_len) % hw->size_emul; + len -=3D read_len; + buf +=3D read_len; + } +} + #define SDL_WRAPPER_FUNC(name, ret_type, args_decl, args, dir) \ static ret_type glue(sdl_, name)args_decl \ { \ @@ -253,13 +300,30 @@ static void sdl_callback_out(void *opaque, Uint8 *buf= , int len) return ret; \ } =20 +#define SDL_WRAPPER_VOID_FUNC(name, args_decl, args, dir) \ + static void glue(sdl_, name)args_decl \ + { \ + glue(SDLVoice, dir) *sdl =3D (glue(SDLVoice, dir) *)hw; \ + \ + SDL_LockAudioDevice(sdl->devid); \ + glue(audio_generic_, name)args; \ + SDL_UnlockAudioDevice(sdl->devid); \ + } + SDL_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), (hw, size), Out) SDL_WRAPPER_FUNC(put_buffer_out, size_t, (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size)= , Out) SDL_WRAPPER_FUNC(write, size_t, (HWVoiceOut *hw, void *buf, size_t size), (hw, buf, size)= , Out) +SDL_WRAPPER_FUNC(read, size_t, (HWVoiceIn *hw, void *buf, size_t size), + (hw, buf, size), In) +SDL_WRAPPER_FUNC(get_buffer_in, void *, (HWVoiceIn *hw, size_t *size), + (hw, size), In) +SDL_WRAPPER_VOID_FUNC(put_buffer_in, (HWVoiceIn *hw, void *buf, size_t siz= e), + (hw, buf, size), In) #undef SDL_WRAPPER_FUNC +#undef SDL_WRAPPER_VOID_FUNC =20 static void sdl_fini_out(HWVoiceOut *hw) { @@ -325,6 +389,69 @@ static void sdl_enable_out(HWVoiceOut *hw, bool enable) SDL_PauseAudioDevice(sdl->devid, !enable); } =20 +static void sdl_fini_in(HWVoiceIn *hw) +{ + SDLVoiceIn *sdl =3D (SDLVoiceIn *)hw; + + sdl_close_in(sdl); +} + +static int sdl_init_in(HWVoiceIn *hw, audsettings *as, void *drv_opaque) +{ + SDLVoiceIn *sdl =3D (SDLVoiceIn *)hw; + SDL_AudioSpec req, obt; + int endianness; + int err; + AudioFormat effective_fmt; + Audiodev *dev =3D drv_opaque; + AudiodevSdlPerDirectionOptions *spdo =3D dev->u.sdl.in; + struct audsettings obt_as; + + req.freq =3D as->freq; + req.format =3D aud_to_sdlfmt(as->fmt); + req.channels =3D as->nchannels; + /* SDL samples are QEMU frames */ + req.samples =3D audio_buffer_frames( + qapi_AudiodevSdlPerDirectionOptions_base(spdo), as, 11610); + req.callback =3D sdl_callback_in; + req.userdata =3D sdl; + + sdl->dev =3D dev; + sdl->devid =3D sdl_open(&req, &obt, 1); + if (!sdl->devid) { + return -1; + } + + err =3D sdl_to_audfmt(obt.format, &effective_fmt, &endianness); + if (err) { + sdl_close_in(sdl); + return -1; + } + + obt_as.freq =3D obt.freq; + obt_as.nchannels =3D obt.channels; + obt_as.fmt =3D effective_fmt; + obt_as.endianness =3D endianness; + + audio_pcm_init_info(&hw->info, &obt_as); + hw->samples =3D (spdo->has_buffer_count ? spdo->buffer_count : 4) * + obt.samples; + hw->size_emul =3D hw->samples * hw->info.bytes_per_frame; + hw->buf_emul =3D g_malloc(hw->size_emul); + hw->pos_emul =3D hw->pending_emul =3D 0; + + sdl->initialized =3D 1; + sdl->exit =3D 0; + return 0; +} + +static void sdl_enable_in(HWVoiceIn *hw, bool enable) +{ + SDLVoiceIn *sdl =3D (SDLVoiceIn *)hw; + + SDL_PauseAudioDevice(sdl->devid, !enable); +} + static void *sdl_audio_init(Audiodev *dev) { if (SDL_InitSubSystem (SDL_INIT_AUDIO)) { @@ -350,6 +477,15 @@ static struct audio_pcm_ops sdl_pcm_ops =3D { /* wrapper for audio_generic_put_buffer_out */ .put_buffer_out =3D sdl_put_buffer_out, .enable_out =3D sdl_enable_out, + .init_in =3D sdl_init_in, + .fini_in =3D sdl_fini_in, + /* wrapper for audio_generic_read */ + .read =3D sdl_read, + /* wrapper for audio_generic_get_buffer_in */ + .get_buffer_in =3D sdl_get_buffer_in, + /* wrapper for audio_generic_put_buffer_in */ + .put_buffer_in =3D sdl_put_buffer_in, + .enable_in =3D sdl_enable_in, }; =20 static struct audio_driver sdl_audio_driver =3D { @@ -360,9 +496,9 @@ static struct audio_driver sdl_audio_driver =3D { .pcm_ops =3D &sdl_pcm_ops, .can_be_default =3D 1, .max_voices_out =3D 1, - .max_voices_in =3D 0, - .voice_size_out =3D sizeof (SDLVoiceOut), - .voice_size_in =3D 0 + .max_voices_in =3D 1, + .voice_size_out =3D sizeof(SDLVoiceOut), + .voice_size_in =3D sizeof(SDLVoiceIn), }; =20 static void register_audio_sdl(void) --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273299; cv=none; d=zohomail.com; s=zohoarc; b=lZmGEYx9m+DhaF3FQ6rWz2okuYv/6kJYpHJkE34DQ0xplfWAKBxeoM4HzPBJTy1QMf/s4F/cxCtzSI72SM9H9rmD1NGXZTPtc0pi3nqSXKvpa4nrXza3HOJmp4juG48jVCYeD6Yc7IUApLC0FLxE0Fp+ZLwwpxOSfAEhJzI69NQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273299; 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=B9YenUCYfgpvPKP57DcSgtfRBqCO5tgI4R2ieuMRqKY=; b=DyO3Mf36IrohTctu3vjrxBTJrP4TSfKsN1mt0qSBnqR3liFoOBf9v5kXG4BWj2Vp7/miEqq1gvs3/T33rfynEQlC+k/C/m9A6gi3NBoKi5pz3O601AuUyVQWZsvEqiLx8UpoOsGW3XVNYIqUwC/36DorM6Wv+IiEhoUEwJ2S6ok= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273299876804.9482520402902; Sun, 10 Jan 2021 02:08:19 -0800 (PST) Received: from localhost ([::1]:36700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXdy-0006Ul-2q for importer@patchew.org; Sun, 10 Jan 2021 05:08:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYx-0001d3-Ok for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:07 -0500 Received: from mailout03.t-online.de ([194.25.134.81]:57036) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXYv-0005Ny-4S for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:06 -0500 Received: from fwd39.aul.t-online.de (fwd39.aul.t-online.de [172.20.27.138]) by mailout03.t-online.de (Postfix) with SMTP id 075C74217779; Sun, 10 Jan 2021 11:03:04 +0100 (CET) Received: from linpower.localnet (EPZUScZHghU5OdQsaS4N+3zlg2g4BU+7+KzhIpjklF9B3+2ETWR+xHi7rAvhhevZXJ@[93.236.152.29]) by fwd39.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYt-2DO80G0; Sun, 10 Jan 2021 11:03:03 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id F0E9C200637; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 10/23] audio: break generic buffer dependency on mixing-engine Date: Sun, 10 Jan 2021 11:02:26 +0100 Message-Id: <20210110100239.27588-10-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: EPZUScZHghU5OdQsaS4N+3zlg2g4BU+7+KzhIpjklF9B3+2ETWR+xHi7rAvhhevZXJ X-TOI-EXPURGATEID: 150726::1610272983-00000BD0-AC32E848/0/0 CLEAN NORMAL X-TOI-MSGID: 678f67c7-0fee-488e-99c9-26f0ae5f0329 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; Received-SPF: none client-ip=194.25.134.81; envelope-from=volker.ruemelin@t-online.de; helo=mailout03.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Break the unnecessary dependency of the generic buffer management code on mixing-engine. This is required for the next patch. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 480b3cce1f..22d769db0c 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1388,9 +1388,8 @@ void audio_run(AudioState *s, const char *msg) void audio_generic_run_buffer_in(HWVoiceIn *hw) { if (unlikely(!hw->buf_emul)) { - size_t calc_size =3D hw->conv_buf->size * hw->info.bytes_per_frame; - hw->buf_emul =3D g_malloc(calc_size); - hw->size_emul =3D calc_size; + hw->size_emul =3D hw->samples * hw->info.bytes_per_frame; + hw->buf_emul =3D g_malloc(hw->size_emul); hw->pos_emul =3D hw->pending_emul =3D 0; } =20 @@ -1452,10 +1451,8 @@ void audio_generic_run_buffer_out(HWVoiceOut *hw) void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size) { if (unlikely(!hw->buf_emul)) { - size_t calc_size =3D hw->mix_buf->size * hw->info.bytes_per_frame; - - hw->buf_emul =3D g_malloc(calc_size); - hw->size_emul =3D calc_size; + hw->size_emul =3D hw->samples * hw->info.bytes_per_frame; + hw->buf_emul =3D g_malloc(hw->size_emul); hw->pos_emul =3D hw->pending_emul =3D 0; } =20 --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273535; cv=none; d=zohomail.com; s=zohoarc; b=GiQx1RKiWBJK7/A4FHepuMX1K4GNl+io4jZoRJ08nFuyUBqdnjVKc6Gmc/3rCLlfLuNEjvGtY3LJYgOvy7JyC2s8WHle5gUKApkNsDMCd43qgDlWxog9PrV+TXefw+16D06hu2iW+NfUPW4BMQA2+Jdiy+wmorbJszHk4lXyH34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273535; 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=I6a7e7XV80yDg+awUWPc5JdIYLNEXHF2NarfeC2vEtc=; b=ljNZNKQ3J5M3laetla8jbo8lI8JTIigg5BWtFYrfXevX04DWRE9cYJT/GHUn6KHnTalMtZB9ckpWJj1fjNsbYNYp12d8ZxEBYbj64XPxHxm9ebn6UAtT6sQLTb1tnKkxyQ9zNSR3NR6ghml1e7KtClAPVo/0q5DYMAMfJ0RwxWk= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273535768800.9070585955965; Sun, 10 Jan 2021 02:12:15 -0800 (PST) Received: from localhost ([::1]:46216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXhm-0002KO-Hg for importer@patchew.org; Sun, 10 Jan 2021 05:12:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZ5-0001nB-CA for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:15 -0500 Received: from mailout04.t-online.de ([194.25.134.18]:54870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZ1-0005Qd-Er for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:15 -0500 Received: from fwd15.aul.t-online.de (fwd15.aul.t-online.de [172.20.27.63]) by mailout04.t-online.de (Postfix) with SMTP id A488841882AC; Sun, 10 Jan 2021 11:03:09 +0100 (CET) Received: from linpower.localnet (Th3+qYZlrhGAagdA7KJDS8oYS3kQM5qVnzTCCsCF4lY4zsBbtEOr3126d5XCFcMZvM@[93.236.152.29]) by fwd15.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYw-1u8ynI0; Sun, 10 Jan 2021 11:03:06 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id F303C200638; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 11/23] sdlaudio: enable (in|out).mixing-engine=off Date: Sun, 10 Jan 2021 11:02:27 +0100 Message-Id: <20210110100239.27588-11-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: Th3+qYZlrhGAagdA7KJDS8oYS3kQM5qVnzTCCsCF4lY4zsBbtEOr3126d5XCFcMZvM X-TOI-EXPURGATEID: 150726::1610272986-0000E7A1-57FCDB25/0/0 CLEAN NORMAL X-TOI-MSGID: 6fe58f68-43bf-4757-ad0d-5018d3940918 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; Received-SPF: none client-ip=194.25.134.18; envelope-from=volker.ruemelin@t-online.de; helo=mailout04.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Enable the SDL2 backend options -audiodev sdl,out.mixing- engine=3Doff,in.mixing-engine=3Doff. Signed-off-by: Volker R=C3=BCmelin --- audio/sdlaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 445cae8de5..c68c62a3e4 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -495,8 +495,8 @@ static struct audio_driver sdl_audio_driver =3D { .fini =3D sdl_audio_fini, .pcm_ops =3D &sdl_pcm_ops, .can_be_default =3D 1, - .max_voices_out =3D 1, - .max_voices_in =3D 1, + .max_voices_out =3D INT_MAX, + .max_voices_in =3D INT_MAX, .voice_size_out =3D sizeof(SDLVoiceOut), .voice_size_in =3D sizeof(SDLVoiceIn), }; --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273674; cv=none; d=zohomail.com; s=zohoarc; b=AHbpZWTu7vABFWvvA23uq4pMOhJDbAlkCYL12kp0PK0knlQXgvfBreTPF191MCp0TCktqnl0kBsTfRjRKDDeZB+LPN1RKy2jzWNavg/dOcGRzpvqSg0Zc0wIzXtxll9OZwm/nfSwLmYYRUMbHk8+BNoA032C0FJCkKwSoDUapJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273674; 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=lcD/xCuBjAmIgf9h1rw9FkcaMgJ59TdlX6BDOjSOabk=; b=Y3BedU4QCwjBSECPPdcMpzXuOznv4QAy52VD1Bw+Pgkqzpxa+KlJNfwARKII+hdEAgmiE1nTUGWQ2SQfKpFbfx2CKGja2XSHGcwH4izbrP6rWopgUn5qLx+0Hx3UnGGyBrjvAKBsLPyyusD3+kt67nlKgvrXJZtp3lTxyHPQeAU= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161027367428329.228262532175904; Sun, 10 Jan 2021 02:14:34 -0800 (PST) Received: from localhost ([::1]:57122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXk0-0006v9-Vk for importer@patchew.org; Sun, 10 Jan 2021 05:14:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZC-00027r-Nq for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:22 -0500 Received: from mailout07.t-online.de ([194.25.134.83]:59858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZA-0005Wl-Mj for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:22 -0500 Received: from fwd19.aul.t-online.de (fwd19.aul.t-online.de [172.20.27.65]) by mailout07.t-online.de (Postfix) with SMTP id 7234D42DAAD1; Sun, 10 Jan 2021 11:03:19 +0100 (CET) Received: from linpower.localnet (EX69uYZrrhX73Qye7hJAYo+vBEbH4cFar-iPZOKHspH9B5DdyWparAiHPKR7JIqwFZ@[93.236.152.29]) by fwd19.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXYy-4AWRlI0; Sun, 10 Jan 2021 11:03:08 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 00E7F20063A; Sun, 10 Jan 2021 11:02:39 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 12/23] audio: remove remaining unused plive code Date: Sun, 10 Jan 2021 11:02:28 +0100 Message-Id: <20210110100239.27588-12-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: EX69uYZrrhX73Qye7hJAYo+vBEbH4cFar-iPZOKHspH9B5DdyWparAiHPKR7JIqwFZ X-TOI-EXPURGATEID: 150726::1610272989-00008954-54B0D0A2/0/0 CLEAN NORMAL X-TOI-MSGID: d60598f8-040c-4e4f-b808-548f0e079ba3 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; Received-SPF: none client-ip=194.25.134.83; envelope-from=volker.ruemelin@t-online.de; helo=mailout07.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Commit 73ad33ef7b "audio: remove plive" forgot to remove this code. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 22d769db0c..34c9cb9182 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1132,7 +1132,7 @@ static void audio_run_out (AudioState *s) =20 while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { size_t played, live, prev_rpos, free; - int nb_live, cleanup_required; + int nb_live; =20 live =3D audio_pcm_hw_get_live_out (hw, &nb_live); if (!nb_live) { @@ -1194,7 +1194,6 @@ static void audio_run_out (AudioState *s) audio_capture_mix_and_clear (hw, prev_rpos, played); } =20 - cleanup_required =3D 0; for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (!sw->active && sw->empty) { continue; @@ -1210,7 +1209,6 @@ static void audio_run_out (AudioState *s) =20 if (!sw->total_hw_samples_mixed) { sw->empty =3D 1; - cleanup_required |=3D !sw->active && !sw->callback.fn; } =20 if (sw->active) { @@ -1220,19 +1218,6 @@ static void audio_run_out (AudioState *s) } } } - - if (cleanup_required) { - SWVoiceOut *sw1; - - sw =3D hw->sw_head.lh_first; - while (sw) { - sw1 =3D sw->entries.le_next; - if (!sw->active && !sw->callback.fn) { - audio_close_out (sw); - } - sw =3D sw1; - } - } } } =20 --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273639; cv=none; d=zohomail.com; s=zohoarc; b=YmK4y+7zMBrnEURz8nHlEwsXf90v0LV0Gd2akeoT3ho8KQzXmZ5bon9IXt/0lEt1ECA/cmEZTi5oi0SDjRK/xakwYg1TTV2MIvZSY7Jhnyoew2I2x9ZSXsbA7EeEJ9i+eHcshiRGGj3yCxEJUw6aLDK+FyUs9iJpqqEuzdjNNvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273639; 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=aSs0GJQZf6YjUBYvZaaqG7dWpvZ1Q4pqfOupvg5JCaQ=; b=TWlQxjBJNK/g+w3SHlYQAlYeapI630o4IjexIDqZ2COmRZWqhjbUpNI0uFwXWUL7DJ6AqlAanLCH7zE16FOXViJslPh/gDUF1fpsuM6/qVXPqAv4QoqUprRtJNgkJqRRMbKPOVe5YBTAxRY5eT55NggrNefORmQs6Tex9bdi0Os= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273639161568.8443322571588; Sun, 10 Jan 2021 02:13:59 -0800 (PST) Received: from localhost ([::1]:54418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXjR-0005hd-SB for importer@patchew.org; Sun, 10 Jan 2021 05:13:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZ5-0001os-V0 for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:15 -0500 Received: from mailout09.t-online.de ([194.25.134.84]:40508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZ3-0005S3-6B for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:15 -0500 Received: from fwd37.aul.t-online.de (fwd37.aul.t-online.de [172.20.27.137]) by mailout09.t-online.de (Postfix) with SMTP id B00EA42C88CD; Sun, 10 Jan 2021 11:03:11 +0100 (CET) Received: from linpower.localnet (bjcJ-iZYrhLnw4oQl9gXdXdEpFAQv7YsR2kzbqFSJNupXXu59HsCWCnXbJLCFf5gqX@[93.236.152.29]) by fwd37.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZ1-3tUVxQ0; Sun, 10 Jan 2021 11:03:11 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 032FC20063B; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 13/23] paaudio: avoid to clip samples multiple times Date: Sun, 10 Jan 2021 11:02:29 +0100 Message-Id: <20210110100239.27588-13-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: bjcJ-iZYrhLnw4oQl9gXdXdEpFAQv7YsR2kzbqFSJNupXXu59HsCWCnXbJLCFf5gqX X-TOI-EXPURGATEID: 150726::1610272991-0000D445-CF5BC4D1/0/0 CLEAN NORMAL X-TOI-MSGID: 8be1d8f8-6c48-47c0-adf6-ed953f4b3fd7 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; Received-SPF: none client-ip=194.25.134.84; envelope-from=volker.ruemelin@t-online.de; helo=mailout09.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The pulseaudio backend currently converts, clips and copies audio playback samples in the mixing-engine sample buffer multiple times. In qpa_get_buffer_out() the function pa_stream_begin_write() returns a rather large buffer and this allows audio_pcm_hw_run_out() in audio/audio.c to copy all samples in the mixing-engine buffer to the pulse audio buffer. Immediately after copying, qpa_write() notices with a call to pa_stream_writable_size() that pulse audio only needs a smaller part of the copied samples and ignores the rest. This copy and ignore process happens several times for each audio sample. To fix this behaviour, call pa_stream_writable_size() in qpa_get_buffer_out() to limit the number of samples audio_pcm_hw_run_out() will convert. With this change the pulseaudio pcm_ops functions put_buffer_out and write are no longer identical and a separate qpa_put_buffer_out is needed. Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index b052084698..229bcfcae8 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -207,6 +207,7 @@ static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t = *size) PAVoiceOut *p =3D (PAVoiceOut *) hw; PAConnection *c =3D p->g->conn; void *ret; + size_t l; int r; =20 pa_threaded_mainloop_lock(c->mainloop); @@ -214,12 +215,19 @@ static void *qpa_get_buffer_out(HWVoiceOut *hw, size_= t *size) CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, "pa_threaded_mainloop_lock failed\n"); =20 + l =3D pa_stream_writable_size(p->stream); + CHECK_SUCCESS_GOTO(c, l !=3D (size_t) -1, unlock_and_fail, + "pa_stream_writable_size failed\n"); + *size =3D -1; r =3D pa_stream_begin_write(p->stream, &ret, size); CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, "pa_stream_begin_write failed\n"); =20 pa_threaded_mainloop_unlock(c->mainloop); + if (*size > l) { + *size =3D l; + } return ret; =20 unlock_and_fail: @@ -228,6 +236,28 @@ unlock_and_fail: return NULL; } =20 +static size_t qpa_put_buffer_out(HWVoiceOut *hw, void *data, size_t length) +{ + PAVoiceOut *p =3D (PAVoiceOut *)hw; + PAConnection *c =3D p->g->conn; + int r; + + pa_threaded_mainloop_lock(c->mainloop); + + CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, + "pa_threaded_mainloop_lock failed\n"); + + r =3D pa_stream_write(p->stream, data, length, NULL, 0LL, PA_SEEK_RELA= TIVE); + CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, "pa_stream_write fail= ed\n"); + + pa_threaded_mainloop_unlock(c->mainloop); + return length; + +unlock_and_fail: + pa_threaded_mainloop_unlock(c->mainloop); + return 0; +} + static size_t qpa_write(HWVoiceOut *hw, void *data, size_t length) { PAVoiceOut *p =3D (PAVoiceOut *) hw; @@ -861,7 +891,7 @@ static struct audio_pcm_ops qpa_pcm_ops =3D { .fini_out =3D qpa_fini_out, .write =3D qpa_write, .get_buffer_out =3D qpa_get_buffer_out, - .put_buffer_out =3D qpa_write, /* pa handles it */ + .put_buffer_out =3D qpa_put_buffer_out, .volume_out =3D qpa_volume_out, =20 .init_in =3D qpa_init_in, --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273521; cv=none; d=zohomail.com; s=zohoarc; b=H/FuII9v9u0JBlqMLEWhtWrt+FGI5r7IIv1w3y64jw3IH3MQttU6w2vHm3sffS95xQF3QLMa7x4X3M7f0K4x0NBKHhK0ug+bTEithODqHt7ev1xYo04PVpFQdz2vWNIxpXtc7dCwcY3KJE2JY1YQxgMgAlKeOwTlbjSWasV0Wpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273521; 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=YrE5PJew4pG7dUoyVgIdllfgQs2GzWpuqeESCjamPdo=; b=PvB01lpxy8I8YQhbWhZ4G8xRggpklBRLTCrquJcBk2MDb5UItX70X39McoaqRnmJzVEWFiXEDqRwJe8tKkGdMSdiPzoZkZrPr0i+MQXEcoTEfFXVIlWW8d/QCqtTjGjjQRDuaj4MKdN/3/coLsRLng0F5HKslN1Rhu6eHr9p558= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161027352158941.16525544104161; Sun, 10 Jan 2021 02:12:01 -0800 (PST) Received: from localhost ([::1]:45462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXhY-0001yU-8K for importer@patchew.org; Sun, 10 Jan 2021 05:12:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZ8-0001vl-Ae for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:18 -0500 Received: from mailout06.t-online.de ([194.25.134.19]:33672) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZ6-0005Tc-FF for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:18 -0500 Received: from fwd13.aul.t-online.de (fwd13.aul.t-online.de [172.20.27.62]) by mailout06.t-online.de (Postfix) with SMTP id BC68C412F754; Sun, 10 Jan 2021 11:03:14 +0100 (CET) Received: from linpower.localnet (XH0AMYZXZh9vvbeXRE21rdT9I1p3G1zek3i+uQyxNutC1e9G9US0k5mMmFQupbpQq1@[93.236.152.29]) by fwd13.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZ4-0INnii0; Sun, 10 Jan 2021 11:03:14 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 0581920063C; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 14/23] paaudio: wait for PA_STREAM_READY in qpa_write() Date: Sun, 10 Jan 2021 11:02:30 +0100 Message-Id: <20210110100239.27588-14-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: XH0AMYZXZh9vvbeXRE21rdT9I1p3G1zek3i+uQyxNutC1e9G9US0k5mMmFQupbpQq1 X-TOI-EXPURGATEID: 150726::1610272994-00003E0D-ECD9F048/0/0 CLEAN NORMAL X-TOI-MSGID: b2affc18-a0bf-4b2a-8f9c-e0b6404357a8 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; Received-SPF: none client-ip=194.25.134.19; envelope-from=volker.ruemelin@t-online.de; helo=mailout06.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Don't call pa_stream_writable_size() in qpa_write() before the playback stream is ready. This prevents a lot of the following pulseaudio error messages. pulseaudio: pa_stream_writable_size failed pulseaudio: Reason: Bad state To reproduce start qemu with -parallel none -device gus,audiodev=3Daudio0 -audiodev pa,id=3Daudio0,out.mixing-engine=3Doff Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/audio/paaudio.c b/audio/paaudio.c index 229bcfcae8..1a7252b16d 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -269,6 +269,11 @@ static size_t qpa_write(HWVoiceOut *hw, void *data, si= ze_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 */ + l =3D 0; + goto unlock; + } =20 l =3D pa_stream_writable_size(p->stream); =20 @@ -282,6 +287,7 @@ static size_t qpa_write(HWVoiceOut *hw, void *data, siz= e_t length) r =3D pa_stream_write(p->stream, data, l, NULL, 0LL, PA_SEEK_RELATIVE); CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, "pa_stream_write fail= ed\n"); =20 +unlock: pa_threaded_mainloop_unlock(c->mainloop); return l; =20 --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273735; cv=none; d=zohomail.com; s=zohoarc; b=n607b5SgHiEcWoVyOHRWhjUjII155u7a5WthXRJVB3CZfLOq7UZLNKuWH3pjwqWs8zkqNysLd0XkqaVlHK6jY5NwCh91Vyu9Hv+gsDPLjNDrI7WYUmVgCe709IwveQ1vMvyk/lOQrxn0TTha2lPFKFlMke0F8/2/6haQu8x01Zk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273735; 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=iEHGwyc6j9QCi8b7n5ypxafih+TGdYf/1sx8/E86v4w=; b=FvECv26rn6l0q1mkwO0zEj2loEzPjbaOMl4lo5Ek+vzx1MODO+0HqwRJu3NWuN24sntimG/HCi8m5th/Qv7F5XgNUCsi7N82oJ+QJxLtlw6GCyaKsfy22gT/Fvlpuod98GEO5K9G2ThpF+ax/jAxC7iOkp0g+TWY6f7Aj9rxz7c= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273735583965.4027432023374; Sun, 10 Jan 2021 02:15:35 -0800 (PST) Received: from localhost ([::1]:33682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXl0-0000V5-CF for importer@patchew.org; Sun, 10 Jan 2021 05:15:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZB-00024G-CE for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:21 -0500 Received: from mailout03.t-online.de ([194.25.134.81]:57118) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZ9-0005WY-OF for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:21 -0500 Received: from fwd22.aul.t-online.de (fwd22.aul.t-online.de [172.20.26.127]) by mailout03.t-online.de (Postfix) with SMTP id 30E80421777C; Sun, 10 Jan 2021 11:03:18 +0100 (CET) Received: from linpower.localnet (XL5dysZO8h4j4kC8N7jjUA4vY8nh-OhR0m8PqtbX3GAyGdD1uSOZNbDKIE1AXnBZN8@[93.236.152.29]) by fwd22.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZ6-3W2PKq0; Sun, 10 Jan 2021 11:03:16 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 0790A20063D; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 15/23] paaudio: wait until the playback stream is ready Date: Sun, 10 Jan 2021 11:02:31 +0100 Message-Id: <20210110100239.27588-15-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: XL5dysZO8h4j4kC8N7jjUA4vY8nh-OhR0m8PqtbX3GAyGdD1uSOZNbDKIE1AXnBZN8 X-TOI-EXPURGATEID: 150726::1610272996-00011FFC-69646FD1/0/0 CLEAN NORMAL X-TOI-MSGID: 33a8d171-e8c7-4d91-b872-c5b7244c5dfd 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; Received-SPF: none client-ip=194.25.134.81; envelope-from=volker.ruemelin@t-online.de; helo=mailout03.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Don't call pa_stream_writable_size() in qpa_get_buffer_out() before the playback stream is ready. This prevents a lot of the following pulseaudio error messages. pulseaudio: pa_stream_writable_size failed pulseaudio: Reason: Bad state To reproduce start qemu with -parallel none -device gus,audiodev=3Daudio0 -audiodev pa,id=3Daudio0 Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/audio/paaudio.c b/audio/paaudio.c index 1a7252b16d..4a1ffda753 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -214,6 +214,12 @@ static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t= *size) =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 */ + l =3D 0; + ret =3D NULL; + goto unlock; + } =20 l =3D pa_stream_writable_size(p->stream); CHECK_SUCCESS_GOTO(c, l !=3D (size_t) -1, unlock_and_fail, @@ -224,6 +230,7 @@ static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t = *size) CHECK_SUCCESS_GOTO(c, r >=3D 0, unlock_and_fail, "pa_stream_begin_write failed\n"); =20 +unlock: pa_threaded_mainloop_unlock(c->mainloop); if (*size > l) { *size =3D l; --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273622; cv=none; d=zohomail.com; s=zohoarc; b=jW2ECF/dL16wirRylEaXlgfuVB/lE1JFzdLQRg6iRmaiN4jNnVQJ8VHU93OoerAa9NBfwZPE2zCEZv02WOA833NFjDAS5ZSTC0mkGUKUhE0WKiYI1zrm/xFI56ETOZuQkCm4kt63Vn9H8If3AE0BO05dCvo8iyxWy5WPiu0Rtlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273622; 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=khNDgKbo5QsDHng2/3Ls8gFVCJXzycY+1jl+N/BgZMk=; b=PhX2cD76FAPo18rLqOuRhBbxLaaEEp7onRDLgrLRHlIeQIhlpioZqV38xezxJqh/l+d+usigt+TlKg2CiFLyo7h3ALEa07G7+u5H3nTkQXlGEkwko7ZnUfsW06shJ5B2Z3HQzFebRM6p50m0NcxJg3Ayp43JjjcMRtpLtdyCc+Y= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273622546880.6650297683123; Sun, 10 Jan 2021 02:13:42 -0800 (PST) Received: from localhost ([::1]:53270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXjB-0005Em-15 for importer@patchew.org; Sun, 10 Jan 2021 05:13:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZH-0002IK-Hl for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:33 -0500 Received: from mailout01.t-online.de ([194.25.134.80]:59868) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZE-0005YH-UR for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:27 -0500 Received: from fwd25.aul.t-online.de (fwd25.aul.t-online.de [172.20.26.130]) by mailout01.t-online.de (Postfix) with SMTP id 17E7B421C82F; Sun, 10 Jan 2021 11:03:23 +0100 (CET) Received: from linpower.localnet (Z2Phi2ZJYhPj8HmMDUpCXF3MhYcJfuwTs6JP++5G8eszSJCKXKk7kgy3eCQCFLLwJl@[93.236.152.29]) by fwd25.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZ9-059WpU0; Sun, 10 Jan 2021 11:03:19 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 09B4020063E; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 16/23] paaudio: remove unneeded code Date: Sun, 10 Jan 2021 11:02:32 +0100 Message-Id: <20210110100239.27588-16-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: Z2Phi2ZJYhPj8HmMDUpCXF3MhYcJfuwTs6JP++5G8eszSJCKXKk7kgy3eCQCFLLwJl X-TOI-EXPURGATEID: 150726::1610272999-00015F3A-8A20DDDB/0/0 CLEAN NORMAL X-TOI-MSGID: bce6983c-cc70-412c-ba05-262134147708 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; Received-SPF: none client-ip=194.25.134.80; envelope-from=volker.ruemelin@t-online.de; helo=mailout01.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Commit baea032ec7 "audio/paaudio: fix ignored buffer_length setting" added code to handle buffer_length defaults. This was unnecessary because the audio_buffer_* functions in audio/audio.c already handle this. Remove the unneeded code. Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 4a1ffda753..86038f3e13 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -539,8 +539,7 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, =20 audio_pcm_init_info (&hw->info, &obt_as); hw->samples =3D audio_buffer_samples( - qapi_AudiodevPaPerDirectionOptions_base(ppdo), - &obt_as, ppdo->buffer_length); + qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); =20 return 0; =20 @@ -587,8 +586,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) =20 audio_pcm_init_info (&hw->info, &obt_as); hw->samples =3D audio_buffer_samples( - qapi_AudiodevPaPerDirectionOptions_base(ppdo), - &obt_as, ppdo->buffer_length); + qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); =20 return 0; =20 @@ -738,10 +736,6 @@ static void qpa_volume_in(HWVoiceIn *hw, Volume *vol) static int qpa_validate_per_direction_opts(Audiodev *dev, AudiodevPaPerDirectionOptions *= pdo) { - if (!pdo->has_buffer_length) { - pdo->has_buffer_length =3D true; - pdo->buffer_length =3D 46440; - } if (!pdo->has_latency) { pdo->has_latency =3D true; pdo->latency =3D 15000; --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273759; cv=none; d=zohomail.com; s=zohoarc; b=IorYQXpRNNjzGIK00WMOPx+lHRrDisCRXu5/MAs8Mm8mGD6B1kvLGXy7InD2Sa31AB9n5W5a4jIyl4J5bI0acVbz5l13bsFYNKCtPbzyly2PU/8jlVF4UpP6Y+cfN73Y7M9KXkVcYM8TV5Y6SmJ8h1HzfQPYHsH4C+bIn4TVge4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273759; 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=7hJAUrIJ2NdtEQe6YWHe8OGcU90UbRR3nAweTUd4Drk=; b=cBWyrnqaquwVPFlkd2YmHcyvurxrUR+E7V+c7fLlbB3RcMm9Jk6iM1C1TOlmmI86KSST/WT77JrQhG7Lw76hNKhjErI/6ezJgkIEcv+2pMdgVHmXJhdJINf0y+t50ZFOLTtr15UKCLXXNBnqejc4UwVkHFlLvYtmG0NAviAK/4A= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273759620203.31138537978381; Sun, 10 Jan 2021 02:15:59 -0800 (PST) Received: from localhost ([::1]:35624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXlO-0001Mp-CQ for importer@patchew.org; Sun, 10 Jan 2021 05:15:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZJ-0002Ih-FZ for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:33 -0500 Received: from mailout08.t-online.de ([194.25.134.20]:33454) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZH-0005Ze-9A for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:29 -0500 Received: from fwd41.aul.t-online.de (fwd41.aul.t-online.de [172.20.27.139]) by mailout08.t-online.de (Postfix) with SMTP id 11B2B41A5138; Sun, 10 Jan 2021 11:03:26 +0100 (CET) Received: from linpower.localnet (rXgvaOZZYhxLXj36onIrNgRjpRJ1zuvobSP+gzmN0N2RPhWO22ENxDl4C+DY+9iwR9@[93.236.152.29]) by fwd41.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZB-1CUsUq0; Sun, 10 Jan 2021 11:03:21 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 0BEFF2006C0; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 17/23] paaudio: comment bugs in functions qpa_init_* Date: Sun, 10 Jan 2021 11:02:33 +0100 Message-Id: <20210110100239.27588-17-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: rXgvaOZZYhxLXj36onIrNgRjpRJ1zuvobSP+gzmN0N2RPhWO22ENxDl4C+DY+9iwR9 X-TOI-EXPURGATEID: 150726::1610273001-00000C4D-38D5E87B/0/0 CLEAN NORMAL X-TOI-MSGID: 9ca11905-4f8e-4589-b7fe-bf466a66b510 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; Received-SPF: none client-ip=194.25.134.20; envelope-from=volker.ruemelin@t-online.de; helo=mailout08.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The audio buffer size in audio/paaudio.c is typically larger than expected. Just comment the bugs in qpa_init_in() and qpa_init_out() for now. Fixing these bugs may break glitch free audio playback with fine tuned user audio settings. Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/audio/paaudio.c b/audio/paaudio.c index 86038f3e13..ff3dd01c96 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -538,6 +538,10 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsett= ings *as, } =20 audio_pcm_init_info (&hw->info, &obt_as); + /* + * This is wrong. hw->samples counts in frames. hw->samples will be + * number of channels times larger than expected. + */ hw->samples =3D audio_buffer_samples( qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); =20 @@ -585,6 +589,10 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettin= gs *as, void *drv_opaque) } =20 audio_pcm_init_info (&hw->info, &obt_as); + /* + * This is wrong. hw->samples counts in frames. hw->samples will be + * number of channels times larger than expected. + */ hw->samples =3D audio_buffer_samples( qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); =20 --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273980; cv=none; d=zohomail.com; s=zohoarc; b=mH2l0b8QwNp8xpGH2KhWNH1F1AV5GTFsTOe6iSer7RqOBwm4uk8bUibhUXFrHc8yXANNYdomOG2pFBSpWmhR2vC/45IoHhjd0BPn9RgUFQeZMJ1JlEJ+Fd/Fv9N0SG8Gt5NlXcYO6cCycbxU7w8NxKDes5FqS4xbTy1cqS7xnHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273980; 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=mrtJCi7bU/PzdVEX5v4ryNukxVfnEW0VnDs/onvUMnc=; b=M+fVS8P07fcFZyWMmzaB4fpvX7NA9rj24C1sbAVvNG9rMj4Sdjm7S9aCJUtRk3aSyKBmCpDgdHIkTo+dH2r6dPISxrKESU7OpEeiYAUx41eEZz7Qzu7J9IBo3kfspFU80OKIAt8MDIu7bkMNDFxQD5RAvhKsWGLI2iWn8d+Myrs= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273980097828.860694541619; Sun, 10 Jan 2021 02:19:40 -0800 (PST) Received: from localhost ([::1]:42692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXow-0004M5-74 for importer@patchew.org; Sun, 10 Jan 2021 05:19:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZP-0002JJ-JM for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:35 -0500 Received: from mailout05.t-online.de ([194.25.134.82]:42692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZJ-0005b9-VF for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:35 -0500 Received: from fwd27.aul.t-online.de (fwd27.aul.t-online.de [172.20.26.132]) by mailout05.t-online.de (Postfix) with SMTP id 6A58F42030A8; Sun, 10 Jan 2021 11:03:28 +0100 (CET) Received: from linpower.localnet (XRs0VMZbZha5tNOVl7KXal1KCepQjBNkcgbJaR-q53PoJFBLZAwZEuIAvPDaSHSwhd@[93.236.152.29]) by fwd27.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZE-095AA40; Sun, 10 Jan 2021 11:03:24 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 0E18D2006C1; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 18/23] paaudio: limit minreq to 75% of audio timer_rate Date: Sun, 10 Jan 2021 11:02:34 +0100 Message-Id: <20210110100239.27588-18-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: XRs0VMZbZha5tNOVl7KXal1KCepQjBNkcgbJaR-q53PoJFBLZAwZEuIAvPDaSHSwhd X-TOI-EXPURGATEID: 150726::1610273004-0000CED0-BC938EA4/0/0 CLEAN NORMAL X-TOI-MSGID: a267f9ea-efe3-4a38-8799-5de0a5c0005d 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; Received-SPF: none client-ip=194.25.134.82; envelope-from=volker.ruemelin@t-online.de; helo=mailout05.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Currently with the playback buffer attribute minreq =3D -1 and flag PA_STREAM_EARLY_REQUESTS PulseAudio uses minreq =3D tlength / 4. To improve audio playback with larger PulseAudio server side buffers, limit minreq to a maximum of 75% of audio timer_rate. That way there is a good chance qemu receives a stream buffer size update before it tries to write data to the playback stream. Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index ff3dd01c96..3186868294 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -517,7 +517,8 @@ static int qpa_init_out(HWVoiceOut *hw, struct audsetti= ngs *as, ss.rate =3D as->freq; =20 ba.tlength =3D pa_usec_to_bytes(ppdo->latency, &ss); - ba.minreq =3D -1; + ba.minreq =3D pa_usec_to_bytes(MIN(ppdo->latency >> 2, + (g->dev->timer_period >> 2) * 3), &ss= ); ba.maxlength =3D -1; ba.prebuf =3D -1; =20 --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273871; cv=none; d=zohomail.com; s=zohoarc; b=EK5SnvUrtK84y+ujasfQm3G2m4nact0Uq8U1dCkswL4SnjZ5+JJaTpdLBeggbGrsJR/kme3ygamwkUxOZzNnoG/C87LhjvAEPr0etoqJdUtIVKk7u82IeNLVPhYzD0+78++yOulVqBrcaiWLjPZIvWRp+qVORGdu5tKvVY8BnWI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273871; 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=Db2zDFrgSZdGe4QAexxxyEVpl8lDhS3PWbz6Q/Kh5DM=; b=IgJrQI0rwjiI9EHKdmnYMXgp4wLo7X5zhItiEx2MyPIt74LjZ544Tzx0zETuQ/E0SS3m7SS173ePEe3OjQVgfFW8MFXzYB0EOWrlgqtXPNEiQgaqg24uB9uFkLkEqpYKOpF4CprMwPF6p1Nyv7UNGrVlz4Ie0ViD3Qc5MOvvAkc= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273871422593.6678933554501; Sun, 10 Jan 2021 02:17:51 -0800 (PST) Received: from localhost ([::1]:40160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXnC-0003Gj-87 for importer@patchew.org; Sun, 10 Jan 2021 05:17:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZN-0002Ip-Aa for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:33 -0500 Received: from mailout04.t-online.de ([194.25.134.18]:55038) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZJ-0005b7-7r for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:33 -0500 Received: from fwd39.aul.t-online.de (fwd39.aul.t-online.de [172.20.27.138]) by mailout04.t-online.de (Postfix) with SMTP id 048DB41AA781; Sun, 10 Jan 2021 11:03:28 +0100 (CET) Received: from linpower.localnet (EAVH5mZToh23QiYENvIVgbpDE3zBdDG-aOxfNzdjuaMHUxE8F1isBX4h+uA+litZrS@[93.236.152.29]) by fwd39.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZG-2rw17A0; Sun, 10 Jan 2021 11:03:26 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 102BD2006C2; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 19/23] paaudio: send recorded data in smaller chunks Date: Sun, 10 Jan 2021 11:02:35 +0100 Message-Id: <20210110100239.27588-19-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: EAVH5mZToh23QiYENvIVgbpDE3zBdDG-aOxfNzdjuaMHUxE8F1isBX4h+uA+litZrS X-TOI-EXPURGATEID: 150726::1610273007-00000BD0-353D45A1/0/0 CLEAN NORMAL X-TOI-MSGID: cf1b0246-e2bf-474a-8fff-4524f33d5335 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; Received-SPF: none client-ip=194.25.134.18; envelope-from=volker.ruemelin@t-online.de; helo=mailout04.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Tell PulseAudio to send recorded audio data in smaller chunks than timer_period, so there's a good chance that qemu can read recorded audio data every time it looks for new data. PulseAudio tries to send buffer updates at a fragsize / 2 rate. With fragsize =3D timer_period / 2 * 3 the update rate is 75% of timer_period. The lower limit for the recording buffer size maxlength is fragsize * 2. Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 3186868294..1e6f4448ce 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -568,8 +568,9 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsetting= s *as, void *drv_opaque) ss.channels =3D as->nchannels; ss.rate =3D as->freq; =20 - ba.fragsize =3D pa_usec_to_bytes(ppdo->latency, &ss); - ba.maxlength =3D pa_usec_to_bytes(ppdo->latency * 2, &ss); + ba.fragsize =3D pa_usec_to_bytes((g->dev->timer_period >> 1) * 3, &ss); + ba.maxlength =3D pa_usec_to_bytes( + MAX(ppdo->latency, g->dev->timer_period * 3), &ss); ba.minreq =3D -1; ba.prebuf =3D -1; =20 --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610274103; cv=none; d=zohomail.com; s=zohoarc; b=mWRKrYnFHB6gpi7zfGYmaEGWbH9jVb2nBXf5YDaQ9kU00nUfvg/Dy44UoNj9k6t5dOUCVYryi2yfoyZpU5Q30Lm+0lepOz/EZVBjxGOfJrAIkDRT8ZYvikrrmG6AOKPnF1QIkQItLxx0cgw3X5d2g1GG3QuvhWnQgqTxBj6fbqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610274103; 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=8VE3yIMV0UdLVz5lThnDJiBw+1DRPK81dEmCIRUh6Ho=; b=hZDkCvWpNhKttmsmB8MJrfVk5DxHSmGM/MKDmAlTJgE4lj7SOURS7+oL2XZO9xU0FMeT4hJ3lZetRcbWDrxW9sTg1OPmKA9Su8GLFe41gwL+uQsbp4YOQUIHhZn5LBJ4VZdKf+QlHJvNm/xH9BJIymoy+QNspbeAH6SMxOMqr5k= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610274103652716.6323739998483; Sun, 10 Jan 2021 02:21:43 -0800 (PST) Received: from localhost ([::1]:44908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXqw-0005g4-Cn for importer@patchew.org; Sun, 10 Jan 2021 05:21:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZU-0002Jw-SS for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:41 -0500 Received: from mailout11.t-online.de ([194.25.134.85]:43696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZN-0005bv-3F for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:39 -0500 Received: from fwd36.aul.t-online.de (fwd36.aul.t-online.de [172.20.26.137]) by mailout11.t-online.de (Postfix) with SMTP id 7611542542EE; Sun, 10 Jan 2021 11:03:31 +0100 (CET) Received: from linpower.localnet (G0bPiEZ68haCtw5n1t2vu2C2KE5qBrRHMCpjq6qzN7UG4xmB9n0l8IWELlvgsgTgEj@[93.236.152.29]) by fwd36.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZJ-4DUxZw0; Sun, 10 Jan 2021 11:03:29 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 1268D2006C3; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 20/23] dsoundaudio: replace GetForegroundWindow() Date: Sun, 10 Jan 2021 11:02:36 +0100 Message-Id: <20210110100239.27588-20-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: G0bPiEZ68haCtw5n1t2vu2C2KE5qBrRHMCpjq6qzN7UG4xmB9n0l8IWELlvgsgTgEj X-TOI-EXPURGATEID: 150726::1610273009-00004FB0-0A17421E/0/0 CLEAN NORMAL X-TOI-MSGID: 01c17d62-0b6f-4f4c-9b16-14ca2d3fc521 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; Received-SPF: none client-ip=194.25.134.85; envelope-from=volker.ruemelin@t-online.de; helo=mailout11.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" GetForegroundWindow() doesn't necessarily return the own window handle. It just returns a handle to the currently active window and can even return NULL. At the time dsound_open() gets called the active window is most likely the shell window and not the QEMU window. Replace GetForegroundWindow() with GetDesktopWindow() which always returns a valid window handle, and at the same time replace the DirectSound buffer flag DSBCAPS_STICKYFOCUS with DSBCAPS_GLOBALFOCUS where Windows only expects a valid window handle for DirectSound function SetCooperativeLevel(). The Microsoft online docs for IDirectSound::SetCooperativeLevel recommend this in the remarks. This fixes a bug where you can't hear sound from the guest. To reproduce start qemu with -machine pcspk-audiodev=3Daudio0 -device intel-hda -device hda-duplex,audiodev=3Daudio0 -audiodev dsound,id=3Daudio0,out.mixing-engine=3Doff from a shell and start audio playback with the hda device in the guest. The guest will be silent. To hear guest audio you have to activate the shell window once. Signed-off-by: Volker R=C3=BCmelin --- audio/dsound_template.h | 2 +- audio/dsoundaudio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/dsound_template.h b/audio/dsound_template.h index 9c5ce625ab..0678f2de38 100644 --- a/audio/dsound_template.h +++ b/audio/dsound_template.h @@ -205,7 +205,7 @@ static int dsound_init_out(HWVoiceOut *hw, struct audse= ttings *as, NULL ); #else - bd.dwFlags =3D DSBCAPS_STICKYFOCUS | DSBCAPS_GETCURRENTPOSITION2; + bd.dwFlags =3D DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2; hr =3D IDirectSound_CreateSoundBuffer ( s->dsound, &bd, diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 4cdf19ab67..0fbdf770ac 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -347,7 +347,7 @@ static int dsound_open (dsound *s) HRESULT hr; HWND hwnd; =20 - hwnd =3D GetForegroundWindow (); + hwnd =3D GetDesktopWindow(); hr =3D IDirectSound_SetCooperativeLevel ( s->dsound, hwnd, --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273820; cv=none; d=zohomail.com; s=zohoarc; b=bo89P+NL7Kp4Fi99Vm5c0SMDG7JwtIf5qYPs1prUwnxN3X4ZxtoeWH1B8UwD0RqKjkD+XclyueYfWAMhKmdSPp4LWrLN+NHXXdMLmRqjOKwb5w4fp6dXVie4QlHOxXERQPiKmoGbFpkVV1FTmOO8XCUmQQXIMGn0GaDe9kPm0zk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273820; 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=auTSX9xblaX/eWJwey1DWNtCRIXmq7+TK3DTA42YJpo=; b=OmdypgoM+0xWGzY526QTmHVPQPQYPHFEl/mn/vYUaV2J3bZ9m5iqOZSMLNPsYcBJ9UeBeTZXkzHRl/Khsjj0+Ag7DV/I25mtWsNEELqBOZ5O+UBLaHT6kPU4ivh1pGLgsxiy3clkYFhyhuydvOJ3eR5g4tu/et0kX6S8d+Jyi2o= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273820340341.62431893116343; Sun, 10 Jan 2021 02:17:00 -0800 (PST) Received: from localhost ([::1]:38852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXmN-0002iD-4C for importer@patchew.org; Sun, 10 Jan 2021 05:16:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZS-0002Js-9s for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:41 -0500 Received: from mailout04.t-online.de ([194.25.134.18]:55108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZP-0005c5-Hr for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:38 -0500 Received: from fwd22.aul.t-online.de (fwd22.aul.t-online.de [172.20.26.127]) by mailout04.t-online.de (Postfix) with SMTP id 5ACF941AA787; Sun, 10 Jan 2021 11:03:34 +0100 (CET) Received: from linpower.localnet (EfTN+OZprh-BWn25zQbkigENNIvkLSbknsOU5mAn48wvbOPEnyHJa8DexFQe1Y8Qme@[93.236.152.29]) by fwd22.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZM-3uvsqu0; Sun, 10 Jan 2021 11:03:32 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 14A482006C4; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 21/23] dsoundaudio: rename dsound_open() Date: Sun, 10 Jan 2021 11:02:37 +0100 Message-Id: <20210110100239.27588-21-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: EfTN+OZprh-BWn25zQbkigENNIvkLSbknsOU5mAn48wvbOPEnyHJa8DexFQe1Y8Qme X-TOI-EXPURGATEID: 150726::1610273012-00011FFC-DBEE0940/0/0 CLEAN NORMAL X-TOI-MSGID: ce1ef6d0-3cf9-428e-9905-c4287ba24236 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; Received-SPF: none client-ip=194.25.134.18; envelope-from=volker.ruemelin@t-online.de; helo=mailout04.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Rename dsound_open() to dsound_set_cooperative_level(). The only task of that function is to set the cooperative level for DirectSound. Signed-off-by: Volker R=C3=BCmelin --- audio/dsoundaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index 0fbdf770ac..d3695f3af6 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -342,7 +342,7 @@ static void dsound_clear_sample (HWVoiceOut *hw, LPDIRE= CTSOUNDBUFFER dsb, dsound_unlock_out (dsb, p1, p2, blen1, blen2); } =20 -static int dsound_open (dsound *s) +static int dsound_set_cooperative_level(dsound *s) { HRESULT hr; HWND hwnd; @@ -673,7 +673,7 @@ static void *dsound_audio_init(Audiodev *dev) } } =20 - err =3D dsound_open (s); + err =3D dsound_set_cooperative_level(s); if (err) { dsound_audio_fini (s); return NULL; --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273625; cv=none; d=zohomail.com; s=zohoarc; b=D8l8+xC4x9EzjA5GgXat4/K8R0J5VJ/MiVInRqiccPdKCP9LvNVvvdhQn5xa5R3JHM6KrN78ksux5/78ciJCECCCh5Sfan74UC2sSXU9GZ0kOocTHtseueogIYM9n2qrVjPC48CP1pJSyB8ZQB5/cQozLdiFnlGO2qjBNsr/b3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273625; 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=K+T3SIUdrE83k08NQfTs7iJENMoLd7hz14q+dYH5/z8=; b=fAqjdPjeJ6luhGODV8MRhviisJ5BphK40AexJqoQMftWCwUGPISb5YC27FhDuEsot2TXXv1ElksQWofqbIMcX9HMt0sWlnndZj+tLrWiPVbZ5aPq6sgY9MWVQTxfdFdqZ2NoYEH0GHpHwIBO23TQzWR7EF/EsCa/kSuSVmUjYjQ= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273625691999.1101388074078; Sun, 10 Jan 2021 02:13:45 -0800 (PST) Received: from localhost ([::1]:53664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXjE-0005OP-BF for importer@patchew.org; Sun, 10 Jan 2021 05:13:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZX-0002Kl-T6 for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:44 -0500 Received: from mailout01.t-online.de ([194.25.134.80]:59994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZU-0005cx-ME for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:43 -0500 Received: from fwd17.aul.t-online.de (fwd17.aul.t-online.de [172.20.27.64]) by mailout01.t-online.de (Postfix) with SMTP id 4320E421C832; Sun, 10 Jan 2021 11:03:38 +0100 (CET) Received: from linpower.localnet (Vsh4yEZb8h4kTiBY1NJtYXK3pTOYuhMrvxDikXTw4IuDTc6MaNzJa8zQgQAqXrjw17@[93.236.152.29]) by fwd17.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZO-2g7jsG0; Sun, 10 Jan 2021 11:03:34 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 16C052006C5; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 22/23] dsoundaudio: enable f32 audio sample format Date: Sun, 10 Jan 2021 11:02:38 +0100 Message-Id: <20210110100239.27588-22-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: Vsh4yEZb8h4kTiBY1NJtYXK3pTOYuhMrvxDikXTw4IuDTc6MaNzJa8zQgQAqXrjw17 X-TOI-EXPURGATEID: 150726::1610273014-00006CDB-5260A379/0/0 CLEAN NORMAL X-TOI-MSGID: 43743ed1-774f-4d87-ab0a-afcd99bbfd59 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; Received-SPF: none client-ip=194.25.134.80; envelope-from=volker.ruemelin@t-online.de; helo=mailout01.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Enable the f32 audio sample format for the DirectSound backend. Signed-off-by: Volker R=C3=BCmelin --- audio/audio_win_int.c | 71 ++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/audio/audio_win_int.c b/audio/audio_win_int.c index b938fd667b..b7db34900c 100644 --- a/audio/audio_win_int.c +++ b/audio/audio_win_int.c @@ -5,6 +5,7 @@ =20 #define AUDIO_CAP "win-int" #include +#include #include =20 #include "audio.h" @@ -16,7 +17,6 @@ int waveformat_from_audio_settings (WAVEFORMATEX *wfx, { memset (wfx, 0, sizeof (*wfx)); =20 - wfx->wFormatTag =3D WAVE_FORMAT_PCM; wfx->nChannels =3D as->nchannels; wfx->nSamplesPerSec =3D as->freq; wfx->nAvgBytesPerSec =3D as->freq << (as->nchannels =3D=3D 2); @@ -26,11 +26,13 @@ int waveformat_from_audio_settings (WAVEFORMATEX *wfx, switch (as->fmt) { case AUDIO_FORMAT_S8: case AUDIO_FORMAT_U8: + wfx->wFormatTag =3D WAVE_FORMAT_PCM; wfx->wBitsPerSample =3D 8; break; =20 case AUDIO_FORMAT_S16: case AUDIO_FORMAT_U16: + wfx->wFormatTag =3D WAVE_FORMAT_PCM; wfx->wBitsPerSample =3D 16; wfx->nAvgBytesPerSec <<=3D 1; wfx->nBlockAlign <<=3D 1; @@ -38,6 +40,14 @@ int waveformat_from_audio_settings (WAVEFORMATEX *wfx, =20 case AUDIO_FORMAT_S32: case AUDIO_FORMAT_U32: + wfx->wFormatTag =3D WAVE_FORMAT_PCM; + wfx->wBitsPerSample =3D 32; + wfx->nAvgBytesPerSec <<=3D 2; + wfx->nBlockAlign <<=3D 2; + break; + + case AUDIO_FORMAT_F32: + wfx->wFormatTag =3D WAVE_FORMAT_IEEE_FLOAT; wfx->wBitsPerSample =3D 32; wfx->nAvgBytesPerSec <<=3D 2; wfx->nBlockAlign <<=3D 2; @@ -54,12 +64,6 @@ int waveformat_from_audio_settings (WAVEFORMATEX *wfx, int waveformat_to_audio_settings (WAVEFORMATEX *wfx, struct audsettings *as) { - if (wfx->wFormatTag !=3D WAVE_FORMAT_PCM) { - dolog ("Invalid wave format, tag is not PCM, but %d\n", - wfx->wFormatTag); - return -1; - } - if (!wfx->nSamplesPerSec) { dolog ("Invalid wave format, frequency is zero\n"); return -1; @@ -83,23 +87,42 @@ int waveformat_to_audio_settings (WAVEFORMATEX *wfx, return -1; } =20 - switch (wfx->wBitsPerSample) { - case 8: - as->fmt =3D AUDIO_FORMAT_U8; - break; - - case 16: - as->fmt =3D AUDIO_FORMAT_S16; - break; - - case 32: - as->fmt =3D AUDIO_FORMAT_S32; - break; - - default: - dolog ("Invalid wave format, bits per sample is not " - "8, 16 or 32, but %d\n", - wfx->wBitsPerSample); + if (wfx->wFormatTag =3D=3D WAVE_FORMAT_PCM) { + switch (wfx->wBitsPerSample) { + case 8: + as->fmt =3D AUDIO_FORMAT_U8; + break; + + case 16: + as->fmt =3D AUDIO_FORMAT_S16; + break; + + case 32: + as->fmt =3D AUDIO_FORMAT_S32; + break; + + default: + dolog("Invalid PCM wave format, bits per sample is not " + "8, 16 or 32, but %d\n", + wfx->wBitsPerSample); + return -1; + } + } else if (wfx->wFormatTag =3D=3D WAVE_FORMAT_IEEE_FLOAT) { + switch (wfx->wBitsPerSample) { + case 32: + as->fmt =3D AUDIO_FORMAT_F32; + break; + + default: + dolog("Invalid IEEE_FLOAT wave format, bits per sample is not " + "32, but %d\n", + wfx->wBitsPerSample); + return -1; + } + } else { + dolog("Invalid wave format, tag is not PCM and not IEEE_FLOAT, " + "but %d\n", + wfx->wFormatTag); return -1; } =20 --=20 2.26.2 From nobody Mon Apr 29 04:48:01 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1610273725; cv=none; d=zohomail.com; s=zohoarc; b=efv6i6we6PqkNY586defNWIZp7hM+qjyAgkR85ZGk6ysYNoeP9RKlKlz3dHI7+SrPQOYVnWZ6SMlRaedt62Fyhw79kHCq02kyG26OVFIQjXmSYXuJeTTdypTXlwmF+Ee1RxTfkbL7XrJYsPNkW2gygChUlS8IfgCsnqxDZ5BnUk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610273725; 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=6a+7YxQy113YX4b71VdrFtW5L/XV8x92y8EQP8LM85c=; b=SCR5kP2893y+bpuoa7V2c5V0vI31/XlnmLe+sAQ54fMSHrsnScrMXB22Ol2jp7nhUJiUxEIKAb/wYr7gmtCfdgHeF6ox4g/CA5NzGfvvi7NMmoWCqfwuxXv8j6qXqeEwyV9/xm9WsJPI1D4JDP5heimz3bPoiswAsDBNc8BiwVw= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1610273725600432.88450540753524; Sun, 10 Jan 2021 02:15:25 -0800 (PST) Received: from localhost ([::1]:32968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyXkq-0000C1-8S for importer@patchew.org; Sun, 10 Jan 2021 05:15:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZY-0002Le-Us for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:45 -0500 Received: from mailout07.t-online.de ([194.25.134.83]:60078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyXZU-0005cz-MS for qemu-devel@nongnu.org; Sun, 10 Jan 2021 05:03:44 -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 4EC1F42D62B8; Sun, 10 Jan 2021 11:03:38 +0100 (CET) Received: from linpower.localnet (Sy6OJwZCrhFIfcTErfdQiBmZE0t5-otkGSfIMOQZZlRKmXObCZOmAC1ZwucH9A9ghW@[93.236.152.29]) by fwd35.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1kyXZR-0ysPIm0; Sun, 10 Jan 2021 11:03:37 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id 18E602006C6; Sun, 10 Jan 2021 11:02:40 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 23/23] dsoundaudio: fix log message Date: Sun, 10 Jan 2021 11:02:39 +0100 Message-Id: <20210110100239.27588-23-vr_qemu@t-online.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> References: <9315afe5-5958-c0b4-ea1e-14769511a9d5@t-online.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ID: Sy6OJwZCrhFIfcTErfdQiBmZE0t5-otkGSfIMOQZZlRKmXObCZOmAC1ZwucH9A9ghW X-TOI-EXPURGATEID: 150726::1610273017-0000E07B-BE1B176D/0/0 CLEAN NORMAL X-TOI-MSGID: 57f0680b-7a8b-4f3f-ba47-a697714bf775 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; Received-SPF: none client-ip=194.25.134.83; envelope-from=volker.ruemelin@t-online.de; helo=mailout07.t-online.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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?q?Zolt=C3=A1n=20K=C5=91v=C3=A1g=C3=B3?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" There is a mismatch between message and used argument. Change the argument from frequency to format. Signed-off-by: Volker R=C3=BCmelin --- audio/audio_win_int.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/audio_win_int.c b/audio/audio_win_int.c index b7db34900c..5ea8157dfc 100644 --- a/audio/audio_win_int.c +++ b/audio/audio_win_int.c @@ -54,7 +54,7 @@ int waveformat_from_audio_settings (WAVEFORMATEX *wfx, break; =20 default: - dolog ("Internal logic error: Bad audio format %d\n", as->freq); + dolog("Internal logic error: Bad audio format %d\n", as->fmt); return -1; } =20 --=20 2.26.2