From patchwork Mon Apr 1 18:59:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 10880509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C19E1708 for ; Mon, 1 Apr 2019 19:00:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A48828553 for ; Mon, 1 Apr 2019 19:00:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68533285BD; Mon, 1 Apr 2019 19:00:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A4EE628553 for ; Mon, 1 Apr 2019 19:00:07 +0000 (UTC) Received: from localhost ([127.0.0.1]:59046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hB2A9-0008CI-Vl for patchwork-qemu-devel@patchwork.kernel.org; Mon, 01 Apr 2019 15:00:06 -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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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ümelin Reviewed-by: Zoltán Kővágó --- 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 <= 0) { s->period_ticks = 1; } else { - s->period_ticks = NANOSECONDS_PER_SECOND / dev->timer_period; + s->period_ticks = dev->timer_period * SCALE_US; } e = 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 *drvname) handle_per_direction(audio_get_pdo_in(e->dev), "QEMU_AUDIO_ADC_"); handle_per_direction(audio_get_pdo_out(e->dev), "QEMU_AUDIO_DAC_"); + /* 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 = NANOSECONDS_PER_SECOND / 1000 / + e->dev->timer_period; + } switch (e->dev->driver) { case AUDIODEV_DRIVER_ALSA: