Jack time - assertion failure in alsa_seqmidi.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Jack time - assertion failure in alsa_seqmidi.c

KenEllinwood
Hi,

I'm trying out the jack midi APIs, and I ran into a problem in which jackd dies on an assertion failure in alsa_seqmidi.c, do_jack_output(), at line 852 in the latest code from SVN (revision 1050).  It appears that the code on line 847, which calculates the value of frame_offset, is among other things attempting to subtract the amount of time that has passed between the start of the process cycle and now (+info->period_start - info->cur_frames).   The period_start value comes from jack_last_frame_time() and the cur_frames value comes from jack_frame_time().   The frame_offset calculation logic does not appear incorrect, instead the assertion failure stems from the fact that jack_frame_time() is returning a smaller value than jack_last_frame_time().  See below, I've included the output of some printf()s added just before the assert() statement.   Due to the smaller value of cur_frames, time is being added to frame_offset, not subtracted.  Coupled with an event time that
 approaches the value of nframes, the assertion fails.


jack_event->time = 960
info->dir = 1
info->nframes = 1024
info->period_start = 945152 (jack_last_frame_time())
info->sample_rate = 44100
info->cur_frames = 945063 (jack_frame_time())

As a workaround, I modified the code to limit the time offset to 0 in case it is a negative value (see below for the patch).  I'm really not sure if this is the best way to fix the problem -- the best case solution would be to get a period start value that is less than the current time, but I'm not sure how to do that.




Index: drivers/alsa-midi/alsa_seqmidi.c
===================================================================
--- drivers/alsa-midi/alsa_seqmidi.c    (revision 1050)
+++ drivers/alsa-midi/alsa_seqmidi.c    (working copy)
@@ -844,7 +844,9 @@
                snd_seq_ev_set_dest(&alsa_event, port->remote.client, port->remote.port);
 
                /* NOTE: in case of xrun it could become negative, so it is essential to use signed type! */
-               frame_offset = (int64_t)jack_event.time + info->period_start + info->nframes - info->cur_frames;
+               int64_t period_offset = (int64_t)info->cur_frames - info->period_start;
+               if (period_offset < 0) period_offset = 0;
+               frame_offset = (int64_t)jack_event.time + info->nframes - period_offset;
                if (frame_offset < 0) {
                        frame_offset = info->nframes + jack_event.time;
                        error_log("internal xrun detected: frame_offset = %lld\n", frame_offset);


Ken






      ____________________________________________________________________________________
Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/ 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel