[LAD] alsa sequencer latency ( snd_seq_ev_schedule_real ) - need help!

From: nescivi <nescivi@email-addr-hidden>
Date: Mon Jan 05 2009 - 04:51:21 EET

Hiho,

I am experiencing strange things with some code that uses the ALSA sequencer,
with the function
         snd_seq_ev_schedule_real(evt, mQueue, 1, &time);

The timing of this is unreliable.

At times it goes as expected for a while, but then after some time large
delays (minutes, instead of the expected latency of 0.1 second) are
introduced.

Does anyone have any idea what the problem could be?

I have a code snippet below. In case anyone wants to try (the app is
SuperCollider, you need the latest svn).

I'm on a Debian kernel (2.6.24-1-amd64 #1 SMP Thu Mar 27 16:52:38 UTC 2008
x86_64 GNU/Linux), in case that is relevant.

sincerely,
Marije

int SC_AlsaMidiClient::sendEvent(int outputIndex, int uid, snd_seq_event_t*
evt, float late)
{
        snd_seq_real_time time;
        
        if ((outputIndex < 0) || (outputIndex >= mNumOutPorts)) return
errIndexOutOfRange;

        snd_seq_ev_set_source(evt, mOutPorts[outputIndex]);
        if (uid == 0) {
                // send to all subscribed ports
                snd_seq_ev_set_subs(evt);
        } else {
                // send to specific port
                int cid, pid;
                SC_AlsaParseUID(uid, cid, pid);
                snd_seq_ev_set_dest(evt, cid, pid);
        }

        long latelong;
        if (late > 0.f) {
                latelong = (long) (late * 1000000000);
// new time calculation. The old one was not correct
                time.tv_sec = (long)(latelong / 1000000000); // seconds
                time.tv_nsec = (long)(latelong % 1000000000); // nanoseconds
        } else {
                time.tv_sec = time.tv_nsec = 0;
        }

// evt->flags = evt->flags | SND_SEQ_TIME_STAMP_REAL;

         post("MIDI (ALSA): sending event, time %i, %i, late %f, latelong %i\n",
time.tv_sec, time.tv_nsec, late, latelong);

        snd_seq_ev_schedule_real(evt, mQueue, 1, &time);
        snd_seq_event_output_direct(mHandle, evt);
// snd_seq_event_output(mHandle, evt);

        return errNone;
}
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Mon Jan 5 08:15:01 2009

This archive was generated by hypermail 2.1.8 : Mon Jan 05 2009 - 08:15:01 EET