From nobody Fri Nov 7 04:15:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547683698532562.1832167886721; Wed, 16 Jan 2019 16:08:18 -0800 (PST) Received: from localhost ([127.0.0.1]:38415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjvEH-00028t-9I for importer@patchew.org; Wed, 16 Jan 2019 19:08:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjul9-0004Qi-6q for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:38:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjul4-0003S6-Ke for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:38:11 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:46786) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gjul4-0003Kf-69 for qemu-devel@nongnu.org; Wed, 16 Jan 2019 18:38:06 -0500 Received: by mail-wr1-x442.google.com with SMTP id l9so8888921wrt.13 for ; Wed, 16 Jan 2019 15:38:03 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-e4b0-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:e4b0::5]) by smtp.gmail.com with ESMTPSA id s66sm30760437wmf.34.2019.01.16.15.38.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 15:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+GJrV0c5zzNT39TwSPxNd5uWTZp42OGxJwGSrdyqRJw=; b=RLyzQe952zw0PoyTjO6eYGpJpd4PMU4ruHmv7eubsIjkXWXmCrOtsyAfTaFud9tOLw qwGQZYENhRjIPttWpJ+d/N5QJPfxZsYnjZQoerD5y15+3Kz0Pd1Z1r0bBvn6BI1BRgja PoTo8xGtFiwChm1eCTbOZF7gqhD9ZBCZfqMrFUMUL5sbzYOR+rX1jZIufgn1VMWByNdC HLc7jnbLRXTrpwk/dgyRyvPlZext+3HIxkyH7c10KglZ44uzt5kts419A4JOxZxfnvCj fIgKamj696EVw/Dvobv2vKDvXxAn7r0UF/mU5/V4e/qmBcVEVOLIPoswtfbjy7RLve/U X6Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+GJrV0c5zzNT39TwSPxNd5uWTZp42OGxJwGSrdyqRJw=; b=uF84/vjRpx6+lEXtEk3jYKhEXk21sD/D52lcxYZRfiSaKJ3FOggwy6rkW94lh81Lqq 7LpwlVAFG9MmAtRXcK8iEQ9i3+27keIzKvz4pJek92K2yFihfqlQKmb9OEFYfs8iX1HY C1N1+IIPHoU8usoiWK6xo8ZCTlO+67fN3GSNQHhzojk3TonUuoDx3kgfPlVTTK7KnI5j gMkxduvF3RYXB/tmm7FP3UPAbfuYp+N829uULwql26UHfSItD6aU6aK4qb1Cxh2WIq0p 4Eydui4B2YltnocYHjRVxOAzjZt5zTfrB2Z41pqcbVMyMgle97ZA1a6nKMenSgdgL7lF s5NA== X-Gm-Message-State: AJcUukdH1fUlJMcHImvcJdHoZ/f6dOs9UQskMFw+88mxx5bYWHhG9Ig4 +5oaF7VXI6Zjg9YN/a/9TgXMygGB0cg= X-Google-Smtp-Source: ALg8bN4JRfBBv+Pp2dab6ZPrR6B1hzZ4j/mSo5HINLyDeJO+/1GCf8EzvLQj74AaZVYY+Md4n7k7AA== X-Received: by 2002:adf:a58a:: with SMTP id g10mr9366125wrc.3.1547681882807; Wed, 16 Jan 2019 15:38:02 -0800 (PST) From: "=?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?=" X-Google-Original-From: =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= To: qemu-devel@nongnu.org Date: Thu, 17 Jan 2019 00:37:15 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 Subject: [Qemu-devel] [PATCH v3 42/50] audio: make mixeng optional X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Implementation of the previously added mixeng option. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- audio/audio_template.h | 46 ++++++++++++++++----------- audio/audio.c | 70 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 92 insertions(+), 24 deletions(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 9ec565fc48..e5a4d6fa40 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -78,26 +78,32 @@ static void glue (audio_pcm_hw_free_resources_, TYPE) (= HW *hw) =20 static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw) { - size_t samples; - if (!hw->pcm_ops) { - /* - * We should only end up here when using wavcapture hmp command (a= nd not - * the wavcapture audio backend). - * It needs a lot of samples, otherwise you'll end up with "Could = not - * mix X bytes into a capture buffer" warnings and a garbled captu= re. - */ - samples =3D 4096 * 4; - } else if (hw->pcm_ops->glue(buffer_size_, TYPE)) { - samples =3D hw->pcm_ops->glue(buffer_size_, TYPE)(hw); + if (hw->s->dev->TYPE->mixeng) { + size_t samples; + if (!hw->pcm_ops) { + /* + * We should only end up here when using wavcapture hmp comman= d (and + * not the wavcapture audio backend). + * It needs a lot of samples, otherwise you'll end up with "Co= uld + * not mix X bytes into a capture buffer" warnings and a garbl= ed + * capture. + */ + samples =3D 4096 * 4; + } else if (hw->pcm_ops->glue(buffer_size_, TYPE)) { + samples =3D hw->pcm_ops->glue(buffer_size_, TYPE)(hw); + } else { + samples =3D 1024; /* todo better default */ + } + + if (audio_bug(__func__, samples =3D=3D 0)) { + dolog("Attempted to allocate empty buffer\n"); + } + + HWBUF =3D g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * s= amples); + HWBUF->size =3D samples; } else { - samples =3D 1024; /* todo better default */ + HWBUF =3D NULL; } - if (audio_bug(__func__, samples =3D=3D 0)) { - dolog("Attempted to allocate empty buffer\n"); - } - - HWBUF =3D g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * sampl= es); - HWBUF->size =3D samples; } =20 static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw) @@ -116,6 +122,10 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) = (SW *sw) { int samples; =20 + if (!sw->s->dev->TYPE->mixeng) { + return 0; + } + samples =3D ((int64_t) sw->HWBUF->size << 32) / sw->ratio; =20 sw->buf =3D audio_calloc(__func__, samples, sizeof(struct st_sample)); diff --git a/audio/audio.c b/audio/audio.c index 6bbbcd3e03..db42d89dc3 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -839,32 +839,46 @@ static void audio_timer (void *opaque) */ size_t AUD_write(SWVoiceOut *sw, void *buf, size_t size) { + HWVoiceOut *hw; + if (!sw) { /* XXX: Consider options */ return size; } + hw =3D sw->hw; =20 - if (!sw->hw->enabled) { + if (!hw->enabled) { dolog ("Writing to disabled voice %s\n", SW_NAME (sw)); return 0; } =20 - return audio_pcm_sw_write(sw, buf, size); + if (hw->s->dev->out->mixeng) { + return audio_pcm_sw_write(sw, buf, size); + } else { + return hw->pcm_ops->write(hw, buf, size); + } } =20 size_t AUD_read(SWVoiceIn *sw, void *buf, size_t size) { + HWVoiceIn *hw; + if (!sw) { /* XXX: Consider options */ return size; } + hw =3D sw->hw; =20 - if (!sw->hw->enabled) { + if (!hw->enabled) { dolog ("Reading from disabled voice %s\n", SW_NAME (sw)); return 0; } =20 - return audio_pcm_sw_read(sw, buf, size); + if (hw->s->dev->in->mixeng) { + return audio_pcm_sw_read(sw, buf, size); + } else { + return hw->pcm_ops->read(hw, buf, size); + } } =20 int AUD_get_buffer_size_out (SWVoiceOut *sw) @@ -1086,6 +1100,26 @@ static void audio_run_out (AudioState *s) HWVoiceOut *hw =3D NULL; SWVoiceOut *sw; =20 + if (!s->dev->out->mixeng) { + while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { + /* there is exactly 1 sw for each hw with no mixeng */ + sw =3D hw->sw_head.lh_first; + + if (hw->pending_disable) { + hw->enabled =3D 0; + hw->pending_disable =3D 0; + if (hw->pcm_ops->enable_out) { + hw->pcm_ops->enable_out(hw, false); + } + } + + if (sw->active) { + sw->callback.fn(sw->callback.opaque, INT_MAX); + } + } + return; + } + while ((hw =3D audio_pcm_hw_find_any_enabled_out(s, hw))) { size_t played, live, prev_rpos, free; int nb_live, cleanup_required; @@ -1223,6 +1257,17 @@ static void audio_run_in (AudioState *s) { HWVoiceIn *hw =3D NULL; =20 + if (!s->dev->in->mixeng) { + while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { + /* there is exactly 1 sw for each hw with no mixeng */ + SWVoiceIn *sw =3D hw->sw_head.lh_first; + if (sw->active) { + sw->callback.fn(sw->callback.opaque, INT_MAX); + } + } + return; + } + while ((hw =3D audio_pcm_hw_find_any_enabled_in(s, hw))) { SWVoiceIn *sw; size_t captured =3D 0, min; @@ -1738,6 +1783,11 @@ CaptureVoiceOut *AUD_add_capture( s =3D audio_init(NULL, NULL); } =20 + if (!s->dev->out->mixeng) { + dolog("Can't capture with mixeng disabled\n"); + goto err0; + } + if (audio_validate_settings (as)) { dolog ("Invalid settings were passed when trying to add capture\n"= ); audio_print_settings (as); @@ -1888,9 +1938,13 @@ static void audio_validate_per_direction_opts( *has_pdo =3D true; } =20 + if (!(*pdo)->has_mixeng) { + (*pdo)->has_mixeng =3D true; + (*pdo)->mixeng =3D true; + } if (!(*pdo)->has_fixed_settings) { (*pdo)->has_fixed_settings =3D true; - (*pdo)->fixed_settings =3D true; + (*pdo)->fixed_settings =3D (*pdo)->mixeng; } if (!(*pdo)->fixed_settings && ((*pdo)->has_frequency || (*pdo)->has_channels || (*pdo)->has_form= at)) { @@ -1898,6 +1952,10 @@ static void audio_validate_per_direction_opts( "You can't use frequency, channels or format with fixed= -settings=3Doff"); return; } + if (!(*pdo)->mixeng && (*pdo)->fixed_settings) { + error_setg(errp, "You can't use fixed-settings without mixeng"); + return; + } =20 if (!(*pdo)->has_frequency) { (*pdo)->has_frequency =3D true; @@ -1909,7 +1967,7 @@ static void audio_validate_per_direction_opts( } if (!(*pdo)->has_voices) { (*pdo)->has_voices =3D true; - (*pdo)->voices =3D 1; + (*pdo)->voices =3D (*pdo)->mixeng ? 1 : INT_MAX; } if (!(*pdo)->has_format) { (*pdo)->has_format =3D true; --=20 2.20.1