diff --git a/jack.C b/jack.C index 042b623..354df17 100644 --- a/jack.C +++ b/jack.C @@ -368,7 +368,10 @@ midi_init ( void ) { MESSAGE( "Initializing Jack MIDI" ); - if (( client = jack_client_new ( APP_NAME )) == 0 ) +/* if (( client = jack_client_new ( APP_NAME )) == 0 ) */ +/* return 0; */ + + if (( client = jack_client_open ( APP_NAME, (jack_options_t)0, NULL )) == 0 ) return 0; /* create output ports */ @@ -406,9 +409,6 @@ midi_init ( void ) //1 jack_set_buffer_size_callback( client, bufsize, 0 ); jack_set_process_callback( client, process, 0 ); - jack_activate( client ); - - sample_rate = jack_get_sample_rate( client ); /* /\* initialize buffer size *\/ */ /* transport_poll(); */ @@ -422,6 +422,16 @@ midi_init ( void ) else WARNING( "could not take over as timebase master" ); + jack_activate( client ); + + sample_rate = jack_get_sample_rate( client ); + + /* FIXME: hack! we need to wait until jack finally calls our + * timebase and process callbacks in order to be able to test for + * valid transport info. */ + MESSAGE( "Waiting for JACK..." ); + usleep( 500000 ); + return 1; } diff --git a/main.C b/main.C index 2e194ed..b8cfa6b 100644 --- a/main.C +++ b/main.C @@ -164,6 +164,9 @@ main ( int argc, char **argv ) if ( ! midi_init() ) ASSERTION( "Could not initialize MIDI system! (is Jack running and with MIDI ports enabled?)" ); + if ( ! transport.valid ) + ASSERTION( "The version of JACK you are using does not appear to be capable of passing BBT positional information." ); + MESSAGE( "Initializing GUI" ); init_colors(); diff --git a/transport.C b/transport.C index 9c98d3d..adad049 100644 --- a/transport.C +++ b/transport.C @@ -33,7 +33,7 @@ extern jack_client_t *client; Transport transport; -static bool _done; +static volatile bool _done; /** callback for when we're Timebase Master, mostly taken from * transport.c in Jack's example clients. */ @@ -100,7 +100,9 @@ Transport::poll ( void ) ts = jack_transport_query( client, &pos ); rolling = ts == JackTransportRolling; - valid = pos.valid == JackPositionBBT; + + valid = pos.valid & JackPositionBBT; + bar = pos.bar; beat = pos.beat; tick = pos.tick;