On 13/02/2017 19:40, Yurii Zubrytskyi wrote: > Hi, > > It looks to me that this behavior can be achieved with > "timer_mod_anticipate()" function instead of a separate check.
True, but I think Pavel's version is more readable. Since the timer is set to a fixed value from QEMU_CLOCK_VIRTUAL, timer_mod_anticipate is never going to do anything if the timer is already set. Paolo > > diff --git a/audio/audio.c b/audio/audio.c > > index c845a44..1ee95a5 100644 > > --- a/audio/audio.c > > +++ b/audio/audio.c > > @@ -1112,8 +1112,10 @@ static int audio_is_timer_needed (void) > > static void audio_reset_timer (AudioState *s) > > { > > if (audio_is_timer_needed ()) { > > - timer_mod (s->ts, > > - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + > conf.period.ticks); > > + if (!timer_pending(s->ts)) { > > + timer_mod (s->ts, > > + qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + > conf.period.ticks); > > + } > > } > > else { > > timer_del (s->ts); > > > > > > > -- > Thanks, Yurii