From: lilo_booter Date: Thu, 4 Mar 2004 12:17:34 +0000 (+0000) Subject: consumer read ahead and int32_t migration X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=5c299d1ae6f3535df35b3f30bae0476a1ca50aa6;p=melted consumer read ahead and int32_t migration git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@192 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 51298bd..5845d51 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -26,6 +26,7 @@ #include #include #include +#include /** Public final methods */ @@ -181,6 +182,164 @@ mlt_frame mlt_consumer_get_frame( mlt_consumer this ) return frame; } +static inline long time_difference( struct timeval *time1 ) +{ + struct timeval time2; + time2.tv_sec = time1->tv_sec; + time2.tv_usec = time1->tv_usec; + gettimeofday( time1, NULL ); + return time1->tv_sec * 1000000 + time1->tv_usec - time2.tv_sec * 1000000 - time2.tv_usec; +} + +static void *consumer_read_ahead_thread( void *arg ) +{ + // The argument is the consumer + mlt_consumer this = arg; + + // Get the properties of the consumer + mlt_properties properties = mlt_consumer_properties( this ); + + // Get the width and height + int width = mlt_properties_get_int( properties, "width" ); + int height = mlt_properties_get_int( properties, "height" ); + + // General frame variable + mlt_frame frame = NULL; + uint8_t *image = NULL; + + // Time structures + struct timeval ante; + + // Average time for get_frame and get_image + int count = 1; + int64_t time_wait = 0; + int64_t time_frame = 0; + int64_t time_image = 0; + + // Get the first frame + gettimeofday( &ante, NULL ); + frame = mlt_consumer_get_frame( this ); + time_frame = time_difference( &ante ); + + // Get the image of the first frame + mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 ); + mlt_properties_set_int( mlt_frame_properties( frame ), "rendered", 1 ); + time_image = time_difference( &ante ); + + // Continue to read ahead + while ( this->ahead ) + { + // Put the current frame into the queue + pthread_mutex_lock( &this->mutex ); + while( this->ahead && mlt_deque_count( this->queue ) >= 25 ) + pthread_cond_wait( &this->cond, &this->mutex ); + mlt_deque_push_back( this->queue, frame ); + pthread_cond_broadcast( &this->cond ); + pthread_mutex_unlock( &this->mutex ); + time_wait += time_difference( &ante ); + + // Get the next frame + frame = mlt_consumer_get_frame( this ); + time_frame += time_difference( &ante ); + + // Increment the count + count ++; + + // Get the image + if ( ( time_frame + time_image + time_wait ) / count < 40000 ) + { + // Get the image, mark as rendered and time it + mlt_frame_get_image( frame, &image, &this->format, &width, &height, 0 ); + mlt_properties_set_int( mlt_frame_properties( frame ), "rendered", 1 ); + time_image += time_difference( &ante ); + } + else + { + // This is wrong, but it avoids slower machines getting starved + // It is, after all, impossible to go back in time :-/ + time_image -= ( time_image / count / 8 ); + } + } + + // Remove the last frame + mlt_frame_close( frame ); + + return NULL; +} + +static void consumer_read_ahead_start( mlt_consumer this ) +{ + // We're running now + this->ahead = 1; + + // Create the frame queue + this->queue = mlt_deque_init( ); + + // Create the mutex + pthread_mutex_init( &this->mutex, NULL ); + + // Create the condition + pthread_cond_init( &this->cond, NULL ); + + // Create the read ahead + pthread_create( &this->ahead_thread, NULL, consumer_read_ahead_thread, this ); + +} + +static void consumer_read_ahead_stop( mlt_consumer this ) +{ + // Make sure we're running + if ( this->ahead ) + { + // Inform thread to stop + this->ahead = 0; + + // Broadcast to the condition in case it's waiting + pthread_mutex_lock( &this->mutex ); + pthread_cond_broadcast( &this->cond ); + pthread_mutex_unlock( &this->mutex ); + + // Join the thread + pthread_join( this->ahead_thread, NULL ); + + // Destroy the mutex + pthread_mutex_destroy( &this->mutex ); + + // Destroy the condition + pthread_cond_destroy( &this->cond ); + + // Wipe the queue + while ( mlt_deque_count( this->queue ) ) + mlt_frame_close( mlt_deque_pop_back( this->queue ) ); + } +} + +mlt_frame mlt_consumer_rt_frame( mlt_consumer this, mlt_image_format format ) +{ + // Frame to return + mlt_frame frame = NULL; + int size = 1; + + + // Is the read ahead running? + if ( this->ahead == 0 ) + { + this->format = format; + consumer_read_ahead_start( this ); + size = 12; + } + + // Get frame from queue + pthread_mutex_lock( &this->mutex ); + while( this->ahead && mlt_deque_count( this->queue ) < size ) + pthread_cond_wait( &this->cond, &this->mutex ); + frame = mlt_deque_pop_front( this->queue ); + pthread_cond_broadcast( &this->cond ); + pthread_mutex_unlock( &this->mutex ); + + return frame; +} + /** Stop the consumer. */ @@ -193,6 +352,9 @@ int mlt_consumer_stop( mlt_consumer this ) if ( this->stop != NULL ) this->stop( this ); + // Kill the read ahead + consumer_read_ahead_stop( this ); + // Kill the test card mlt_properties_set_data( properties, "test_card_producer", NULL, 0, NULL, NULL ); diff --git a/src/framework/mlt_consumer.h b/src/framework/mlt_consumer.h index 290d02b..1881ded 100644 --- a/src/framework/mlt_consumer.h +++ b/src/framework/mlt_consumer.h @@ -43,11 +43,11 @@ struct mlt_consumer_s void *child; int ahead; - int width; - int height; mlt_image_format format; mlt_deque queue; pthread_t ahead_thread; + pthread_mutex_t mutex; + pthread_cond_t cond; }; /** Public final methods @@ -59,6 +59,7 @@ extern mlt_properties mlt_consumer_properties( mlt_consumer this ); extern int mlt_consumer_connect( mlt_consumer this, mlt_service producer ); extern int mlt_consumer_start( mlt_consumer this ); extern mlt_frame mlt_consumer_get_frame( mlt_consumer this ); +extern mlt_frame mlt_consumer_rt_frame( mlt_consumer this, mlt_image_format format ); extern int mlt_consumer_stop( mlt_consumer this ); extern int mlt_consumer_is_stopped( mlt_consumer this ); extern void mlt_consumer_close( mlt_consumer ); diff --git a/src/humperdink/client.c b/src/humperdink/client.c index 0705c14..e93c2f8 100644 --- a/src/humperdink/client.c +++ b/src/humperdink/client.c @@ -147,7 +147,7 @@ void dv_demo_show_status( dv_demo demo, valerie_status status ) break; } - sprintf( temp + strlen( temp ), " %9lld %9lld %9lld ", status->in, status->position, status->out ); + sprintf( temp + strlen( temp ), " %9d %9d %9d ", status->in, status->position, status->out ); strcat( temp, status->clip ); printf( "%-80.80s\r", temp ); diff --git a/src/miracle/miracle_unit.c b/src/miracle/miracle_unit.c index 4fbfdbc..83f0f02 100644 --- a/src/miracle/miracle_unit.c +++ b/src/miracle/miracle_unit.c @@ -246,7 +246,7 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) { mlt_playlist_clip_info info; mlt_playlist_get_clip_info( playlist , &info, i ); - valerie_response_printf( response, 10240, "%d \"%s\" %lld %lld %lld %lld %.2f\n", + valerie_response_printf( response, 10240, "%d \"%s\" %d %d %d %d %.2f\n", i, strip_root( unit, info.resource ), info.frame_in, @@ -267,7 +267,7 @@ void miracle_unit_report_list( miracle_unit unit, valerie_response response ) \param out The ending frame (-1 for maximum) */ -valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, int64_t out, int flush ) +valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int32_t in, int32_t out, int flush ) { // Now try to create an producer mlt_producer instance = create_producer( clip ); @@ -287,7 +287,7 @@ valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, return valerie_invalid_file; } -valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int64_t in, int64_t out ) +valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int32_t in, int32_t out ) { mlt_producer instance = locate_producer( unit, clip ); @@ -345,7 +345,7 @@ valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ) \param out The ending frame (-1 for maximum) */ -valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out ) +valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int32_t in, int32_t out ) { mlt_producer instance = locate_producer( unit, clip ); @@ -511,7 +511,7 @@ int miracle_unit_get_status( miracle_unit unit, valerie_status status ) /** Change position in the playlist. */ -void miracle_unit_change_position( miracle_unit unit, int clip, int64_t position ) +void miracle_unit_change_position( miracle_unit unit, int clip, int32_t position ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -531,8 +531,8 @@ void miracle_unit_change_position( miracle_unit unit, int clip, int64_t position if ( mlt_playlist_get_clip_info( playlist, &info, clip ) == 0 ) { - int64_t frame_start = info.start; - int64_t frame_offset = position; + int32_t frame_start = info.start; + int32_t frame_offset = position; if ( frame_offset < 0 ) frame_offset = info.frame_out; @@ -561,7 +561,7 @@ int miracle_unit_get_current_clip( miracle_unit unit ) /** Set a clip's in point */ -int miracle_unit_set_clip_in( miracle_unit unit, int index, int64_t position ) +int miracle_unit_set_clip_in( miracle_unit unit, int index, int32_t position ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -582,7 +582,7 @@ int miracle_unit_set_clip_in( miracle_unit unit, int index, int64_t position ) /** Set a clip's out point. */ -int miracle_unit_set_clip_out( miracle_unit unit, int index, int64_t position ) +int miracle_unit_set_clip_out( miracle_unit unit, int index, int32_t position ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); @@ -604,7 +604,7 @@ int miracle_unit_set_clip_out( miracle_unit unit, int index, int64_t position ) /** Step by specified position. */ -void miracle_unit_step( miracle_unit unit, int64_t offset ) +void miracle_unit_step( miracle_unit unit, int32_t offset ) { mlt_properties properties = unit->properties; mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); diff --git a/src/miracle/miracle_unit.h b/src/miracle/miracle_unit.h index 9cf2663..07d3834 100644 --- a/src/miracle/miracle_unit.h +++ b/src/miracle/miracle_unit.h @@ -42,9 +42,9 @@ miracle_unit_t, *miracle_unit; extern miracle_unit miracle_unit_init( int index, char *arg ); extern void miracle_unit_report_list( miracle_unit unit, valerie_response response ); extern void miracle_unit_allow_stdin( miracle_unit unit, int flag ); -extern valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, int64_t out, int flush ); -extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int64_t in, int64_t out ); -extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out ); +extern valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int32_t in, int32_t out, int flush ); +extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int32_t in, int32_t out ); +extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int32_t in, int32_t out ); extern valerie_error_code miracle_unit_remove( miracle_unit unit, int index ); extern valerie_error_code miracle_unit_clean( miracle_unit unit ); extern valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ); @@ -57,15 +57,15 @@ extern int miracle_unit_get_channel( miracle_unit unit ); extern int miracle_unit_is_offline( miracle_unit unit ); extern void miracle_unit_set_notifier( miracle_unit, valerie_notifier, char * ); extern int miracle_unit_get_status( miracle_unit, valerie_status ); -extern void miracle_unit_change_position( miracle_unit, int, int64_t position ); +extern void miracle_unit_change_position( miracle_unit, int, int32_t position ); extern void miracle_unit_change_speed( miracle_unit unit, int speed ); -extern int miracle_unit_set_clip_in( miracle_unit unit, int index, int64_t position ); -extern int miracle_unit_set_clip_out( miracle_unit unit, int index, int64_t position ); +extern int miracle_unit_set_clip_in( miracle_unit unit, int index, int32_t position ); +extern int miracle_unit_set_clip_out( miracle_unit unit, int index, int32_t position ); //extern void miracle_unit_set_mode( miracle_unit unit, dv_player_clip_mode mode ); //extern dv_player_clip_mode miracle_unit_get_mode( miracle_unit unit ); //extern void miracle_unit_set_eof_action( miracle_unit unit, dv_player_eof_action mode ); //extern dv_player_eof_action miracle_unit_get_eof_action( miracle_unit unit ); -extern void miracle_unit_step( miracle_unit unit, int64_t offset ); +extern void miracle_unit_step( miracle_unit unit, int32_t offset ); extern void miracle_unit_close( miracle_unit unit ); extern void miracle_unit_suspend( miracle_unit ); extern void miracle_unit_restore( miracle_unit ); diff --git a/src/miracle/miracle_unit_commands.c b/src/miracle/miracle_unit_commands.c index 66f84bb..af242a4 100644 --- a/src/miracle/miracle_unit_commands.c +++ b/src/miracle/miracle_unit_commands.c @@ -56,7 +56,7 @@ int miracle_load( command_argument cmd_arg ) return RESPONSE_INVALID_UNIT; else { - int64_t in = -1, out = -1; + int32_t in = -1, out = -1; if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) { in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); @@ -207,7 +207,7 @@ int miracle_append( command_argument cmd_arg ) return RESPONSE_INVALID_UNIT; else { - int64_t in = -1, out = -1; + int32_t in = -1, out = -1; if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) { in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); diff --git a/src/modules/dv/consumer_libdv.c b/src/modules/dv/consumer_libdv.c index 15fa136..1d4fafa 100644 --- a/src/modules/dv/consumer_libdv.c +++ b/src/modules/dv/consumer_libdv.c @@ -363,7 +363,7 @@ static void *consumer_thread( void *arg ) while( mlt_properties_get_int( properties, "running" ) ) { // Get the frame - mlt_frame frame = mlt_consumer_get_frame( this ); + mlt_frame frame = mlt_consumer_rt_frame( this, mlt_image_yuv422 ); // Check that we have a frame to work with if ( frame != NULL ) diff --git a/src/modules/sdl/consumer_sdl.c b/src/modules/sdl/consumer_sdl.c index 8ddabcd..b06ca48 100644 --- a/src/modules/sdl/consumer_sdl.c +++ b/src/modules/sdl/consumer_sdl.c @@ -27,7 +27,7 @@ #include #include #include -#include +#include /** This classes definition. */ @@ -275,7 +275,7 @@ static int consumer_play_audio( consumer_sdl this, mlt_frame frame, int init_aud request.freq = frequency; request.format = AUDIO_S16; request.channels = channels; - request.samples = 2048; + request.samples = 4096; request.callback = sdl_fill_audio; request.userdata = (void *)this; if ( SDL_OpenAudio( &request, &got ) != 0 ) @@ -323,9 +323,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap uint8_t *image; int changed = 0; - struct timeb before; - ftime( &before ); - if ( mlt_properties_get_int( properties, "video_off" ) ) { mlt_frame_close( frame ); @@ -336,75 +333,25 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap mlt_properties_set_position( mlt_frame_properties( frame ), "playtime", playtime ); mlt_properties_set_double( mlt_frame_properties( frame ), "consumer_scale", ( double )height / mlt_properties_get_double( properties, "height" ) ); - if ( !this->playing ) - { - struct timeb render; - mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 ); - ftime( &render ); - this->time_taken = ( ( int64_t )render.time * 1000 + render.millitm ) - ( ( int64_t )before.time * 1000 + before.millitm ); - mlt_properties_set( mlt_frame_properties( frame ), "rendered", "true" ); - } - // Push this frame to the back of the queue mlt_deque_push_back( this->queue, frame ); frame = NULL; if ( this->playing ) - { - // We might want to use an old frame if the current frame is skipped - mlt_frame candidate = NULL; - - while ( frame == NULL && mlt_deque_count( this->queue ) ) - { - frame = mlt_deque_peek_front( this->queue ); - playtime = mlt_properties_get_position( mlt_frame_properties( frame ), "playtime" ); - - // Check if frame is in the future or past - if ( mlt_deque_count( this->queue ) > 25 ) - { - frame = mlt_deque_pop_front( this->queue ); - } - else if ( playtime > elapsed + 100 ) - { - // no frame to show or remove - frame = NULL; - break; - } - else if ( playtime < elapsed - 20 ) - { - mlt_frame_close( candidate ); - candidate = mlt_deque_pop_front( this->queue ); - if ( mlt_properties_get( mlt_frame_properties( frame ), "rendered" ) == NULL ) - { - mlt_frame_close( candidate ); - candidate = NULL; - } - frame = NULL; - } - else - { - // Get the frame at the front of the queue - frame = mlt_deque_pop_front( this->queue ); - } - } - - if ( frame == NULL ) - frame = candidate; - else if ( candidate != NULL ) - mlt_frame_close( candidate ); - } + frame = mlt_deque_pop_front( this->queue ); - struct timeb render; - ftime( &render ); - - if ( this->playing && frame != NULL ) + if ( this->playing && frame != NULL && mlt_properties_get_int( mlt_frame_properties( frame ), "rendered" ) == 1 ) { + playtime = mlt_properties_get_position( mlt_frame_properties( frame ), "playtime" ); // Get the image, width and height mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 ); - ftime( &render ); - if ( mlt_properties_get( mlt_frame_properties( frame ), "rendered" ) == NULL ) - this->time_taken = ( ( int64_t )render.time * 1000 + render.millitm ) - ( ( int64_t )before.time * 1000 + before.millitm ); + + if ( playtime > elapsed + 20000 ) + { + struct timespec tm = { ( playtime - elapsed ) / 1000000, ( ( playtime - elapsed ) % 1000000 ) * 1000 }; + nanosleep( &tm, NULL ); + } // Handle events if ( this->sdl_screen != NULL ) @@ -514,33 +461,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame, int64_t elap if ( frame != NULL ) mlt_frame_close( frame ); - struct timeb after; - ftime( &after ); - int processing = ( ( int64_t )after.time * 1000 + after.millitm ) - ( ( int64_t )render.time * 1000 + render.millitm ); - int delay = playtime - elapsed - processing; - - if ( delay > this->time_taken && mlt_deque_count( this->queue ) ) - { - mlt_frame next = mlt_deque_peek_front( this->queue ); - playtime = mlt_properties_get_position( mlt_frame_properties( next ), "playtime" ); - if ( playtime > elapsed + delay ) - { - struct timeb render; - mlt_frame_get_image( next, &image, &vfmt, &width, &height, 0 ); - ftime( &render ); - this->time_taken = ( ( int64_t )render.time * 1000 + render.millitm ) - ( ( int64_t )after.time * 1000 + after.millitm ); - mlt_properties_set( mlt_frame_properties( next ), "rendered", "true" ); - } - else - { - this->time_taken /= 2; - } - } - else - { - this->time_taken /= 2; - } - return 0; } @@ -559,7 +479,7 @@ static void *consumer_thread( void *arg ) int init_audio = 1; // Obtain time of thread start - struct timeb now; + struct timeval now; int64_t start = 0; int64_t elapsed = 0; int duration = 0; @@ -578,7 +498,7 @@ static void *consumer_thread( void *arg ) while( this->running ) { // Get a frame from the attached producer - mlt_frame frame = mlt_consumer_get_frame( consumer ); + mlt_frame frame = mlt_consumer_rt_frame( consumer, mlt_image_yuv422 ); // Ensure that we have a frame if ( frame != NULL ) @@ -589,18 +509,19 @@ static void *consumer_thread( void *arg ) if ( this->playing ) { // Get the current time - ftime( &now ); + gettimeofday( &now, NULL ); // Determine elapsed time if ( start == 0 ) - start = ( int64_t )now.time * 1000 + now.millitm; + start = ( int64_t )now.tv_sec * 1000000 + now.tv_usec; else - elapsed = ( ( int64_t )now.time * 1000 + now.millitm ) - start; + elapsed = ( ( int64_t )now.tv_sec * 1000000 + now.tv_usec) - start; + } consumer_play_video( this, frame, elapsed, playtime ); - playtime += duration; + playtime += ( duration * 1000 ); } } diff --git a/src/valerie/valerie.c b/src/valerie/valerie.c index f273153..428ed0b 100644 --- a/src/valerie/valerie.c +++ b/src/valerie/valerie.c @@ -223,9 +223,9 @@ static void valerie_interpret_clip_offset( char *output, valerie_clip_offset off /** Load a file on the specified unit with the specified in/out points. */ -valerie_error_code valerie_unit_load_clipped( valerie this, int unit, char *file, int64_t in, int64_t out ) +valerie_error_code valerie_unit_load_clipped( valerie this, int unit, char *file, int32_t in, int32_t out ) { - return valerie_execute( this, 10240, "LOAD U%d \"%s\" %lld %lld", unit, file, in, out ); + return valerie_execute( this, 10240, "LOAD U%d \"%s\" %d %d", unit, file, in, out ); } /** Load a file on the specified unit at the end of the current pump. @@ -239,17 +239,17 @@ valerie_error_code valerie_unit_load_back( valerie this, int unit, char *file ) /** Load a file on the specified unit at the end of the pump with the specified in/out points. */ -valerie_error_code valerie_unit_load_back_clipped( valerie this, int unit, char *file, int64_t in, int64_t out ) +valerie_error_code valerie_unit_load_back_clipped( valerie this, int unit, char *file, int32_t in, int32_t out ) { - return valerie_execute( this, 10240, "LOAD U%d \"!%s\" %lld %lld", unit, file, in, out ); + return valerie_execute( this, 10240, "LOAD U%d \"!%s\" %d %d", unit, file, in, out ); } /** Append a file on the specified unit. */ -valerie_error_code valerie_unit_append( valerie this, int unit, char *file, int64_t in, int64_t out ) +valerie_error_code valerie_unit_append( valerie this, int unit, char *file, int32_t in, int32_t out ) { - return valerie_execute( this, 10240, "APND U%d \"%s\" %lld %lld", unit, file, in, out ); + return valerie_execute( this, 10240, "APND U%d \"%s\" %d %d", unit, file, in, out ); } /** Clean the unit - this function removes all but the currently playing clip. @@ -293,11 +293,11 @@ valerie_error_code valerie_unit_remove_current_clip( valerie this, int unit ) /** Insert clip at the specified position. */ -valerie_error_code valerie_unit_clip_insert( valerie this, int unit, valerie_clip_offset offset, int clip, char *file, int64_t in, int64_t out ) +valerie_error_code valerie_unit_clip_insert( valerie this, int unit, valerie_clip_offset offset, int clip, char *file, int32_t in, int32_t out ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "INSERT U%d %s %s %lld %lld", unit, file, temp, in, out ); + return valerie_execute( this, 1024, "INSERT U%d %s %s %d %d", unit, file, temp, in, out ); } /** Play the unit at normal speed. @@ -351,63 +351,63 @@ valerie_error_code valerie_unit_fast_forward( valerie this, int unit ) /** Step by the number of frames on the specified unit. */ -valerie_error_code valerie_unit_step( valerie this, int unit, int64_t step ) +valerie_error_code valerie_unit_step( valerie this, int unit, int32_t step ) { - return valerie_execute( this, 1024, "STEP U%d %lld", unit, step ); + return valerie_execute( this, 1024, "STEP U%d %d", unit, step ); } /** Goto the specified frame on the specified unit. */ -valerie_error_code valerie_unit_goto( valerie this, int unit, int64_t position ) +valerie_error_code valerie_unit_goto( valerie this, int unit, int32_t position ) { - return valerie_execute( this, 1024, "GOTO U%d %lld", unit, position ); + return valerie_execute( this, 1024, "GOTO U%d %d", unit, position ); } /** Goto the specified frame in the clip on the specified unit. */ -valerie_error_code valerie_unit_clip_goto( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t position ) +valerie_error_code valerie_unit_clip_goto( valerie this, int unit, valerie_clip_offset offset, int clip, int32_t position ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "GOTO U%d %lld %s", unit, position, temp ); + return valerie_execute( this, 1024, "GOTO U%d %d %s", unit, position, temp ); } /** Set the in point of the loaded file on the specified unit. */ -valerie_error_code valerie_unit_set_in( valerie this, int unit, int64_t in ) +valerie_error_code valerie_unit_set_in( valerie this, int unit, int32_t in ) { - return valerie_execute( this, 1024, "SIN U%d %lld", unit, in ); + return valerie_execute( this, 1024, "SIN U%d %d", unit, in ); } /** Set the in point of the clip on the specified unit. */ -valerie_error_code valerie_unit_clip_set_in( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t in ) +valerie_error_code valerie_unit_clip_set_in( valerie this, int unit, valerie_clip_offset offset, int clip, int32_t in ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "SIN U%d %lld %s", unit, in, temp ); + return valerie_execute( this, 1024, "SIN U%d %d %s", unit, in, temp ); } /** Set the out point of the loaded file on the specified unit. */ -valerie_error_code valerie_unit_set_out( valerie this, int unit, int64_t out ) +valerie_error_code valerie_unit_set_out( valerie this, int unit, int32_t out ) { - return valerie_execute( this, 1024, "SOUT U%d %lld", unit, out ); + return valerie_execute( this, 1024, "SOUT U%d %d", unit, out ); } /** Set the out point of the clip on the specified unit. */ -valerie_error_code valerie_unit_clip_set_out( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t in ) +valerie_error_code valerie_unit_clip_set_out( valerie this, int unit, valerie_clip_offset offset, int clip, int32_t in ) { char temp[ 100 ]; valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "SOUT U%d %lld %s", unit, in, temp ); + return valerie_execute( this, 1024, "SOUT U%d %d %s", unit, in, temp ); } /** Clear the in point of the loaded file on the specified unit. diff --git a/src/valerie/valerie.h b/src/valerie/valerie.h index 658ef9a..2ff0020 100644 --- a/src/valerie/valerie.h +++ b/src/valerie/valerie.h @@ -90,28 +90,28 @@ extern valerie_error_code valerie_run( valerie, char * ); /* Unit functions */ extern valerie_error_code valerie_unit_add( valerie, char *, int * ); extern valerie_error_code valerie_unit_load( valerie, int, char * ); -extern valerie_error_code valerie_unit_load_clipped( valerie, int, char *, int64_t, int64_t ); +extern valerie_error_code valerie_unit_load_clipped( valerie, int, char *, int32_t, int32_t ); extern valerie_error_code valerie_unit_load_back( valerie, int, char * ); -extern valerie_error_code valerie_unit_load_back_clipped( valerie, int, char *, int64_t, int64_t ); -extern valerie_error_code valerie_unit_append( valerie, int, char *, int64_t, int64_t ); +extern valerie_error_code valerie_unit_load_back_clipped( valerie, int, char *, int32_t, int32_t ); +extern valerie_error_code valerie_unit_append( valerie, int, char *, int32_t, int32_t ); extern valerie_error_code valerie_unit_clean( valerie, int ); extern valerie_error_code valerie_unit_clip_move( valerie, int, valerie_clip_offset, int, valerie_clip_offset, int ); extern valerie_error_code valerie_unit_clip_remove( valerie, int, valerie_clip_offset, int ); extern valerie_error_code valerie_unit_remove_current_clip( valerie, int ); -extern valerie_error_code valerie_unit_clip_insert( valerie, int, valerie_clip_offset, int, char *, int64_t, int64_t ); +extern valerie_error_code valerie_unit_clip_insert( valerie, int, valerie_clip_offset, int, char *, int32_t, int32_t ); extern valerie_error_code valerie_unit_play( valerie, int ); extern valerie_error_code valerie_unit_play_at_speed( valerie, int, int ); extern valerie_error_code valerie_unit_stop( valerie, int ); extern valerie_error_code valerie_unit_pause( valerie, int ); extern valerie_error_code valerie_unit_rewind( valerie, int ); extern valerie_error_code valerie_unit_fast_forward( valerie, int ); -extern valerie_error_code valerie_unit_step( valerie, int, int64_t ); -extern valerie_error_code valerie_unit_goto( valerie, int, int64_t ); -extern valerie_error_code valerie_unit_clip_goto( valerie, int, valerie_clip_offset, int, int64_t ); -extern valerie_error_code valerie_unit_clip_set_in( valerie, int, valerie_clip_offset, int, int64_t ); -extern valerie_error_code valerie_unit_clip_set_out( valerie, int, valerie_clip_offset, int, int64_t ); -extern valerie_error_code valerie_unit_set_in( valerie, int, int64_t ); -extern valerie_error_code valerie_unit_set_out( valerie, int, int64_t ); +extern valerie_error_code valerie_unit_step( valerie, int, int32_t ); +extern valerie_error_code valerie_unit_goto( valerie, int, int32_t ); +extern valerie_error_code valerie_unit_clip_goto( valerie, int, valerie_clip_offset, int, int32_t ); +extern valerie_error_code valerie_unit_clip_set_in( valerie, int, valerie_clip_offset, int, int32_t ); +extern valerie_error_code valerie_unit_clip_set_out( valerie, int, valerie_clip_offset, int, int32_t ); +extern valerie_error_code valerie_unit_set_in( valerie, int, int32_t ); +extern valerie_error_code valerie_unit_set_out( valerie, int, int32_t ); extern valerie_error_code valerie_unit_clear_in( valerie, int ); extern valerie_error_code valerie_unit_clear_out( valerie, int ); extern valerie_error_code valerie_unit_clear_in_out( valerie, int ); @@ -169,11 +169,11 @@ typedef struct { int clip; char full[ PATH_MAX + NAME_MAX ]; - int64_t in; - int64_t out; - int64_t max; - int64_t size; - int64_t fps; + int32_t in; + int32_t out; + int32_t max; + int32_t size; + int32_t fps; } *valerie_list_entry, valerie_list_entry_t; diff --git a/src/valerie/valerie_status.c b/src/valerie/valerie_status.c index 5e4cbd2..1b1d551 100644 --- a/src/valerie/valerie_status.c +++ b/src/valerie/valerie_status.c @@ -121,7 +121,7 @@ char *valerie_status_serialise( valerie_status status, char *text, int length ) break; } - snprintf( text, length, "%d %s \"%s\" %lld %d %.2f %lld %lld %lld \"%s\" %lld %lld %lld %lld %d %d %d\r\n", + snprintf( text, length, "%d %s \"%s\" %d %d %.2f %d %d %d \"%s\" %d %d %d %d %d %d %d\r\n", status->unit, status_string, status->clip, diff --git a/src/valerie/valerie_status.h b/src/valerie/valerie_status.h index f20dcff..2b77c7b 100644 --- a/src/valerie/valerie_status.h +++ b/src/valerie/valerie_status.h @@ -52,17 +52,17 @@ typedef struct int unit; unit_status status; char clip[ 2048 ]; - int64_t position; + int32_t position; int speed; double fps; - int64_t in; - int64_t out; - int64_t length; + int32_t in; + int32_t out; + int32_t length; char tail_clip[ 2048 ]; - int64_t tail_position; - int64_t tail_in; - int64_t tail_out; - int64_t tail_length; + int32_t tail_position; + int32_t tail_in; + int32_t tail_out; + int32_t tail_length; int seek_flag; int generation; int clip_index;