From nobody Tue Feb 10 01:35:36 2026 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; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1554188796360991.0363095510743; Tue, 2 Apr 2019 00:06:36 -0700 (PDT) Received: from localhost ([127.0.0.1]:40408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBDVB-0003w7-Bw for importer@patchew.org; Tue, 02 Apr 2019 03:06:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBDT3-0002bL-Um for qemu-devel@nongnu.org; Tue, 02 Apr 2019 03:04:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBDT1-0001Md-6w for qemu-devel@nongnu.org; Tue, 02 Apr 2019 03:04:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53646) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hBDC2-0005Su-5r for qemu-devel@nongnu.org; Tue, 02 Apr 2019 02:46:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7076B307D976; Tue, 2 Apr 2019 06:46:45 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A18260BEC; Tue, 2 Apr 2019 06:46:44 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2354AA1E9; Tue, 2 Apr 2019 08:46:40 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 2 Apr 2019 08:46:39 +0200 Message-Id: <20190402064639.27108-6-kraxel@redhat.com> In-Reply-To: <20190402064639.27108-1-kraxel@redhat.com> References: <20190402064639.27108-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 02 Apr 2019 06:46:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/5] audio: fix audio timer rate conversion bug 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: =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Volker R=C3=BCmelin Currently the default audio timer frequency is 10000Hz instead of a period of 10000us. Also the audiodev timer-period property gets converted like a frequency. Only handling of the legacy QEMU_AUDIO_TIMER_PERIOD environment variable is correct because it's actually a frequency. With this patch the property timer-period is really a timer period and QEMU_AUDIO_TIMER_PERIOD remains a frequency. Fixes: 71830221fb "-audiodev command line option basic implementation." Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Zolt=C3=A1n K=C5=91v=C3=A1g=C3=B3 Message-id: 90b95e4f-39ef-2b01-da6a-857ebaee1ec5@t-online.de Signed-off-by: Gerd Hoffmann --- audio/audio.c | 2 +- audio/audio_legacy.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/audio/audio.c b/audio/audio.c index 5fd9a58a808f..2040762feff1 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1471,7 +1471,7 @@ static int audio_init(Audiodev *dev) if (dev->timer_period <=3D 0) { s->period_ticks =3D 1; } else { - s->period_ticks =3D NANOSECONDS_PER_SECOND / dev->timer_period; + s->period_ticks =3D dev->timer_period * SCALE_US; } =20 e =3D qemu_add_vm_change_state_handler (audio_vm_change_state_handler,= s); diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c index 6d140119d98a..2fd58cb8ef25 100644 --- a/audio/audio_legacy.c +++ b/audio/audio_legacy.c @@ -26,6 +26,7 @@ #include "audio_int.h" #include "qemu-common.h" #include "qemu/cutils.h" +#include "qemu/timer.h" #include "qapi/error.h" #include "qapi/qapi-visit-audio.h" #include "qapi/visitor-impl.h" @@ -338,8 +339,13 @@ static AudiodevListEntry *legacy_opt(const char *drvna= me) handle_per_direction(audio_get_pdo_in(e->dev), "QEMU_AUDIO_ADC_"); handle_per_direction(audio_get_pdo_out(e->dev), "QEMU_AUDIO_DAC_"); =20 + /* Original description: Timer period in HZ (0 - use lowest possible) = */ get_int("QEMU_AUDIO_TIMER_PERIOD", &e->dev->timer_period, &e->dev->has_timer_period); + if (e->dev->has_timer_period && e->dev->timer_period) { + e->dev->timer_period =3D NANOSECONDS_PER_SECOND / 1000 / + e->dev->timer_period; + } =20 switch (e->dev->driver) { case AUDIODEV_DRIVER_ALSA: --=20 2.18.1