From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641481846120735.6258678286808; Thu, 6 Jan 2022 07:10:46 -0800 (PST) Received: from localhost ([::1]:54074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UPd-00032Q-4o for importer@patchew.org; Thu, 06 Jan 2022 10:10:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P12-0005sB-E7 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:03 -0500 Received: from mailout05.t-online.de ([194.25.134.82]:40032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P10-0006XC-JV for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:00 -0500 Received: from fwd75.dcpf.telekom.de (fwd75.aul.t-online.de [10.223.144.101]) by mailout05.t-online.de (Postfix) with SMTP id CCBB1104B3; Thu, 6 Jan 2022 10:23:33 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd75.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5Ozd-2IWHab0; Thu, 6 Jan 2022 10:23:33 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id D07DA200619; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 01/15] audio: replace open-coded buffer arithmetic Date: Thu, 6 Jan 2022 10:23:18 +0100 Message-Id: <20220106092332.7223-1-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461013-000184BD-37F24861/0/0 CLEAN NORMAL X-TOI-MSGID: 52318789-439f-4264-bb62-5fee4067c6dc 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:04:59 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Christian Schoenebeck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641481846984100001 From: Volker R=C3=BCmelin Replace open-coded buffer arithmetic with the available function audio_ring_dist(). Because the name audio_ring_dist implies it calculates the distance between two points, define the alias function name audio_ring_posb. That's the position in backward direction of a given point at a given distance. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 25 +++++++------------------ audio/audio_int.h | 2 ++ audio/coreaudio.c | 10 ++++------ audio/sdlaudio.c | 11 +++++------ 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index dc28685d22..e7a139e289 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -574,19 +574,13 @@ static size_t audio_pcm_sw_get_rpos_in(SWVoiceIn *sw) { HWVoiceIn *hw =3D sw->hw; ssize_t live =3D hw->total_samples_captured - sw->total_hw_samples_acq= uired; - ssize_t rpos; =20 if (audio_bug(__func__, live < 0 || live > hw->conv_buf->size)) { dolog("live=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_buf-= >size); return 0; } =20 - rpos =3D hw->conv_buf->pos - live; - if (rpos >=3D 0) { - return rpos; - } else { - return hw->conv_buf->size + rpos; - } + return audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); } =20 static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size) @@ -1394,12 +1388,10 @@ void audio_generic_run_buffer_in(HWVoiceIn *hw) =20 void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size) { - ssize_t start =3D (ssize_t)hw->pos_emul - hw->pending_emul; + size_t start; =20 - if (start < 0) { - start +=3D hw->size_emul; - } - assert(start >=3D 0 && start < hw->size_emul); + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size_emu= l); + assert(start < hw->size_emul); =20 *size =3D MIN(*size, hw->pending_emul); *size =3D MIN(*size, hw->size_emul - start); @@ -1415,13 +1407,10 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, voi= d *buf, size_t size) void audio_generic_run_buffer_out(HWVoiceOut *hw) { while (hw->pending_emul) { - size_t write_len, written; - ssize_t start =3D ((ssize_t) hw->pos_emul) - hw->pending_emul; + size_t write_len, written, start; =20 - if (start < 0) { - start +=3D hw->size_emul; - } - assert(start >=3D 0 && start < hw->size_emul); + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size= _emul); + assert(start < hw->size_emul); =20 write_len =3D MIN(hw->pending_emul, hw->size_emul - start); =20 diff --git a/audio/audio_int.h b/audio/audio_int.h index 428a091d05..928d8e107e 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -266,6 +266,8 @@ static inline size_t audio_ring_dist(size_t dst, size_t= src, size_t len) return (dst >=3D src) ? (dst - src) : (len - src + dst); } =20 +#define audio_ring_posb(pos, dist, len) audio_ring_dist(pos, dist, len) + #define dolog(fmt, ...) AUD_log(AUDIO_CAP, fmt, ## __VA_ARGS__) =20 #ifdef DEBUG diff --git a/audio/coreaudio.c b/audio/coreaudio.c index d8a21d3e50..1fdd1d4b14 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -333,12 +333,10 @@ static OSStatus audioDeviceIOProc( =20 len =3D frameCount * hw->info.bytes_per_frame; while (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); + size_t write_len, start; + + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, hw->size= _emul); + assert(start < hw->size_emul); =20 write_len =3D MIN(MIN(hw->pending_emul, len), hw->size_emul - start); diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index c68c62a3e4..d6f3aa1a9a 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -224,12 +224,11 @@ static void sdl_callback_out(void *opaque, Uint8 *buf= , int len) /* dolog("callback_out: 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); + size_t write_len, start; + + start =3D audio_ring_posb(hw->pos_emul, hw->pending_emul, + hw->size_emul); + assert(start < hw->size_emul); =20 write_len =3D MIN(MIN(hw->pending_emul, len), hw->size_emul - start); --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641481677072790.6510067363131; Thu, 6 Jan 2022 07:07:57 -0800 (PST) Received: from localhost ([::1]:45360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UMt-0005f5-PV for importer@patchew.org; Thu, 06 Jan 2022 10:07:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P12-0005sA-A6 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:03 -0500 Received: from mailout05.t-online.de ([194.25.134.82]:40106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P10-0006XE-K1 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:00 -0500 Received: from fwd71.dcpf.telekom.de (fwd71.aul.t-online.de [10.223.144.97]) by mailout05.t-online.de (Postfix) with SMTP id 2F6D144D3; Thu, 6 Jan 2022 10:23:36 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd71.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5Ozf-2A3cH30; Thu, 6 Jan 2022 10:23:35 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id D2512200620; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 02/15] audio: move function audio_pcm_hw_clip_out() Date: Thu, 6 Jan 2022 10:23:19 +0100 Message-Id: <20220106092332.7223-2-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461016-00001674-F5712C01/0/0 CLEAN NORMAL X-TOI-MSGID: 4ddef1b4-3e23-429e-9b59-3c61dd31af1c 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:04:59 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641481679080100001 From: Volker R=C3=BCmelin Move the function audio_pcm_hw_clip_out() into the correct section 'Hard voice (playback)'. Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- audio/audio.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index e7a139e289..dfd32912da 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -548,25 +548,6 @@ static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) return live; } =20 -static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) -{ - size_t clipped =3D 0; - size_t pos =3D hw->mix_buf->pos; - - while (len) { - st_sample *src =3D hw->mix_buf->samples + pos; - uint8_t *dst =3D advance(pcm_buf, clipped * hw->info.bytes_per_fra= me); - size_t samples_till_end_of_buf =3D hw->mix_buf->size - pos; - size_t samples_to_clip =3D MIN(len, samples_till_end_of_buf); - - hw->clip(dst, src, samples_to_clip); - - pos =3D (pos + samples_to_clip) % hw->mix_buf->size; - len -=3D samples_to_clip; - clipped +=3D samples_to_clip; - } -} - /* * Soft voice (capture) */ @@ -677,6 +658,25 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *h= w, int *nb_live) return 0; } =20 +static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) +{ + size_t clipped =3D 0; + size_t pos =3D hw->mix_buf->pos; + + while (len) { + st_sample *src =3D hw->mix_buf->samples + pos; + uint8_t *dst =3D advance(pcm_buf, clipped * hw->info.bytes_per_fra= me); + size_t samples_till_end_of_buf =3D hw->mix_buf->size - pos; + size_t samples_to_clip =3D MIN(len, samples_till_end_of_buf); + + hw->clip(dst, src, samples_to_clip); + + pos =3D (pos + samples_to_clip) % hw->mix_buf->size; + len -=3D samples_to_clip; + clipped +=3D samples_to_clip; + } +} + /* * Soft voice (playback) */ --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641481682591936.7671316915911; Thu, 6 Jan 2022 07:08:02 -0800 (PST) Received: from localhost ([::1]:45526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UMz-0005lu-GT for importer@patchew.org; Thu, 06 Jan 2022 10:08:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P2I-00062W-Cr for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:26:18 -0500 Received: from mailout08.t-online.de ([194.25.134.20]:55158) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P2G-00074a-RN for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:26:18 -0500 Received: from fwd77.dcpf.telekom.de (fwd77.aul.t-online.de [10.223.144.103]) by mailout08.t-online.de (Postfix) with SMTP id 550AD14532; Thu, 6 Jan 2022 10:26:02 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd77.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5Ozi-44Nb1d0; Thu, 6 Jan 2022 10:23:38 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id D3D4D200621; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 03/15] audio: add function audio_pcm_hw_conv_in() Date: Thu, 6 Jan 2022 10:23:20 +0100 Message-Id: <20220106092332.7223-3-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461018-0001606D-116FBED2/0/0 CLEAN NORMAL X-TOI-MSGID: cbcdfea4-d84e-4208-8d05-b0e46116deb0 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:05:01 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641481683033100002 From: Volker R=C3=BCmelin Add a function audio_pcm_hw_conv_in() similar to the existing counterpart function audio_pcm_hw_clip_out(). This function reduces the number of calls to the pcm_ops functions get_buffer_in() and put_buffer_in(). That's one less call to get_buffer_in() and put_buffer_in() every time the conv_buffer wraps around. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index dfd32912da..f28e91853f 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -548,6 +548,24 @@ static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw) return live; } =20 +static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, void *pcm_buf, size_t sa= mples) +{ + size_t conv =3D 0; + STSampleBuffer *conv_buf =3D hw->conv_buf; + + while (samples) { + uint8_t *src =3D advance(pcm_buf, conv * hw->info.bytes_per_frame); + size_t proc =3D MIN(samples, conv_buf->size - conv_buf->pos); + + hw->conv(conv_buf->samples + conv_buf->pos, src, proc); + conv_buf->pos =3D (conv_buf->pos + proc) % conv_buf->size; + samples -=3D proc; + conv +=3D proc; + } + + return conv; +} + /* * Soft voice (capture) */ @@ -1219,7 +1237,6 @@ static void audio_run_out (AudioState *s) static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, size_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); @@ -1235,11 +1252,7 @@ static size_t audio_pcm_hw_run_in(HWVoiceIn *hw, siz= e_t samples) break; } =20 - proc =3D MIN(size / hw->info.bytes_per_frame, - conv_buf->size - conv_buf->pos); - - hw->conv(conv_buf->samples + conv_buf->pos, buf, proc); - conv_buf->pos =3D (conv_buf->pos + proc) % conv_buf->size; + proc =3D audio_pcm_hw_conv_in(hw, buf, size / hw->info.bytes_per_f= rame); =20 samples -=3D proc; conv +=3D proc; --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641482023548853.8765345645107; Thu, 6 Jan 2022 07:13:43 -0800 (PST) Received: from localhost ([::1]:34838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5USU-0000oM-Ie for importer@patchew.org; Thu, 06 Jan 2022 10:13:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P17-0005tz-0n for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:09 -0500 Received: from mailout02.t-online.de ([194.25.134.17]:37608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P15-0006Xz-7Q for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:04 -0500 Received: from fwd89.dcpf.telekom.de (fwd89.aul.t-online.de [10.223.144.115]) by mailout02.t-online.de (Postfix) with SMTP id C35398ADE; Thu, 6 Jan 2022 10:23:41 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd89.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5Ozk-0WiXmz0; Thu, 6 Jan 2022 10:23:41 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id D6165200623; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 04/15] audio: inline function audio_pcm_sw_get_rpos_in() Date: Thu, 6 Jan 2022 10:23:21 +0100 Message-Id: <20220106092332.7223-4-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461021-0000F5B3-18BCDE6D/0/0 CLEAN NORMAL X-TOI-MSGID: efee966b-d942-4678-b25f-42246549effc 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:05:00 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641482024243100003 From: Volker R=C3=BCmelin Simplify code by inlining function audio_pcm_sw_get_rpos_in() at the only call site and remove the duplicated audio_bug() test. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index f28e91853f..35437986d9 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -569,37 +569,24 @@ static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, voi= d *pcm_buf, size_t samples) /* * Soft voice (capture) */ -static size_t audio_pcm_sw_get_rpos_in(SWVoiceIn *sw) -{ - HWVoiceIn *hw =3D sw->hw; - ssize_t live =3D hw->total_samples_captured - sw->total_hw_samples_acq= uired; - - if (audio_bug(__func__, live < 0 || live > hw->conv_buf->size)) { - dolog("live=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_buf-= >size); - return 0; - } - - return audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); -} - static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size) { HWVoiceIn *hw =3D sw->hw; size_t samples, live, ret =3D 0, swlim, isamp, osamp, rpos, total =3D = 0; struct st_sample *src, *dst =3D sw->buf; =20 - rpos =3D audio_pcm_sw_get_rpos_in(sw) % hw->conv_buf->size; - live =3D hw->total_samples_captured - sw->total_hw_samples_acquired; + if (!live) { + return 0; + } if (audio_bug(__func__, live > hw->conv_buf->size)) { dolog("live_in=3D%zu hw->conv_buf->size=3D%zu\n", live, hw->conv_b= uf->size); return 0; } =20 + rpos =3D audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size); + samples =3D size / sw->info.bytes_per_frame; - if (!live) { - return 0; - } =20 swlim =3D (live * sw->ratio) >> 32; swlim =3D MIN (swlim, samples); --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641481783481207.60205391131365; Thu, 6 Jan 2022 07:09:43 -0800 (PST) Received: from localhost ([::1]:51090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UOc-00014f-Bg for importer@patchew.org; Thu, 06 Jan 2022 10:09:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P14-0005tY-AC for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:03 -0500 Received: from mailout05.t-online.de ([194.25.134.82]:40258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P11-0006XK-Dp for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:01 -0500 Received: from fwd71.dcpf.telekom.de (fwd71.aul.t-online.de [10.223.144.97]) by mailout05.t-online.de (Postfix) with SMTP id 7C9EC1804B; Thu, 6 Jan 2022 10:23:45 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd71.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5Ozn-0k7odV0; Thu, 6 Jan 2022 10:23:43 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id D8345200625; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 05/15] paaudio: increase default latency to 46ms Date: Thu, 6 Jan 2022 10:23:22 +0100 Message-Id: <20220106092332.7223-5-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461023-00001674-FB04F9C7/0/0 CLEAN NORMAL X-TOI-MSGID: 2d3263b5-bcd1-4e8a-bd19-cf6fc7ff7016 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:05:00 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641481784192100001 From: Volker R=C3=BCmelin This is a patch to improve the pulseaudio playback experience. Asking pulseaudio for a playback latency of 15ms is quite demanding. Increase this to 46ms. The total playback latency now is 31ms larger. One of the next patches will reduce the total playback latency again by more than 46ms. Here is a quote from the PulseAudio Latency Control documentation: 'For the sake of (...) drop-out safety always make sure to pick the highest latency possible that fulfills your needs.' Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 75401d5391..9df1e69c08 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -744,7 +744,7 @@ static int qpa_validate_per_direction_opts(Audiodev *de= v, { if (!pdo->has_latency) { pdo->has_latency =3D true; - pdo->latency =3D 15000; + pdo->latency =3D 46440; } return 1; } --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164148184809992.3914916532027; Thu, 6 Jan 2022 07:10:48 -0800 (PST) Received: from localhost ([::1]:54216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UPf-00037f-3l for importer@patchew.org; Thu, 06 Jan 2022 10:10:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Ozw-0005Y2-I5 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:23:52 -0500 Received: from mailout08.t-online.de ([194.25.134.20]:53722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Ozv-0006R6-47 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:23:52 -0500 Received: from fwd83.dcpf.telekom.de (fwd83.aul.t-online.de [10.223.144.109]) by mailout08.t-online.de (Postfix) with SMTP id CB92391F9; Thu, 6 Jan 2022 10:23:46 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd83.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5Ozq-4K7me90; Thu, 6 Jan 2022 10:23:46 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id DA777200626; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 06/15] jackaudio: use more jack audio buffers Date: Thu, 6 Jan 2022 10:23:23 +0100 Message-Id: <20220106092332.7223-6-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461026-0000EDC4-442821A5/0/0 CLEAN NORMAL X-TOI-MSGID: e159b3b6-9498-4f3a-9ed5-28a1de6ef652 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:04:59 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Schoenebeck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641481848753100003 From: Volker R=C3=BCmelin The next patch reduces the effective qemu playback buffer size by timer-period. Increase the number of jack audio buffers by one to preserve the total effective buffer size. The size of one jack audio buffer is 512 samples. With audio defaults that's 512 samples / 44100 samples/s =3D 11.6 ms and only slightly larger than the timer-period of 10 ms. Signed-off-by: Volker R=C3=BCmelin --- audio/jackaudio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/jackaudio.c b/audio/jackaudio.c index e7de6d5433..fe4d9d54c6 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -483,8 +483,8 @@ static int qjack_client_init(QJackClient *c) c->buffersize =3D 512; } =20 - /* create a 2 period buffer */ - qjack_buffer_create(&c->fifo, c->nchannels, c->buffersize * 2); + /* create a 3 period buffer */ + qjack_buffer_create(&c->fifo, c->nchannels, c->buffersize * 3); =20 qjack_client_connect_ports(c); c->state =3D QJACK_STATE_RUNNING; --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641482385582386.435951650108; Thu, 6 Jan 2022 07:19:45 -0800 (PST) Received: from localhost ([::1]:51280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UYK-0003bd-KV for importer@patchew.org; Thu, 06 Jan 2022 10:19:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P2Q-00063i-Br for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:26:26 -0500 Received: from mailout07.t-online.de ([194.25.134.83]:49290) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P2K-00074m-FT for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:26:22 -0500 Received: from fwd88.dcpf.telekom.de (fwd88.aul.t-online.de [10.223.144.114]) by mailout07.t-online.de (Postfix) with SMTP id 6EED2CC86; Thu, 6 Jan 2022 10:23:49 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd88.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5Ozs-0w4LLN0; Thu, 6 Jan 2022 10:23:49 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id DCD7A200627; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 07/15] audio: copy playback stream in sequential order Date: Thu, 6 Jan 2022 10:23:24 +0100 Message-Id: <20220106092332.7223-7-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461029-00013579-8CB58DE5/0/0 CLEAN NORMAL X-TOI-MSGID: 2eb07e8c-9816-4a19-b980-842675530181 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:05:02 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Schoenebeck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641482386929100001 From: Volker R=C3=BCmelin Change the code to copy the playback stream in sequential order. The advantage can be seen in the next patches where the stream copy operation effectively becomes a write through operation. The following diagram shows the average buffer fill level and the stream copy sequence. ### represents a timer_period sized chunk. The rest of the buffer sizes are not to scale. With current code: |--------| |#####111| |---#####| sw->buf mix_buf backend buffer 1. clip |--------| |---#####| |111##222| sw->buf mix_buf backend buffer 2. write to audio device 333 -> |--------| |---#####| |---111##| -> 222 sw->buf mix_buf backend buffer 3a. sw device write |-----333| |---#####| |---111##| sw->buf mix_buf backend buffer 3b. resample and mix |--------| |333#####| |---111##| sw->buf mix_buf backend buffer With this patch: 111 -> |--------| |---#####| |---#####| sw->buf mix_buf backend buffer 1a: sw device write |-----111| |---#####| |---#####| sw->buf mix_buf backend buffer 1b. resample and mix |--------| |111##222| |---#####| sw->buf mix_buf backend buffer 2. clip |--------| |---111##| |222##333| sw->buf mix_buf backend buffer 3. write to audio device |--------| |---111##| |---222##| -> 333 sw->buf mix_buf backend buffer The effective total playback buffer size is reduced by timer_period. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 35437986d9..9e2d7fb209 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1134,6 +1134,15 @@ static void audio_run_out (AudioState *s) size_t played, live, prev_rpos, free; int nb_live; =20 + for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { + if (sw->active) { + free =3D audio_get_free(sw); + if (free > 0) { + sw->callback.fn(sw->callback.opaque, free); + } + } + } + live =3D audio_pcm_hw_get_live_out (hw, &nb_live); if (!nb_live) { live =3D 0; @@ -1162,14 +1171,6 @@ static void audio_run_out (AudioState *s) } =20 if (!live) { - for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_ne= xt) { - if (sw->active) { - free =3D audio_get_free (sw); - if (free > 0) { - sw->callback.fn (sw->callback.opaque, free); - } - } - } if (hw->pcm_ops->run_buffer_out) { hw->pcm_ops->run_buffer_out(hw); } @@ -1210,13 +1211,6 @@ static void audio_run_out (AudioState *s) if (!sw->total_hw_samples_mixed) { sw->empty =3D 1; } - - if (sw->active) { - free =3D audio_get_free (sw); - if (free > 0) { - sw->callback.fn (sw->callback.opaque, free); - } - } } } } --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641482024206435.762573807746; Thu, 6 Jan 2022 07:13:44 -0800 (PST) Received: from localhost ([::1]:34842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5USU-0000oR-TF for importer@patchew.org; Thu, 06 Jan 2022 10:13:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Ozy-0005bX-Pl for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:23:54 -0500 Received: from mailout12.t-online.de ([194.25.134.22]:47670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5Ozx-0006RV-6T for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:23:54 -0500 Received: from fwd75.dcpf.telekom.de (fwd75.aul.t-online.de [10.223.144.101]) by mailout12.t-online.de (Postfix) with SMTP id C94F4AC9E; Thu, 6 Jan 2022 10:23:51 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd75.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5Ozv-2Nmgdt0; Thu, 6 Jan 2022 10:23:51 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id DEE07200628; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 08/15] audio: add pcm_ops function table for capture backend Date: Thu, 6 Jan 2022 10:23:25 +0100 Message-Id: <20220106092332.7223-8-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461031-000184BD-37AA465C/0/0 CLEAN NORMAL X-TOI-MSGID: 4937adab-2bed-4359-944e-d01614863354 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:04:59 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641482026269100005 From: Volker R=C3=BCmelin Add a pcm_ops function table for the capture backend. This avoids additional code in the next patches to test if the pcm_ops table is available. Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/audio/audio.c b/audio/audio.c index 9e2d7fb209..55f885f8e9 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1804,6 +1804,7 @@ void AUD_remove_card (QEMUSoundCard *card) g_free (card->name); } =20 +static struct audio_pcm_ops capture_pcm_ops; =20 CaptureVoiceOut *AUD_add_capture( AudioState *s, @@ -1849,6 +1850,7 @@ CaptureVoiceOut *AUD_add_capture( =20 hw =3D &cap->hw; hw->s =3D s; + hw->pcm_ops =3D &capture_pcm_ops; QLIST_INIT (&hw->sw_head); QLIST_INIT (&cap->cb_head); =20 --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641481682067273.30648843762265; Thu, 6 Jan 2022 07:08:02 -0800 (PST) Received: from localhost ([::1]:45524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UMy-0005lq-RZ for importer@patchew.org; Thu, 06 Jan 2022 10:08:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P1h-0005z0-7X for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:41 -0500 Received: from mailout10.t-online.de ([194.25.134.21]:54132) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P1f-0006xO-JN for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:40 -0500 Received: from fwd71.dcpf.telekom.de (fwd71.aul.t-online.de [10.223.144.97]) by mailout10.t-online.de (Postfix) with SMTP id 8DFFE79D0; Thu, 6 Jan 2022 10:23:54 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd71.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5Ozx-27HTer0; Thu, 6 Jan 2022 10:23:53 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E0EB420062A; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 09/15] audio: revert tests for pcm_ops table Date: Thu, 6 Jan 2022 10:23:26 +0100 Message-Id: <20220106092332.7223-9-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461033-00001674-206ECA61/0/0 CLEAN NORMAL X-TOI-MSGID: 51243944-2fb0-4996-af74-da88a0598ceb 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.21; envelope-from=volker.ruemelin@t-online.de; helo=mailout10.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-Mailman-Approved-At: Thu, 06 Jan 2022 10:05:00 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641481683030100001 From: Volker R=C3=BCmelin With previous commit every audio backend has a pcm_ops function table. It's no longer necessary to test if the table is available. This reverts commit cbaf25d1f5: "audio: fix wavcapture segfault" Signed-off-by: Volker R=C3=BCmelin --- audio/audio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 55f885f8e9..c420a8bd1c 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -612,7 +612,7 @@ static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *bu= f, size_t size) total +=3D isamp; } =20 - if (hw->pcm_ops && !hw->pcm_ops->volume_in) { + if (!hw->pcm_ops->volume_in) { mixeng_volume (sw->buf, ret, &sw->vol); } =20 @@ -718,7 +718,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) if (swlim) { sw->conv (sw->buf, buf, swlim); =20 - if (sw->hw->pcm_ops && !sw->hw->pcm_ops->volume_out) { + if (!sw->hw->pcm_ops->volume_out) { mixeng_volume (sw->buf, swlim, &sw->vol); } } --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16414820208251016.0645878269319; Thu, 6 Jan 2022 07:13:40 -0800 (PST) Received: from localhost ([::1]:34634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5USR-0000eu-LU for importer@patchew.org; Thu, 06 Jan 2022 10:13:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P0k-0005qP-EW for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:24:42 -0500 Received: from mailout09.t-online.de ([194.25.134.84]:56964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P0i-0006VK-8K for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:24:42 -0500 Received: from fwd85.dcpf.telekom.de (fwd85.aul.t-online.de [10.223.144.111]) by mailout09.t-online.de (Postfix) with SMTP id 658A61094E; Thu, 6 Jan 2022 10:23:57 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd85.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5P00-03wjWj0; Thu, 6 Jan 2022 10:23:56 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E354B20062B; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 10/15] audio: restore mixing-engine playback buffer size Date: Thu, 6 Jan 2022 10:23:27 +0100 Message-Id: <20220106092332.7223-10-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461036-00014AB5-E253CD9B/0/0 CLEAN NORMAL X-TOI-MSGID: db986569-e668-426d-9e7a-45c5bd2dea6c 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:04:59 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Christian Schoenebeck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641482022288100001 From: Volker R=C3=BCmelin Commit ff095e5231 "audio: api for mixeng code free backends" introduced another FIFO for the audio subsystem with exactly the same size as the mixing-engine FIFO. Most audio backends use this generic FIFO. The generic FIFO used together with the mixing-engine FIFO doubles the audio FIFO size, because that's just two independent FIFOs connected together in series. For audio playback this nearly doubles the playback latency. This patch restores the effective mixing-engine playback buffer size to a pre v4.2.0 size by only accepting the amount of samples for the mixing-engine queue which the downstream queue accepts. Signed-off-by: Volker R=C3=BCmelin --- audio/alsaaudio.c | 1 + audio/audio.c | 69 +++++++++++++++++++++++++++++++++++------------ audio/audio_int.h | 7 ++++- audio/coreaudio.c | 3 +++ audio/jackaudio.c | 1 + audio/noaudio.c | 1 + audio/ossaudio.c | 12 +++++++++ audio/sdlaudio.c | 3 +++ audio/wavaudio.c | 1 + 9 files changed, 80 insertions(+), 18 deletions(-) diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 2b9789e647..b04716a6cc 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -916,6 +916,7 @@ static struct audio_pcm_ops alsa_pcm_ops =3D { .init_out =3D alsa_init_out, .fini_out =3D alsa_fini_out, .write =3D alsa_write, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D alsa_enable_out, =20 diff --git a/audio/audio.c b/audio/audio.c index c420a8bd1c..a88572e713 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -663,6 +663,12 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *h= w, int *nb_live) return 0; } =20 +static size_t audio_pcm_hw_get_free(HWVoiceOut *hw) +{ + return (hw->pcm_ops->buffer_get_free ? hw->pcm_ops->buffer_get_free(hw= ) : + INT_MAX) / hw->info.bytes_per_frame; +} + static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t le= n) { size_t clipped =3D 0; @@ -687,7 +693,8 @@ static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void = *pcm_buf, size_t len) */ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size) { - size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, swlim= , blck; + size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, blck; + size_t hw_free; size_t ret =3D 0, pos =3D 0, total =3D 0; =20 if (!sw) { @@ -710,27 +717,28 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void= *buf, size_t size) } =20 wpos =3D (sw->hw->mix_buf->pos + live) % hwsamples; - samples =3D size / sw->info.bytes_per_frame; =20 dead =3D hwsamples - live; - swlim =3D ((int64_t) dead << 32) / sw->ratio; - swlim =3D MIN (swlim, samples); - if (swlim) { - sw->conv (sw->buf, buf, swlim); + hw_free =3D audio_pcm_hw_get_free(sw->hw); + hw_free =3D hw_free > live ? hw_free - live : 0; + samples =3D ((int64_t)MIN(dead, hw_free) << 32) / sw->ratio; + samples =3D MIN(samples, size / sw->info.bytes_per_frame); + if (samples) { + sw->conv(sw->buf, buf, samples); =20 if (!sw->hw->pcm_ops->volume_out) { - mixeng_volume (sw->buf, swlim, &sw->vol); + mixeng_volume(sw->buf, samples, &sw->vol); } } =20 - while (swlim) { + while (samples) { dead =3D hwsamples - live; left =3D hwsamples - wpos; blck =3D MIN (dead, left); if (!blck) { break; } - isamp =3D swlim; + isamp =3D samples; osamp =3D blck; st_rate_flow_mix ( sw->rate, @@ -740,7 +748,7 @@ static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *= buf, size_t size) &osamp ); ret +=3D isamp; - swlim -=3D isamp; + samples -=3D isamp; pos +=3D isamp; live +=3D osamp; wpos =3D (wpos + osamp) % hwsamples; @@ -1002,6 +1010,11 @@ static size_t audio_get_avail (SWVoiceIn *sw) return (((int64_t) live << 32) / sw->ratio) * sw->info.bytes_per_frame; } =20 +static size_t audio_sw_bytes_free(SWVoiceOut *sw, size_t free) +{ + return (((int64_t)free << 32) / sw->ratio) * sw->info.bytes_per_frame; +} + static size_t audio_get_free(SWVoiceOut *sw) { size_t live, dead; @@ -1021,13 +1034,11 @@ static size_t audio_get_free(SWVoiceOut *sw) dead =3D sw->hw->mix_buf->size - live; =20 #ifdef DEBUG_OUT - dolog ("%s: get_free live %zu dead %zu ret %" PRId64 "\n", - SW_NAME (sw), - live, dead, (((int64_t) dead << 32) / sw->ratio) * - sw->info.bytes_per_frame); + dolog("%s: get_free live %zu dead %zu sw_bytes %zu\n", + SW_NAME(sw), live, dead, audio_sw_bytes_free(sw, dead)); #endif =20 - return (((int64_t) dead << 32) / sw->ratio) * sw->info.bytes_per_frame; + return dead; } =20 static void audio_capture_mix_and_clear(HWVoiceOut *hw, size_t rpos, @@ -1131,12 +1142,21 @@ 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; + size_t played, live, prev_rpos; + size_t hw_free =3D audio_pcm_hw_get_free(hw); int nb_live; =20 for (sw =3D hw->sw_head.lh_first; sw; sw =3D sw->entries.le_next) { if (sw->active) { - free =3D audio_get_free(sw); + size_t sw_free =3D audio_get_free(sw); + size_t free; + + if (hw_free > sw->total_hw_samples_mixed) { + free =3D audio_sw_bytes_free(sw, + MIN(sw_free, hw_free - sw->total_hw_samples_mixed)= ); + } else { + free =3D 0; + } if (free > 0) { sw->callback.fn(sw->callback.opaque, free); } @@ -1398,6 +1418,15 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, void= *buf, size_t size) hw->pending_emul -=3D size; } =20 +size_t audio_generic_buffer_get_free(HWVoiceOut *hw) +{ + if (hw->buf_emul) { + return hw->size_emul - hw->pending_emul; + } else { + return hw->samples * hw->info.bytes_per_frame; + } +} + void audio_generic_run_buffer_out(HWVoiceOut *hw) { while (hw->pending_emul) { @@ -1445,6 +1474,12 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf= , size_t size) { size_t total =3D 0; =20 + if (hw->pcm_ops->buffer_get_free) { + size_t free =3D hw->pcm_ops->buffer_get_free(hw); + + size =3D MIN(size, free); + } + while (total < size) { size_t dst_size =3D size - total; size_t copy_size, proc; diff --git a/audio/audio_int.h b/audio/audio_int.h index 928d8e107e..3c6a5eaa86 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -161,10 +161,14 @@ struct audio_pcm_ops { void (*fini_out)(HWVoiceOut *hw); size_t (*write) (HWVoiceOut *hw, void *buf, size_t size); void (*run_buffer_out)(HWVoiceOut *hw); + /* + * Get the free output buffer size. This is an upper limit. The size + * returned by function get_buffer_out may be smaller. + */ + size_t (*buffer_get_free)(HWVoiceOut *hw); /* * get a buffer that after later can be passed to put_buffer_out; opti= onal * returns the buffer, and writes it's size to size (in bytes) - * this is unrelated to the above buffer_size_out function */ void *(*get_buffer_out)(HWVoiceOut *hw, size_t *size); /* @@ -190,6 +194,7 @@ 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); +size_t audio_generic_buffer_get_free(HWVoiceOut *hw); void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size); size_t audio_generic_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size= ); size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size); diff --git a/audio/coreaudio.c b/audio/coreaudio.c index 1fdd1d4b14..91ea6ae975 100644 --- a/audio/coreaudio.c +++ b/audio/coreaudio.c @@ -283,6 +283,7 @@ static int coreaudio_buf_unlock (coreaudioVoiceOut *cor= e, const char *fn_name) coreaudio_buf_unlock(core, "coreaudio_" #name); \ return ret; \ } +COREAUDIO_WRAPPER_FUNC(buffer_get_free, size_t, (HWVoiceOut *hw), (hw)) COREAUDIO_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *si= ze), (hw, size)) COREAUDIO_WRAPPER_FUNC(put_buffer_out, size_t, @@ -652,6 +653,8 @@ static struct audio_pcm_ops coreaudio_pcm_ops =3D { .fini_out =3D coreaudio_fini_out, /* wrapper for audio_generic_write */ .write =3D coreaudio_write, + /* wrapper for audio_generic_buffer_get_free */ + .buffer_get_free =3D coreaudio_buffer_get_free, /* wrapper for audio_generic_get_buffer_out */ .get_buffer_out =3D coreaudio_get_buffer_out, /* wrapper for audio_generic_put_buffer_out */ diff --git a/audio/jackaudio.c b/audio/jackaudio.c index fe4d9d54c6..18c9fc666e 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -650,6 +650,7 @@ static struct audio_pcm_ops jack_pcm_ops =3D { .init_out =3D qjack_init_out, .fini_out =3D qjack_fini_out, .write =3D qjack_write, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D qjack_enable_out, =20 diff --git a/audio/noaudio.c b/audio/noaudio.c index aac87dbc93..84a6bfbb1c 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -118,6 +118,7 @@ static struct audio_pcm_ops no_pcm_ops =3D { .init_out =3D no_init_out, .fini_out =3D no_fini_out, .write =3D no_write, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D no_enable_out, =20 diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 60eff66424..1bd6800840 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -389,6 +389,17 @@ static void oss_run_buffer_out(HWVoiceOut *hw) } } =20 +static size_t oss_buffer_get_free(HWVoiceOut *hw) +{ + OSSVoiceOut *oss =3D (OSSVoiceOut *)hw; + + if (oss->mmapped) { + return INT_MAX; + } else { + return audio_generic_buffer_get_free(hw); + } +} + static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size) { OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; @@ -750,6 +761,7 @@ static struct audio_pcm_ops oss_pcm_ops =3D { .init_out =3D oss_init_out, .fini_out =3D oss_fini_out, .write =3D oss_write, + .buffer_get_free =3D oss_buffer_get_free, .run_buffer_out =3D oss_run_buffer_out, .get_buffer_out =3D oss_get_buffer_out, .put_buffer_out =3D oss_put_buffer_out, diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index d6f3aa1a9a..e605c787ba 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -309,6 +309,7 @@ static void sdl_callback_in(void *opaque, Uint8 *buf, i= nt len) SDL_UnlockAudioDevice(sdl->devid); \ } =20 +SDL_WRAPPER_FUNC(buffer_get_free, size_t, (HWVoiceOut *hw), (hw), Out) SDL_WRAPPER_FUNC(get_buffer_out, void *, (HWVoiceOut *hw, size_t *size), (hw, size), Out) SDL_WRAPPER_FUNC(put_buffer_out, size_t, @@ -471,6 +472,8 @@ static struct audio_pcm_ops sdl_pcm_ops =3D { .fini_out =3D sdl_fini_out, /* wrapper for audio_generic_write */ .write =3D sdl_write, + /* wrapper for audio_generic_buffer_get_free */ + .buffer_get_free =3D sdl_buffer_get_free, /* wrapper for audio_generic_get_buffer_out */ .get_buffer_out =3D sdl_get_buffer_out, /* wrapper for audio_generic_put_buffer_out */ diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 20e6853f85..ac666335c7 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -197,6 +197,7 @@ static struct audio_pcm_ops wav_pcm_ops =3D { .init_out =3D wav_init_out, .fini_out =3D wav_fini_out, .write =3D wav_write_out, + .buffer_get_free =3D audio_generic_buffer_get_free, .run_buffer_out =3D audio_generic_run_buffer_out, .enable_out =3D wav_enable_out, }; --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641482225114862.4122617285401; Thu, 6 Jan 2022 07:17:05 -0800 (PST) Received: from localhost ([::1]:43332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UVk-0006cL-5R for importer@patchew.org; Thu, 06 Jan 2022 10:17:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P2Q-00063j-Bw for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:26:26 -0500 Received: from mailout07.t-online.de ([194.25.134.83]:49390) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P2L-00074o-8f for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:26:26 -0500 Received: from fwd73.dcpf.telekom.de (fwd73.aul.t-online.de [10.223.144.99]) by mailout07.t-online.de (Postfix) with SMTP id 919AF120CE; Thu, 6 Jan 2022 10:23:59 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd73.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5P03-0uANMX0; Thu, 6 Jan 2022 10:23:59 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E570E20062C; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 11/15] paaudio: reduce effective playback buffer size Date: Thu, 6 Jan 2022 10:23:28 +0100 Message-Id: <20220106092332.7223-11-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461039-0000C4DD-34E3DC02/0/0 CLEAN NORMAL X-TOI-MSGID: 0a245fd0-ebbc-49f8-96b9-c3632ef565ca 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:05:02 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641482225612100001 From: Volker R=C3=BCmelin Add the buffer_get_free pcm_ops function to reduce the effective playback buffer size. All intermediate audio playback buffers become temporary buffers. Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index 9df1e69c08..d94f858ec7 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -201,13 +201,11 @@ unlock_and_fail: return 0; } =20 -static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t *size) +static size_t qpa_buffer_get_free(HWVoiceOut *hw) { - PAVoiceOut *p =3D (PAVoiceOut *) hw; + 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); =20 @@ -216,7 +214,6 @@ static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t = *size) 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 @@ -224,16 +221,33 @@ static void *qpa_get_buffer_out(HWVoiceOut *hw, size_= t *size) CHECK_SUCCESS_GOTO(c, l !=3D (size_t) -1, unlock_and_fail, "pa_stream_writable_size failed\n"); =20 +unlock: + pa_threaded_mainloop_unlock(c->mainloop); + return l; + +unlock_and_fail: + pa_threaded_mainloop_unlock(c->mainloop); + return 0; +} + +static void *qpa_get_buffer_out(HWVoiceOut *hw, size_t *size) +{ + PAVoiceOut *p =3D (PAVoiceOut *)hw; + PAConnection *c =3D p->g->conn; + void *ret; + int r; + + pa_threaded_mainloop_lock(c->mainloop); + + CHECK_DEAD_GOTO(c, p->stream, unlock_and_fail, + "pa_threaded_mainloop_lock 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 -unlock: pa_threaded_mainloop_unlock(c->mainloop); - if (*size > l) { - *size =3D l; - } return ret; =20 unlock_and_fail: @@ -901,6 +915,7 @@ static struct audio_pcm_ops qpa_pcm_ops =3D { .init_out =3D qpa_init_out, .fini_out =3D qpa_fini_out, .write =3D qpa_write, + .buffer_get_free =3D qpa_buffer_get_free, .get_buffer_out =3D qpa_get_buffer_out, .put_buffer_out =3D qpa_put_buffer_out, .volume_out =3D qpa_volume_out, --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641482100581362.3154992060049; Thu, 6 Jan 2022 07:15:00 -0800 (PST) Received: from localhost ([::1]:40068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UTj-0004HB-IG for importer@patchew.org; Thu, 06 Jan 2022 10:14:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P1h-0005z9-Sw for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:41 -0500 Received: from mailout10.t-online.de ([194.25.134.21]:54254) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P1g-0006z3-DM for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:41 -0500 Received: from fwd82.dcpf.telekom.de (fwd82.aul.t-online.de [10.223.144.108]) by mailout10.t-online.de (Postfix) with SMTP id CE96416A52; Thu, 6 Jan 2022 10:24:01 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd82.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5P05-0YYf5N0; Thu, 6 Jan 2022 10:24:01 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E76A220062E; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 12/15] dsoundaudio: reduce effective playback buffer size Date: Thu, 6 Jan 2022 10:23:29 +0100 Message-Id: <20220106092332.7223-12-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461041-0000B8A1-1277E1E0/0/0 CLEAN NORMAL X-TOI-MSGID: fcd145b2-d2ef-4781-a216-007534e6505e 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.21; envelope-from=volker.ruemelin@t-online.de; helo=mailout10.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-Mailman-Approved-At: Thu, 06 Jan 2022 10:05:00 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641482102461100001 From: Volker R=C3=BCmelin Add the buffer_get_free pcm_ops function to reduce the effective playback buffer size. All intermediate audio playback buffers become temporary buffers. Signed-off-by: Volker R=C3=BCmelin --- audio/dsoundaudio.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index cfc79c129e..1f743866e8 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -427,22 +427,18 @@ static void dsound_enable_out(HWVoiceOut *hw, bool en= able) } } =20 -static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size) +static size_t dsound_buffer_get_free(HWVoiceOut *hw) { DSoundVoiceOut *ds =3D (DSoundVoiceOut *) hw; LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; HRESULT hr; - DWORD ppos, wpos, act_size; - size_t req_size; - int err; - void *ret; + DWORD ppos, wpos; =20 hr =3D IDirectSoundBuffer_GetCurrentPosition( dsb, &ppos, ds->first_time ? &wpos : NULL); if (FAILED(hr)) { dsound_logerr(hr, "Could not get playback buffer position\n"); - *size =3D 0; - return NULL; + return 0; } =20 if (ds->first_time) { @@ -450,13 +446,20 @@ static void *dsound_get_buffer_out(HWVoiceOut *hw, si= ze_t *size) ds->first_time =3D false; } =20 - req_size =3D audio_ring_dist(ppos, hw->pos_emul, hw->size_emul); - req_size =3D MIN(req_size, hw->size_emul - hw->pos_emul); + return audio_ring_dist(ppos, hw->pos_emul, hw->size_emul); +} =20 - if (req_size =3D=3D 0) { - *size =3D 0; - return NULL; - } +static void *dsound_get_buffer_out(HWVoiceOut *hw, size_t *size) +{ + DSoundVoiceOut *ds =3D (DSoundVoiceOut *)hw; + LPDIRECTSOUNDBUFFER dsb =3D ds->dsound_buffer; + DWORD act_size; + size_t req_size; + int err; + void *ret; + + req_size =3D MIN(*size, hw->size_emul - hw->pos_emul); + assert(req_size > 0); =20 err =3D dsound_lock_out(dsb, &hw->info, hw->pos_emul, req_size, &ret, = NULL, &act_size, NULL, false, ds->s); @@ -700,6 +703,7 @@ static struct audio_pcm_ops dsound_pcm_ops =3D { .init_out =3D dsound_init_out, .fini_out =3D dsound_fini_out, .write =3D audio_generic_write, + .buffer_get_free =3D dsound_buffer_get_free, .get_buffer_out =3D dsound_get_buffer_out, .put_buffer_out =3D dsound_put_buffer_out, .enable_out =3D dsound_enable_out, --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16414818481001002.0057009630692; Thu, 6 Jan 2022 07:10:48 -0800 (PST) Received: from localhost ([::1]:54166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UPf-000361-35 for importer@patchew.org; Thu, 06 Jan 2022 10:10:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P0B-0005p0-IC for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:24:07 -0500 Received: from mailout08.t-online.de ([194.25.134.20]:54212) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P0A-0006Tp-3z for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:24:07 -0500 Received: from fwd84.dcpf.telekom.de (fwd84.aul.t-online.de [10.223.144.110]) by mailout08.t-online.de (Postfix) with SMTP id 5BD5319885; Thu, 6 Jan 2022 10:24:04 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd84.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5P08-4QSBRB0; Thu, 6 Jan 2022 10:24:04 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id E97F720062F; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 13/15] ossaudio: reduce effective playback buffer size Date: Thu, 6 Jan 2022 10:23:30 +0100 Message-Id: <20220106092332.7223-13-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461044-00009E39-833AC0D4/0/0 CLEAN NORMAL X-TOI-MSGID: 95f836ff-458f-440d-a398-812bc48bdbac 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:04:59 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641481848759100004 From: Volker R=C3=BCmelin Add the buffer_get_free pcm_ops function for the mmapped case to reduce the effective playback buffer size. All intermediate audio playback buffers become temporary buffers. Signed-off-by: Volker R=C3=BCmelin --- audio/ossaudio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 1bd6800840..da9c232222 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -394,7 +394,7 @@ static size_t oss_buffer_get_free(HWVoiceOut *hw) OSSVoiceOut *oss =3D (OSSVoiceOut *)hw; =20 if (oss->mmapped) { - return INT_MAX; + return oss_get_available_bytes(oss); } else { return audio_generic_buffer_get_free(hw); } @@ -402,9 +402,10 @@ static size_t oss_buffer_get_free(HWVoiceOut *hw) =20 static void *oss_get_buffer_out(HWVoiceOut *hw, size_t *size) { - OSSVoiceOut *oss =3D (OSSVoiceOut *) hw; + OSSVoiceOut *oss =3D (OSSVoiceOut *)hw; + if (oss->mmapped) { - *size =3D MIN(oss_get_available_bytes(oss), hw->size_emul - hw->po= s_emul); + *size =3D hw->size_emul - hw->pos_emul; return hw->buf_emul + hw->pos_emul; } else { return audio_generic_get_buffer_out(hw, size); --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641482219257364.53969808197814; Thu, 6 Jan 2022 07:16:59 -0800 (PST) Received: from localhost ([::1]:43228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5UVe-0006YB-0H for importer@patchew.org; Thu, 06 Jan 2022 10:16:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P15-0005ta-LB for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:03 -0500 Received: from mailout05.t-online.de ([194.25.134.82]:40692) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P14-0006Xd-2B for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:03 -0500 Received: from fwd71.dcpf.telekom.de (fwd71.aul.t-online.de [10.223.144.97]) by mailout05.t-online.de (Postfix) with SMTP id F1BBB1001C; Thu, 6 Jan 2022 10:24:08 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd71.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5P0A-3vLSOv0; Thu, 6 Jan 2022 10:24:06 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id EBAD4200630; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 14/15] paaudio: fix samples vs. frames mix-up Date: Thu, 6 Jan 2022 10:23:31 +0100 Message-Id: <20220106092332.7223-14-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461046-00001674-F90F853F/0/0 CLEAN NORMAL X-TOI-MSGID: 13c4796f-7bce-43dc-8326-a6b1d360bbef 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:05:00 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641482221552100001 From: Volker R=C3=BCmelin Now that the mixing buffer size no longer adds to playback latency, fix the samples vs. frames mix-up in the mixing buffer size calculation. This change will go largely unnoticed as long as the user doesn't use a buffer-size smaller than timer-period. Signed-off-by: Volker R=C3=BCmelin --- audio/paaudio.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/audio/paaudio.c b/audio/paaudio.c index d94f858ec7..a53ed85e0b 100644 --- a/audio/paaudio.c +++ b/audio/paaudio.c @@ -549,11 +549,8 @@ 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( + /* hw->samples counts in frames */ + hw->samples =3D audio_buffer_frames( qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); =20 return 0; @@ -601,11 +598,8 @@ 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( + /* hw->samples counts in frames */ + hw->samples =3D audio_buffer_frames( qapi_AudiodevPaPerDirectionOptions_base(ppdo), &obt_as, 46440); =20 return 0; --=20 2.31.1 From nobody Sun Apr 28 14:05:53 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641481978876690.2639220344801; Thu, 6 Jan 2022 07:12:58 -0800 (PST) Received: from localhost ([::1]:59788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5URl-000726-IK for importer@patchew.org; Thu, 06 Jan 2022 10:12:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P1F-0005uJ-Mp for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:14 -0500 Received: from mailout02.t-online.de ([194.25.134.17]:38016) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5P1E-0006km-71 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 04:25:13 -0500 Received: from fwd80.dcpf.telekom.de (fwd80.aul.t-online.de [10.223.144.106]) by mailout02.t-online.de (Postfix) with SMTP id BE373778D; Thu, 6 Jan 2022 10:24:09 +0100 (CET) Received: from linpower.localnet ([46.86.48.20]) by fwd80.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1n5P0D-1fY0q90; Thu, 6 Jan 2022 10:24:09 +0100 Received: by linpower.localnet (Postfix, from userid 1000) id EDBF7200631; Thu, 6 Jan 2022 10:23:32 +0100 (CET) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 15/15] sdlaudio: fix samples vs. frames mix-up Date: Thu, 6 Jan 2022 10:23:32 +0100 Message-Id: <20220106092332.7223-15-volker.ruemelin@t-online.de> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TOI-EXPURGATEID: 150726::1641461049-00001C4D-DD58036B/0/0 CLEAN NORMAL X-TOI-MSGID: fda1647d-72d8-4cf4-8b8a-730ef10820bb 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-Mailman-Approved-At: Thu, 06 Jan 2022 10:05:00 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1641481980221100001 From: Volker R=C3=BCmelin Fix the same samples vs. frames mix-up that the previous commit fixed for the PulseAudio backend. Signed-off-by: Volker R=C3=BCmelin --- audio/sdlaudio.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index e605c787ba..797b47bbdd 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -347,11 +347,8 @@ static int sdl_init_out(HWVoiceOut *hw, struct audsett= ings *as, req.freq =3D as->freq; req.format =3D aud_to_sdlfmt (as->fmt); req.channels =3D as->nchannels; - /* - * 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( + /* SDL samples are QEMU frames */ + req.samples =3D audio_buffer_frames( qapi_AudiodevSdlPerDirectionOptions_base(spdo), as, 11610); req.callback =3D sdl_callback_out; req.userdata =3D sdl; --=20 2.31.1