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 ?
no, it happens even if I set late to 0.1.
It is really strange. Sometimes it just works for a while, and then it just
takes minutes before any event comes out.
The values print out fine, just something weird seems to be happening in the
actual scheduling.
Alternative:
time.tv_sec = (long)(floorf (late));
time.tv_nsec = (long)((late - time.tv_sec) * 1e9f);