X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fsdl%2Fconsumer_sdl.c;h=0d483cf4721ed9a2d2eac10c11cb49673d80bb1a;hb=980bd5cb1c17023459f0330397b817e18b9cb0c3;hp=23f1bd9e11ebb069ccc1ac4a98586704e5a387d9;hpb=66241484cc41f0af876e493bca95b48d39a271bd;p=melted diff --git a/src/modules/sdl/consumer_sdl.c b/src/modules/sdl/consumer_sdl.c index 23f1bd9..0d483cf 100644 --- a/src/modules/sdl/consumer_sdl.c +++ b/src/modules/sdl/consumer_sdl.c @@ -41,7 +41,7 @@ struct consumer_sdl_s mlt_deque queue; pthread_t thread; int running; - uint8_t audio_buffer[ 4096 * 19 ]; + uint8_t audio_buffer[ 4096 * 10 ]; int audio_avail; pthread_mutex_t audio_mutex; pthread_cond_t audio_cond; @@ -454,14 +454,14 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) this->rect.h = this->window_height; } // Use hardware scaler to normalise sample aspect ratio - else if ( this->window_height * frame_aspect > this->window_width ) + else if ( this->window_height * this->display_aspect > this->window_width ) { this->rect.w = this->window_width; - this->rect.h = this->window_width / frame_aspect + 0.5; + this->rect.h = this->window_width / this->display_aspect + 0.5; } else { - this->rect.w = this->window_height * frame_aspect + 0.5; + this->rect.w = this->window_height * this->display_aspect + 0.5; this->rect.h = this->window_height; } @@ -497,6 +497,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) if ( this->sdl_screen != NULL && this->sdl_overlay != NULL ) { this->buffer = this->sdl_overlay->pixels[ 0 ]; + sdl_lock_display(); if ( SDL_LockYUVOverlay( this->sdl_overlay ) >= 0 ) { if ( image != NULL ) @@ -504,6 +505,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) SDL_UnlockYUVOverlay( this->sdl_overlay ); SDL_DisplayYUVOverlay( this->sdl_overlay, &this->sdl_screen->clip_rect ); } + sdl_unlock_display(); } } @@ -523,7 +525,6 @@ static void *video_thread( void *arg ) mlt_frame next = NULL; mlt_properties properties = NULL; double speed = 0; - int skipped = 0; // Get the current time gettimeofday( &now, NULL ); @@ -571,11 +572,9 @@ static void *video_thread( void *arg ) // Show current frame if not too old if ( difference > -10000 || speed != 1.0 || mlt_deque_count( this->queue ) < 2 ) consumer_play_video( this, next ); - else - skipped ++; // If the queue is empty, recalculate start to allow build up again - if ( mlt_deque_count( this->queue ) == 0 ) + if ( mlt_deque_count( this->queue ) == 0 && speed == 1.0 ) { gettimeofday( &now, NULL ); start = ( ( int64_t )now.tv_sec * 1000000 + now.tv_usec ) - scheduled + 20000;