+static void on_jack_started( mlt_properties owner, mlt_consumer consumer, mlt_position *position )
+{
+ mlt_producer producer = mlt_properties_get_data( MLT_CONSUMER_PROPERTIES(consumer), "transport_producer", NULL );
+ if ( producer )
+ {
+ if ( mlt_producer_get_speed( producer ) != 0 )
+ {
+ mlt_properties jack = mlt_properties_get_data( MLT_CONSUMER_PROPERTIES( consumer ), "jack_filter", NULL );
+ mlt_events_fire( jack, "jack-stop", NULL );
+ }
+ else
+ {
+ mlt_producer_set_speed( producer, 1 );
+ mlt_consumer_purge( consumer );
+ mlt_producer_seek( producer, *position );
+ mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "refresh", 1 );
+ }
+ }
+}
+
+static void on_jack_stopped( mlt_properties owner, mlt_consumer consumer, mlt_position *position )
+{
+ mlt_producer producer = mlt_properties_get_data( MLT_CONSUMER_PROPERTIES(consumer), "transport_producer", NULL );
+ if ( producer )
+ {
+ mlt_producer_set_speed( producer, 0 );
+ mlt_consumer_purge( consumer );
+ mlt_producer_seek( producer, *position );
+ mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( consumer ), "refresh", 1 );
+ }
+}
+
+static void setup_jack_transport( mlt_consumer consumer, mlt_profile profile )
+{
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
+ mlt_filter jack = mlt_factory_filter( profile, "jackrack", NULL );
+ mlt_properties jack_properties = MLT_FILTER_PROPERTIES(jack);
+
+ mlt_service_attach( MLT_CONSUMER_SERVICE(consumer), jack );
+ mlt_properties_set_int( properties, "audio_off", 1 );
+ mlt_properties_set_data( properties, "jack_filter", jack, 0, (mlt_destructor) mlt_filter_close, NULL );
+// mlt_properties_set( jack_properties, "out_1", "system:playback_1" );
+// mlt_properties_set( jack_properties, "out_2", "system:playback_2" );
+ mlt_events_listen( jack_properties, consumer, "jack-started", (mlt_listener) on_jack_started );
+ mlt_events_listen( jack_properties, consumer, "jack-stopped", (mlt_listener) on_jack_stopped );
+}
+