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

From: Fons Adriaensen <fons@email-addr-hidden>
Date: Sat Jan 10 2009 - 23:13:44 EET

On Sat, Jan 10, 2009 at 03:59:06PM -0500, nescivi wrote:

> since I get no response here...
> which list you recommend I post this question to?
> I also got no reaction on the alsa-dev list... alsa-user then?

> > 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;
> > }

If 'late' > 2.147 then 'latelong' will go negative.
Could this happen when you schedule an event more than
2 seconds ahead of due time ?

Alternative:

time.tv_sec = (long)(floorf (late));
time.tv_nsec = (long)((late - time.tv_sec) * 1e9f);

Ciao,

-- 
FA
Laboratorio di Acustica ed Elettroacustica
Parma, Italia
O tu, che porte, correndo si ?
E guerra e morte !
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Sun Jan 11 00:15:01 2009

This archive was generated by hypermail 2.1.8 : Sun Jan 11 2009 - 00:15:02 EET