From nobody Wed Nov 12 10:12:50 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=pass; 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=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1569877019; cv=none; d=zoho.com; s=zohoarc; b=HZ0FOl+jWmx/sjB8SlrQ1y6dy8sTcPQdLJ5Ve8tKlRvSel3hOk91ofTLUrRo5da4RtC0ygOJO9kLi3ps64PjwRO4eKF6abVBvmPBlQJPTRWZwaDSyDHt2qQCIcU+G9uHw0dz+5boevXvgRBwoWiTXDTlWWVxMzXs0h73mFaor0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569877019; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Pbln1L0UWMrKENno8JQoLEo0GwL8LqG6fEqEAAIjnjc=; b=RjYlGsD3m1QZNDsP/fN8/TT+qxvMA5KUH621fHG1B/qF/htQllVJYncFWMuNakNUwNz8L18xorT4ErpzmVKyUWwl3DszW2vAlxDkcXhme7MchH+eMRHJlyM2vGQBE1mELcAcKI/5Uc19gwTCk1XM2bJRLUHPgDFGrK5xsyDsSS0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; 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=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1569877019829698.2316263031931; Mon, 30 Sep 2019 13:56:59 -0700 (PDT) Received: from localhost ([::1]:57232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iF2j4-0002tD-Ha for importer@patchew.org; Mon, 30 Sep 2019 16:56:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45736) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iF2Ha-0003w2-T3 for qemu-devel@nongnu.org; Mon, 30 Sep 2019 16:28:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iF2HZ-0002Rm-4n for qemu-devel@nongnu.org; Mon, 30 Sep 2019 16:28:34 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:38590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iF2HY-0002QW-Rj for qemu-devel@nongnu.org; Mon, 30 Sep 2019 16:28:33 -0400 Received: by mail-wm1-x343.google.com with SMTP id 3so833395wmi.3 for ; Mon, 30 Sep 2019 13:28:32 -0700 (PDT) Received: from nullptr.home.dirty-ice.org (2a01-036c-0113-e8f4-0000-0000-0000-0005.pool6.digikabel.hu. [2a01:36c:113:e8f4::5]) by smtp.gmail.com with ESMTPSA id o9sm34402911wrh.46.2019.09.30.13.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 13:28:31 -0700 (PDT) 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=Pbln1L0UWMrKENno8JQoLEo0GwL8LqG6fEqEAAIjnjc=; b=CBvlbTH0xVU5+l/kL9BYNiQiImTMYQJDeWGnohsEnkopLIMk3jlT5Cg82ddJy9g1p3 bvzWbjqkmnC41MOzvU1rvZ0/UEu3FXs1J0i5PkBSwcj5J/Ye9r5HqPY79z8Eh1KUDxR/ Xy5Py/vHS7tvtRhis7wets/FI+j2ZL8IkmF/PoGpV42q/AXTVUZ0sN/w7L1VoRtZN3aY vHLKj3Lis5FcRKt2dMgnKqg7/scaVG8T5KL+Z5FhtxaEdvU+6FrblbapvA3Dy6cpQw1+ ZwD3EulfYP2I2JuCgcbnpO0SMLiusiWMcBb+fzlJOEzL9pzPifW69V4aTwPHOTzuxU27 SKUQ== 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=Pbln1L0UWMrKENno8JQoLEo0GwL8LqG6fEqEAAIjnjc=; b=AtxhEgg/C7+u7LxHqlqQPF/Cf72D+db7SdmMokbwnuKgMLKSnackrj6FRdToTnOWFR pxG6yk8W4lt78LIH6EW/JjZ53ljoEqSxkgZb4/GCvenIW0QaL9wVduiolEAmNj352AZY SzgyD1E4LzOEt/cx9WyJg21ZaIM/gleUuGxctWd4k1r8VVFkQYe9/6jGm3cNue8/OQ0t KXS+COAusoHVRq66EKIdwIH14XqElvxXLa7/L/yNx3kG0ajKbSu+I+ygfgqM4AKmNlZB ridLtAZ2MYarWiGcpYFfBQSLjni7fdP7x+BFUQx3MiRg1afs4dGRR/SAeTzPrAlriudS dUkg== X-Gm-Message-State: APjAAAXoesstejnLZW8c/NZQJORC2R5/L1iucmPlyemNdwgLyd9PNt0I Nbu+D0qV27lbf0j6L9x/br387HYh X-Google-Smtp-Source: APXvYqxTe/6+1CcG5OCThnMCSbGjvNZ79yVpe1CPvm17ALNEpo7/pk/sZ4f7mpqOgdB+j7Y9jNMC0w== X-Received: by 2002:a1c:4c12:: with SMTP id z18mr707090wmf.45.1569875311576; Mon, 30 Sep 2019 13:28:31 -0700 (PDT) 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 Subject: [PATCH v5 02/10] audio: make mixeng optional Date: Mon, 30 Sep 2019 22:28:55 +0200 Message-Id: <2560ebbb34576c29c4b9deaf3a7444b6b9506428.1569874641.git.DirtY.iCE.hu@gmail.com> X-Mailer: git-send-email 2.23.0 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::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Implementation of the previously added mixing-engine option. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n --- Notes: Changes from v4: =20 * audio_pcm_hw_add_* always returns a new HW (or fails) when not using = mixeng audio/audio.c | 70 ++++++++++++++++++++++++++++++++++++++---- audio/audio_template.h | 24 ++++++++++----- 2 files changed, 80 insertions(+), 14 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 7128ee98dc..d616a4af98 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -838,32 +838,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 (audio_get_pdo_out(hw->s->dev)->mixing_engine) { + 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 (audio_get_pdo_in(hw->s->dev)->mixing_engine) { + 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) @@ -1090,6 +1104,26 @@ static void audio_run_out (AudioState *s) HWVoiceOut *hw =3D NULL; SWVoiceOut *sw; =20 + if (!audio_get_pdo_out(s->dev)->mixing_engine) { + 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; @@ -1227,6 +1261,17 @@ static void audio_run_in (AudioState *s) { HWVoiceIn *hw =3D NULL; =20 + if (!audio_get_pdo_in(s->dev)->mixing_engine) { + 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; @@ -1751,6 +1796,11 @@ CaptureVoiceOut *AUD_add_capture( s =3D audio_init(NULL, NULL); } =20 + if (!audio_get_pdo_out(s->dev)->mixing_engine) { + dolog("Can't capture with mixeng disabled\n"); + return NULL; + } + if (audio_validate_settings (as)) { dolog ("Invalid settings were passed when trying to add capture\n"= ); audio_print_settings (as); @@ -1905,9 +1955,13 @@ void audio_create_pdos(Audiodev *dev) static void audio_validate_per_direction_opts( AudiodevPerDirectionOptions *pdo, Error **errp) { + if (!pdo->has_mixing_engine) { + pdo->has_mixing_engine =3D true; + pdo->mixing_engine =3D true; + } if (!pdo->has_fixed_settings) { pdo->has_fixed_settings =3D true; - pdo->fixed_settings =3D true; + pdo->fixed_settings =3D pdo->mixing_engine; } if (!pdo->fixed_settings && (pdo->has_frequency || pdo->has_channels || pdo->has_format)) { @@ -1915,6 +1969,10 @@ static void audio_validate_per_direction_opts( "You can't use frequency, channels or format with fixed= -settings=3Doff"); return; } + if (!pdo->mixing_engine && 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; @@ -1926,7 +1984,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->mixing_engine ? 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 235d1acbbe..3709a4431c 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -78,13 +78,17 @@ 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 =3D hw->samples; - if (audio_bug(__func__, samples =3D=3D 0)) { - dolog("Attempted to allocate empty buffer\n"); - } + if (glue(audio_get_pdo_, TYPE)(hw->s->dev)->mixing_engine) { + size_t samples =3D hw->samples; + if (audio_bug(__func__, samples =3D=3D 0)) { + dolog("Attempted to allocate empty buffer\n"); + } =20 - HWBUF =3D g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * sampl= es); - HWBUF->size =3D samples; + HWBUF =3D g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * s= amples); + HWBUF->size =3D samples; + } else { + HWBUF =3D NULL; + } } =20 static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw) @@ -103,6 +107,10 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) = (SW *sw) { int samples; =20 + if (!glue(audio_get_pdo_, TYPE)(sw->s->dev)->mixing_engine) { + return 0; + } + samples =3D ((int64_t) sw->HWBUF->size << 32) / sw->ratio; =20 sw->buf =3D audio_calloc(__func__, samples, sizeof(struct st_sample)); @@ -328,9 +336,9 @@ static HW *glue(audio_pcm_hw_add_, TYPE)(AudioState *s,= struct audsettings *as) HW *hw; AudiodevPerDirectionOptions *pdo =3D glue(audio_get_pdo_, TYPE)(s->dev= ); =20 - if (pdo->fixed_settings) { + if (!pdo->mixing_engine || pdo->fixed_settings) { hw =3D glue(audio_pcm_hw_add_new_, TYPE)(s, as); - if (hw) { + if (!pdo->mixing_engine || hw) { return hw; } } --=20 2.23.0