From nobody Sat May 4 04:17:03 2024 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 Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1554145231220573.8612416820151; Mon, 1 Apr 2019 12:00:31 -0700 (PDT) Received: from localhost ([127.0.0.1]:59046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hB2AP-0008CI-Er for importer@patchew.org; Mon, 01 Apr 2019 15:00:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hB29W-0007sj-C1 for qemu-devel@nongnu.org; Mon, 01 Apr 2019 14:59:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hB29V-0004ap-6a for qemu-devel@nongnu.org; Mon, 01 Apr 2019 14:59:26 -0400 Received: from mailout10.t-online.de ([194.25.134.21]:58026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hB29U-0004ZG-OF for qemu-devel@nongnu.org; Mon, 01 Apr 2019 14:59:25 -0400 Received: from fwd29.aul.t-online.de (fwd29.aul.t-online.de [172.20.26.134]) by mailout10.t-online.de (Postfix) with SMTP id 5852E41AD916; Mon, 1 Apr 2019 20:59:21 +0200 (CEST) Received: from [192.168.211.101] (GQe1d8ZYohKGoYpYftTLH7lMYkvEaxmPdIbVC+jt+3U3HyvSGUuUckx-ObIkA7IZ8h@[46.86.57.91]) by fwd29.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1hB29R-3tqVs00; Mon, 1 Apr 2019 20:59:21 +0200 To: Gerd Hoffmann From: =?UTF-8?Q?Volker_R=c3=bcmelin?= Message-ID: <90b95e4f-39ef-2b01-da6a-857ebaee1ec5@t-online.de> Date: Mon, 1 Apr 2019 20:59:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Content-Language: en-GB X-ID: GQe1d8ZYohKGoYpYftTLH7lMYkvEaxmPdIbVC+jt+3U3HyvSGUuUckx-ObIkA7IZ8h X-TOI-MSGID: baf1e5d2-137d-4767-a512-7868260e73e9 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 194.25.134.21 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] [PATCH] 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: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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. This fixes commit 71830221fb23388b32e6516c2fb7a698453a6c5a -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 --- 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 5fd9a58a80..2040762fef 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 6d140119d9..2fd58cb8ef 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.16.4