From: ddennedy Date: Mon, 27 Dec 2004 22:01:49 +0000 (+0000) Subject: add filter/jackrack to services.txt and apply a performance tweak to filter_jackrack X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=baa6c5f10b093b5616bc1040ee75d216d7820797;p=mlt add filter/jackrack to services.txt and apply a performance tweak to filter_jackrack git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@582 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/docs/services.txt b/docs/services.txt index f5565a39..b3877490 100644 --- a/docs/services.txt +++ b/docs/services.txt @@ -688,6 +688,53 @@ Filters none + jackrack + + Description + + Creates Jack ports and runs a JackRack project to process audio + through a stack of LADSPA filters. + + Constructor Argument + + src - a JackRack file + + Details + + If you are using a consumer that uses ALSA, then you should start + jacks with the dummy driver: jackd -d dummy. + I also recommend using a period size of 2048: -p 2048. + + jackd -ddummy -r48000 -p2048 + + Initialisation Properties + + int in - in point + int out - out point + + The following can be used without a rack file in order to connect + filter_jackrack to a running instance of JackRack: + string out_1 - Jack port to connect MLT's output port (JackRack's input) + string out_2 - Jack port to connect MLT's output port (JackRack's input) + string in_1 - Jack port to connect MLT's input port (JackRack's output) + string in_2 - Jack port to connect MLT's input port (JackRack's output) + + Read Only Properties + + none + + Mutable Properties + + none + + Dependencies + + Jack, LADSPA, glib-2.0, libxml2 + + Known Bugs + + no encapsulated resampling and jack runs at a fixed frequency + luma Description diff --git a/src/modules/jackrack/filter_jackrack.c b/src/modules/jackrack/filter_jackrack.c index 954917d7..83e46fdf 100644 --- a/src/modules/jackrack/filter_jackrack.c +++ b/src/modules/jackrack/filter_jackrack.c @@ -196,9 +196,6 @@ static int jack_process (jack_nframes_t frames, void * data) total_size += ring_size; if ( first_ring_size == -sizeof(float) || total_size >= first_ring_size ) { - // Set flag to skip this henceforth - mlt_properties_set_int( properties, "_samples", -1 ); - // Return audio through in port jack_input_buffers[i] = jack_port_get_buffer( jack_input_ports[i], frames ); if ( ! jack_input_buffers[i] ) @@ -212,11 +209,15 @@ static int jack_process (jack_nframes_t frames, void * data) jack_ringbuffer_write( input_buffers[i], ( char * )jack_input_buffers[i], ring_size < jack_size ? ring_size : jack_size ); // Tell mlt that audio is available - if ( i == ( channels - 1 ) && pthread_mutex_trylock( output_lock) == 0 ) + if ( first_ring_size != -sizeof(float) && i == ( channels - 1 ) + && pthread_mutex_trylock( output_lock) == 0 ) { pthread_cond_signal( output_ready ); pthread_mutex_unlock( output_lock ); } + + // Set flag to skip this henceforth + mlt_properties_set_int( properties, "_samples", -1 ); } } @@ -273,33 +274,31 @@ static int jackrack_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form // fprintf( stderr, "%s: out buffer size %d\n", __FUNCTION__, jack_ringbuffer_write_space( output_buffers[0] ) ); // Read from input ringbuffer and convert from floats - while ( jack_ringbuffer_read_space( input_buffers[ *channels - 1 ] ) < ( *samples * sizeof(float) ) ) + while ( mlt_properties_get_int( filter_properties, "_samples" ) != -1 + && jack_ringbuffer_read_space( input_buffers[ *channels - 1 ] ) < ( *samples * sizeof(float) ) ) pthread_cond_wait( output_ready, output_lock ); - { - q = *buffer; - - // Initialise to silence, but repeat last frame if available in case of - // buffer underrun - sample = 0; + + q = *buffer; - for ( i = 0; i < *samples; i++ ) - for ( j = 0; j < *channels; j++ ) - { - jack_ringbuffer_read( input_buffers[j], ( char * )&sample, sizeof(float) ); + // Initialise to silence, but repeat last frame if available in case of + // buffer underrun + sample = 0; + + for ( i = 0; i < *samples; i++ ) + for ( j = 0; j < *channels; j++ ) + { + jack_ringbuffer_read( input_buffers[j], ( char * )&sample, sizeof(float) ); - if ( sample > 1.0 ) - sample = 1.0; - else if ( sample < -1.0 ) - sample = -1.0; - - if ( sample > 0 ) - *q ++ = 32767 * sample; - else - *q ++ = 32768 * sample; - } - } - //else - // fprintf( stderr, "%s: in buffer size %d\n", __FUNCTION__, jack_ringbuffer_read_space( output_buffers[0] ) ); + if ( sample > 1.0 ) + sample = 1.0; + else if ( sample < -1.0 ) + sample = -1.0; + + if ( sample > 0 ) + *q ++ = 32767 * sample; + else + *q ++ = 32768 * sample; + } return 0; }