]> git.sesse.net Git - mlt/commitdiff
consumer read ahead and int32_t migration
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 4 Mar 2004 12:17:34 +0000 (12:17 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Thu, 4 Mar 2004 12:17:34 +0000 (12:17 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@192 d19143bc-622f-0410-bfdd-b5b2a6649095

12 files changed:
src/framework/mlt_consumer.c
src/framework/mlt_consumer.h
src/humperdink/client.c
src/miracle/miracle_unit.c
src/miracle/miracle_unit.h
src/miracle/miracle_unit_commands.c
src/modules/dv/consumer_libdv.c
src/modules/sdl/consumer_sdl.c
src/valerie/valerie.c
src/valerie/valerie.h
src/valerie/valerie_status.c
src/valerie/valerie_status.h

index 51298bd309c2157df3c25452371dcfd3028abf7d..5845d516a7a8518e44ecc67e433d1da4bea91779 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <sys/time.h>
 
 /** 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 );
 
index 290d02b88293a7648ebca9bb3abb0c01e88c9bc3..1881ded567c5db0970076d443dbf8a43b95abc80 100644 (file)
@@ -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 );
index 0705c1466b9dff899a9ccea0c23845b240f8b3a2..e93c2f8d918abce8ab963c0ceec5582e176fe892 100644 (file)
@@ -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 );
index 4fbfdbc2bd88deca8b9030507f8787d72fa5d5c5..83f0f024c7b93124e32ac9350fcdba5e5683e7a7 100644 (file)
@@ -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 );
index 9cf26638a93c830c8056d2fc93cef7a9a655d0c4..07d38341e8078564105de5f45708c77b4d864c8c 100644 (file)
@@ -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 );
index 66f84bb89bd5ca70352d978a3801a4713ca7dbf7..af242a44667ab9c0d8adb2da238220d1fef8ff79 100644 (file)
@@ -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 ) );
index 15fa136ad1d9b74a02791607273c80748272add8..1d4fafa107c789fce82f79cda2b5d7e6fb2faa1f 100644 (file)
@@ -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 )
index 8ddabcdad85ac98638b76dd18e04d9a18444ba8e..b06ca484fc9fdc459c59bd935dac949f2f340a0d 100644 (file)
@@ -27,7 +27,7 @@
 #include <pthread.h>
 #include <SDL/SDL.h>
 #include <SDL/SDL_syswm.h>
-#include <sys/timeb.h>
+#include <sys/time.h>
 
 /** 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 );
                }
        }
 
index f2731539e00d11f0d74c0316d589921e130d74f4..428ed0b6ab8c99013355a121008ec8538394f7d0 100644 (file)
@@ -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.
index 658ef9a6b042fe8c1dae883009fe119734d54ef7..2ff0020b9ab3bf98927748b66f341be445fea164 100644 (file)
@@ -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;
 
index 5e4cbd20771d86ecc136a14023f83cfd8e9aa456..1b1d55159aaffbc30b452b9664d8f6cc74aadeba 100644 (file)
@@ -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,
index f20dcff00dafddb4c8f74b041862f97037ce8888..2b77c7b27355dcc07ec936f2965a5eeb48ffa821 100644 (file)
@@ -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;