* [Qemu-devel] [PATCH] audio: fix audio timer rate conversion bug
@ 2019-04-01 18:59 Volker Rümelin
2019-04-01 23:25 ` Zoltán Kővágó
2019-04-02 5:37 ` Gerd Hoffmann
0 siblings, 2 replies; 3+ messages in thread
From: Volker Rümelin @ 2019-04-01 18:59 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
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 <vr_qemu@t-online.de>
---
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:
--
2.16.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] audio: fix audio timer rate conversion bug
2019-04-01 18:59 [Qemu-devel] [PATCH] audio: fix audio timer rate conversion bug Volker Rümelin
@ 2019-04-01 23:25 ` Zoltán Kővágó
2019-04-02 5:37 ` Gerd Hoffmann
1 sibling, 0 replies; 3+ messages in thread
From: Zoltán Kővágó @ 2019-04-01 23:25 UTC (permalink / raw)
To: qemu-devel
On 2019-04-01 20:59, Volker Rümelin wrote:
> 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.
Good catch! The legacy config used Hz, frames, bytes, milliseconds and
microseconds quite randomly to define lengths, this one slipped through
my unification attempts.
>
> This fixes commit 71830221fb23388b32e6516c2fb7a698453a6c5a
> -audiodev command line option basic implementation.
>
> Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Reviewed-by: Zoltán Kővágó <DirtY.iCE.hu@gmail.com>
> ---
> 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;
> + }
I'd use SCALE_US instead of 1000 here. If you have
NANOSECONDS_PER_SECOND / SCALE_US / e->dev->timer_period, it's
immediately obvious that if you multiply it with SCALE_US, you get back
the old value of s->period_ticks above.
>
> switch (e->dev->driver) {
> case AUDIODEV_DRIVER_ALSA:
>
Regards,
Zoltan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] audio: fix audio timer rate conversion bug
2019-04-01 18:59 [Qemu-devel] [PATCH] audio: fix audio timer rate conversion bug Volker Rümelin
2019-04-01 23:25 ` Zoltán Kővágó
@ 2019-04-02 5:37 ` Gerd Hoffmann
1 sibling, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2019-04-02 5:37 UTC (permalink / raw)
To: Volker Rümelin; +Cc: qemu-devel
On Mon, Apr 01, 2019 at 08:59:20PM +0200, Volker Rümelin wrote:
> 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.
Patch queued.
> This fixes commit 71830221fb23388b32e6516c2fb7a698453a6c5a
> -audiodev command line option basic implementation.
This can be written as "Fixes: <short hash> <subject>" line,
so tools can pick this up automatically (Hint for the next time,
I've updated the commit message, no need to resend).
thanks,
Gerd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-02 5:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-01 18:59 [Qemu-devel] [PATCH] audio: fix audio timer rate conversion bug Volker Rümelin
2019-04-01 23:25 ` Zoltán Kővágó
2019-04-02 5:37 ` Gerd Hoffmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.