alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Arthur Marsh <arthur.marsh@internode.on.net>
Cc: alsa-devel@alsa-project.org
Subject: Re: MIDI playback not keeping steady time with recent kernels
Date: Tue, 08 Feb 2011 12:53:13 +0100	[thread overview]
Message-ID: <4D512EA9.2020909@ladisch.de> (raw)
In-Reply-To: <11c228-725.ln1@ppp121-45-136-118.lns11.adl6.internode.on.net>

Arthur Marsh wrote:
>>> Arthur Marsh wrote, on 05/02/11 17:30:
>>>> MIDI playback either through xmms or aplaymidi won't keep regular time,
>>>> sounding weird going faster and slower under any kind of system load
>>>> except when nothing else is running.
> 
> I've tried setting "options snd-timer timer_limit=x" where x is anywhere 
> from 5 down to 0, and seeing either:
> 
> $ cat /proc/asound/seq/timer
> Timer for queue 0 : HR timer
>    Period time : 0.004000250
>    Skew : 65536 / 65536
> 
> or "system timer" in place of "HR timer".
> 
> In all cases, under sufficient load (which might be just running 
> aptitude -u), the tempo of the MIDI file play-back slows right down.

The ALSA interfaces of both the system timer and the HR timer do not
handle delayed interrupts correctly.  Please try the patch below, and if
it fixes the HR timer, tell me if you're OK with the published tag
Reported-and-tested-by: Arthur Marsh <arthur.marsh@internode.on.net>.


Regards,
Clemens

--- a/sound/core/hrtimer.c
+++ b/sound/core/hrtimer.c
@@ -45,12 +45,13 @@ static enum hrtimer_restart snd_hrtimer_
 {
 	struct snd_hrtimer *stime = container_of(hrt, struct snd_hrtimer, hrt);
 	struct snd_timer *t = stime->timer;
+	unsigned long oruns;
 
 	if (!atomic_read(&stime->running))
 		return HRTIMER_NORESTART;
 
-	hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution));
-	snd_timer_interrupt(stime->timer, t->sticks);
+	oruns = hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution));
+	snd_timer_interrupt(stime->timer, t->sticks * oruns);
 
 	if (!atomic_read(&stime->running))
 		return HRTIMER_NORESTART;

       reply	other threads:[~2011-02-08 11:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <559v18-575.ln1@ppp121-45-136-118.lns11.adl6.internode.on.net>
     [not found] ` <bma128-mok.ln1@ppp121-45-136-118.lns11.adl6.internode.on.net>
     [not found]   ` <elo128-8u4.ln1@ppp121-45-136-118.lns11.adl6.internode.on.net>
     [not found]     ` <11c228-725.ln1@ppp121-45-136-118.lns11.adl6.internode.on.net>
2011-02-08 11:53       ` Clemens Ladisch [this message]
2011-02-08 15:19         ` MIDI playback not keeping steady time with recent kernels Arthur Marsh
2011-02-08 15:40           ` Clemens Ladisch
2011-02-09  0:51             ` Arthur Marsh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D512EA9.2020909@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=arthur.marsh@internode.on.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).