* problem with scheduling alsa events
@ 2008-11-25 15:09 nescivi
0 siblings, 0 replies; only message in thread
From: nescivi @ 2008-11-25 15:09 UTC (permalink / raw)
To: alsa-devel
Hiho,
In the Midi output code of this opensource project I am working on, there is a
problem with the timing when alsa events are scheduled in the future.
The events take much longer to arrive (sometimes almost minutes later!).
Below is the code snippet.
Can anyone see what is wrong in here?
Let me know if you need more code...
This is with libasound2 1.0.16-2 (Debian unstable).
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);
}
// late is the latency value in seconds in floats
if (late > 0.f) {
// old time calculation:
// time.tv_sec = (unsigned)(late * 1.0e-6f);
// time.tv_nsec = (unsigned)(late * 1.0e3f);
// new time calculation. The old one was not correct
time.tv_sec = (unsigned)(late); // seconds
time.tv_nsec = (unsigned)(late * 1.0e9f) % 1000000000; //
nanoseconds
// should these be (long) instead???
} else {
time.tv_sec = time.tv_nsec = 0;
}
post("MIDI (ALSA): sending event, time %i, %i, late %f\n",
time.tv_sec,
time.tv_nsec, late);
snd_seq_ev_schedule_real(evt, mQueue, 1, &time);
snd_seq_event_output_direct(mHandle, evt);
return errNone;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-11-25 15:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-25 15:09 problem with scheduling alsa events nescivi
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.