From nobody Fri Nov 7 04:15:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.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 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545600722846693.8415968777739; Sun, 23 Dec 2018 13:32:02 -0800 (PST) Received: from localhost ([127.0.0.1]:60034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbBLn-0005rO-FT for importer@patchew.org; Sun, 23 Dec 2018 16:31:55 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbAkH-0008O3-Dx for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:53:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbAkG-0003df-27 for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:53:09 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:45127) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gbAkF-0003WH-OC for qemu-devel@nongnu.org; Sun, 23 Dec 2018 15:53:07 -0500 Received: by mail-wr1-x441.google.com with SMTP id t6so10091170wrr.12 for ; Sun, 23 Dec 2018 12:53:06 -0800 (PST) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-24a3-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:24a3::5]) by smtp.gmail.com with ESMTPSA id g198sm25456920wmd.23.2018.12.23.12.53.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Dec 2018 12:53:04 -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=sHasOL13Sm4lJqugf3XEUgVeA6clMRH1eNhcHgdVAJw=; b=pWHJZatrWpkqjkvdsrDDYEW8oYKm25EwxCbDuvDs0Jc61h0rSwBcbcYVnDQIMdQoml uYCCj6fv7GWGfac3nkB0/U/8fw4wMSvyaxkv1zSup/IphBwFqHhyjrcADmnA+/mKR2ST oBlS4vn4KkB/lsQ59jSQOT4rRXEhDh/7GrkTQyLXW/oVjE/IDrULMq0eW19fs0zm6wd3 4L/FiKHq3iBLG6YBpdSnFm7Hhz48P0NvpJ69e2TaWYreHcWI+DJqZz7dGAFsky6603Uo Opf/HqsiQnD1vlNN24UwnaRxxiLuSIyvzuGplnHT2lpMkY6tvxc6qMHHm2eRpO31BFbZ pBhA== 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=sHasOL13Sm4lJqugf3XEUgVeA6clMRH1eNhcHgdVAJw=; b=OAgq4CcPhqYvoe8JK/2GP/yrY0F8mc8lsTCJ6EijvnlppX6CyYYBhvExJUuNznrmOl DWE0inFrnm4ttvXHzOWnUcGWnNlGrI0HX15zpA88BaQqeXwEM5gk61YyCzF5ewlZGFh0 vYAGx/oGuXDlDA65MSuxLrZTiJ05BNE61CoEYzn71pnfIfrukRcYsqg60PmXl0JA1Yv2 SjgXEvKEfeiHiaUsEE9j/c9J8aeafkF1hugqGQxaFV59nZhx5a07J5HNWC5LMwhH3L68 CLsgdNGsQPxJA7yQy5N1TdSKKoj3ArqYRJRtxQSo59mlrV6gMJ34YLYJhvFxhX9IciRA fVLg== X-Gm-Message-State: AJcUukcfgIeBE53fSLXQz0J7XAYzYfWJmvecwjfxagfcWsVWWDJMRX32 Y649yF/Aqz9CWZgelv/1t66w3zy7VBU= X-Google-Smtp-Source: ALg8bN7R+zlBOiKtf4GhRCImIWqcr7PtNjhDTHPhvmC0m6ifYDIAEGzKAXUxbkac+mA8ER/typV3Pw== X-Received: by 2002:adf:ae41:: with SMTP id u1mr9136811wrd.20.1545598385358; Sun, 23 Dec 2018 12:53:05 -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: Sun, 23 Dec 2018 21:52:20 +0100 Message-Id: <03189c11f5216339f472d06925582a8e20e7b21b.1545598229.git.DirtY.iCE.hu@gmail.com> 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::441 Subject: [Qemu-devel] [PATCH v2 44/52] 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.c | 70 ++++++++++++++++++++++++++++++++++++++---- audio/audio_template.h | 46 ++++++++++++++++----------- 2 files changed, 92 insertions(+), 24 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 7ba939560a..26ce25989f 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -840,32 +840,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) @@ -1087,6 +1101,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; @@ -1224,6 +1258,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; @@ -1717,6 +1762,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); @@ -1875,9 +1925,13 @@ QemuOptsList qemu_audiodev_opts =3D { static void validate_per_direction_opts(AudiodevPerDirectionOptions *pdo, Error **errp) { + 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_format)) { @@ -1885,6 +1939,10 @@ static void validate_per_direction_opts(AudiodevPerD= irectionOptions *pdo, "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; @@ -1896,7 +1954,7 @@ static void validate_per_direction_opts(AudiodevPerDi= rectionOptions *pdo, } 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; 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)); --=20 2.20.1