#include "jack_rack.h"
+extern pthread_mutex_t g_activate_mutex;
+
#define BUFFER_LEN 204800 * 6
static void jack_started_transmitter( mlt_listener listener, mlt_properties owner, mlt_service service, void **args )
mlt_position position = mlt_profile_fps( profile ) * jack_pos->frame / jack_pos->frame_rate + 0.5;
int result = 1;
- mlt_log_verbose( MLT_FILTER_SERVICE(filter), "%s frame %u rate %u pos %d last_pos %d\n",
+ mlt_log_debug( MLT_FILTER_SERVICE(filter), "%s frame %u rate %u pos %d last_pos %d\n",
JACKSTATE(state), jack_pos->frame, jack_pos->frame_rate, position,
mlt_properties_get_position( properties, "_last_pos" ) );
if ( state == JackTransportStopped )
sizeof( float *) * channels, mlt_pool_release, NULL );
// Start Jack processing - required before registering ports
+ pthread_mutex_lock( &g_activate_mutex );
jack_activate( jack_client );
+ pthread_mutex_unlock( &g_activate_mutex );
// Register Jack ports
for ( i = 0; i < channels; i++ )
}
}
+ // Often jackd does not send the stopped event through the JackSyncCallback
+ jack_client_t *jack_client = mlt_properties_get_data( properties, "jack_client", NULL );
+ jack_position_t jack_pos;
+ jack_transport_state_t state = jack_transport_query( jack_client, &jack_pos );
+ int transport_state = mlt_properties_get_int( properties, "_transport_state" );
+ if ( state != transport_state )
+ {
+ mlt_properties_set_int( properties, "_transport_state", state );
+ if ( state == JackTransportStopped )
+ jack_sync( state, &jack_pos, filter );
+ }
+
return err;
}
mlt_filter this = mlt_filter_new( );
if ( this != NULL )
{
- char name[14];
-
+ char name[16];
+ char *jack_client_name;
+ jack_status_t status = 0;
+
snprintf( name, sizeof( name ), "mlt%d", getpid() );
- jack_client_t *jack_client = jack_client_open( name, JackNullOption, NULL );
+ jack_client_t *jack_client = jack_client_open( name, JackNullOption, &status, NULL );
if ( jack_client )
{
+ if ( status & JackNameNotUnique )
+ {
+ jack_client_name = jack_get_client_name ( jack_client );
+ strcpy( name, jack_client_name );
+ }
+
mlt_properties properties = MLT_FILTER_PROPERTIES( this );
pthread_mutex_t *output_lock = mlt_pool_alloc( sizeof( pthread_mutex_t ) );
pthread_cond_t *output_ready = mlt_pool_alloc( sizeof( pthread_cond_t ) );
mlt_events_listen( properties, this, "jack-seek", (mlt_listener) on_jack_seek );
mlt_properties_set_position( properties, "_jack_seek", -1 );
}
+ else
+ {
+ mlt_log_error( NULL, "Failed to connect to JACK server\n" );
+ mlt_filter_close( this );
+ this = NULL;
+ }
}
return this;
}