SDL_Overlay *sdl_overlay;
SDL_Rect rect;
uint8_t *buffer;
+ int bpp;
};
/** Forward references to static functions.
parent->close = consumer_close;
// get a handle on properties
- mlt_service service = mlt_consumer_service( parent );
- this->properties = mlt_service_properties( service );
+ mlt_service service = MLT_CONSUMER_SERVICE( parent );
+ this->properties = MLT_SERVICE_PROPERTIES( service );
// Set the default volume
mlt_properties_set_double( this->properties, "volume", 1.0 );
mlt_properties_set_int( this->properties, "progressive", 0 );
// Default audio buffer
- mlt_properties_set_int( this->properties, "audio_buffer", 1024 );
+ mlt_properties_set_int( this->properties, "audio_buffer", 512 );
// Get sample aspect ratio
this->aspect_ratio = mlt_properties_get_double( this->properties, "aspect_ratio" );
if ( init_audio == 0 )
{
- mlt_properties properties = mlt_frame_properties( frame );
+ mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
bytes = ( samples * channels * 2 );
pthread_mutex_lock( &this->audio_mutex );
while ( this->running && bytes > ( sizeof( this->audio_buffer) - this->audio_avail ) )
SDL_Event event;
changed = consumer_get_dimensions( &this->window_width, &this->window_height );
-
+
while ( SDL_PollEvent( &event ) )
{
mlt_events_fire( this->properties, "consumer-sdl-event", &event, NULL );
}
}
- if ( width != this->width || height != this->height ||
- ( ( int )( this->last_frame_aspect * 1000 ) != ( int )( mlt_frame_get_aspect_ratio( frame ) * 1000 ) &&
- ( mlt_frame_get_aspect_ratio( frame ) != 1.0 || this->last_frame_aspect == 0.0 ) ) )
+ if ( width != this->width || height != this->height )
+ {
+ if ( this->sdl_overlay != NULL )
+ SDL_FreeYUVOverlay( this->sdl_overlay );
+ this->sdl_overlay = NULL;
+ }
+ if ( this->running && ( this->sdl_screen == NULL || changed ) )
{
- this->width = width;
- this->height = height;
- this->last_frame_aspect = mlt_frame_get_aspect_ratio( frame );
- changed = 1;
+ // Force an overlay recreation
+ if ( this->sdl_overlay != NULL )
+ SDL_FreeYUVOverlay( this->sdl_overlay );
+ this->sdl_overlay = NULL;
+
+ // open SDL window with video overlay, if possible
+ sdl_lock_display();
+ this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, this->bpp, this->sdl_flags );
+ sdl_unlock_display();
+ if ( consumer_get_dimensions( &this->window_width, &this->window_height ) )
+ this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, this->bpp, this->sdl_flags );
+ //SDL_Flip( this->sdl_screen );
+ mlt_properties_set_int( properties, "changed", 0 );
+ }
+ else if ( mlt_properties_get_int( properties, "changed" ) )
+ {
+ sdl_lock_display();
+ this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, this->bpp, this->sdl_flags );
+ SDL_SetClipRect( this->sdl_screen, &this->rect );
+ sdl_unlock_display();
+ mlt_properties_set_int( properties, "changed", 0 );
}
- if ( this->sdl_screen == NULL || changed )
+ if ( 1 )
{
- // Determine frame's display aspect ratio
- float frame_aspect = mlt_frame_get_aspect_ratio( frame ) * this->width / this->height;
-
// Determine window's new display aspect ratio
float this_aspect = ( float )this->window_width / this->window_height;
+ // Determine frame's display aspect ratio
+ float frame_aspect = mlt_frame_get_aspect_ratio( frame ) * width / height;
+ this->width = width;
+ this->height = height;
+
// If using hardware scaler
if ( mlt_properties_get( properties, "rescale" ) != NULL &&
!strcmp( mlt_properties_get( properties, "rescale" ), "none" ) )
mlt_properties_set_int( this->properties, "rect_w", this->rect.w );
mlt_properties_set_int( this->properties, "rect_h", this->rect.h );
- // Force an overlay recreation
- if ( this->sdl_overlay != NULL )
- SDL_FreeYUVOverlay( this->sdl_overlay );
-
- // open SDL window with video overlay, if possible
- sdl_lock_display();
- this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
- sdl_unlock_display();
- if ( consumer_get_dimensions( &this->window_width, &this->window_height ) )
- this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
- SDL_Flip( this->sdl_screen );
- mlt_properties_set_int( properties, "changed", 0 );
-
- if ( this->sdl_screen != NULL )
- {
- SDL_SetClipRect( this->sdl_screen, &this->rect );
- sdl_lock_display();
- this->sdl_overlay = SDL_CreateYUVOverlay( this->width, this->height, SDL_YUY2_OVERLAY, this->sdl_screen );
- sdl_unlock_display();
- }
+ SDL_SetClipRect( this->sdl_screen, &this->rect );
}
-
- if ( mlt_properties_get_int( properties, "changed" ) )
+
+ if ( this->sdl_screen != NULL && this->sdl_overlay == NULL )
{
- sdl_lock_display();
- this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
SDL_SetClipRect( this->sdl_screen, &this->rect );
+ SDL_Flip( this->sdl_screen );
+ sdl_lock_display();
+ this->sdl_overlay = SDL_CreateYUVOverlay( this->width, this->height, SDL_YUY2_OVERLAY, this->sdl_screen );
sdl_unlock_display();
- mlt_properties_set_int( properties, "changed", 0 );
}
if ( this->sdl_screen != NULL && this->sdl_overlay != NULL )
pthread_mutex_unlock( &this->video_mutex );
// Get the properties
- properties = mlt_frame_properties( next );
+ properties = MLT_FRAME_PROPERTIES( next );
// Get the speed of the frame
speed = mlt_properties_get_double( properties, "_speed" );
int64_t playtime = 0;
struct timespec tm = { 0, 100000 };
- if ( mlt_properties_get_int( mlt_consumer_properties( consumer ), "sdl_started" ) == 0 )
+ this->bpp = mlt_properties_get_int( this->properties, "bpp" );
+
+ if ( mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "sdl_started" ) == 0 )
{
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0 )
{
else
{
if ( SDL_GetVideoSurface( ) != NULL )
+ {
+ this->sdl_screen = SDL_GetVideoSurface( );
consumer_get_dimensions( &this->window_width, &this->window_height );
- mlt_properties_set_int( mlt_consumer_properties( consumer ), "changed", 1 );
+ mlt_properties_set_int( this->properties, "changed", 0 );
+ }
}
- SDL_InitSubSystem( SDL_INIT_AUDIO );
+ if ( !mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "audio_off" ) )
+ SDL_InitSubSystem( SDL_INIT_AUDIO );
// Loop until told not to
while( this->running )
if ( frame != NULL )
{
// Get the frame properties
- properties = mlt_frame_properties( frame );
+ properties = MLT_FRAME_PROPERTIES( frame );
// Play audio
init_audio = consumer_play_audio( this, frame, init_audio, &duration );
if ( this->sdl_overlay != NULL )
SDL_FreeYUVOverlay( this->sdl_overlay );
- SDL_QuitSubSystem( SDL_INIT_AUDIO );
+ if ( !mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "audio_off" ) )
+ SDL_QuitSubSystem( SDL_INIT_AUDIO );
- if ( mlt_properties_get_int( mlt_consumer_properties( consumer ), "sdl_started" ) == 0 )
+ if ( mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "sdl_started" ) == 0 )
SDL_Quit( );
while( mlt_deque_count( this->queue ) )