if ( this->joined == 0 )
{
// Kill the thread and clean up
+ this->joined = 1;
this->running = 0;
-
- pthread_mutex_lock( &this->audio_mutex );
- pthread_cond_broadcast( &this->audio_cond );
- pthread_mutex_unlock( &this->audio_mutex );
-
pthread_join( this->thread, NULL );
- this->joined = 1;
}
return 0;
uint8_t *image;
int changed = 0;
- if ( mlt_properties_get_int( properties, "video_off" ) == 0 )
+ if ( this->running && mlt_properties_get_int( properties, "video_off" ) == 0 )
{
// Get the image, width and height
mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
mlt_properties_set_int( properties, "changed", 0 );
}
- if ( 1 )
+ if ( this->running )
{
// Determine window's new display aspect ratio
float this_aspect = ( float )this->window_width / this->window_height;
SDL_SetClipRect( this->sdl_screen, &this->rect );
}
- if ( this->sdl_screen != NULL && this->sdl_overlay == NULL )
+ if ( this->running && this->sdl_screen != NULL && this->sdl_overlay == NULL )
{
SDL_SetClipRect( this->sdl_screen, &this->rect );
SDL_Flip( this->sdl_screen );
sdl_unlock_display();
}
- if ( this->sdl_screen != NULL && this->sdl_overlay != NULL )
+ if ( this->running && this->sdl_screen != NULL && this->sdl_overlay != NULL )
{
this->buffer = this->sdl_overlay->pixels[ 0 ];
sdl_lock_display();
{
// Pop the next frame
pthread_mutex_lock( &this->video_mutex );
- while ( ( next = mlt_deque_pop_front( this->queue ) ) == NULL && this->running )
+ next = mlt_deque_pop_front( this->queue );
+ while ( next == NULL && this->running )
+ {
pthread_cond_wait( &this->video_cond, &this->video_mutex );
+ next = mlt_deque_pop_front( this->queue );
+ }
pthread_mutex_unlock( &this->video_mutex );
+ if ( !this->running || next == NULL ) break;
+
// Get the properties
properties = MLT_FRAME_PROPERTIES( next );
// This frame can now be closed
mlt_frame_close( next );
+ next = NULL;
}
+ if ( next != NULL )
+ mlt_frame_close( next );
+
mlt_consumer_stopped( &this->parent );
return NULL;
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 )
- SDL_Quit( );
+ //if ( mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "sdl_started" ) == 0 )
+ //SDL_Quit( );
while( mlt_deque_count( this->queue ) )
mlt_frame_close( mlt_deque_pop_back( this->queue ) );
consumer_sdl this = parent->child;
// Stop the consumer
- mlt_consumer_stop( parent );
+ ///mlt_consumer_stop( parent );
+
+ // Now clean up the rest
+ mlt_consumer_close( parent );
// Close the queue
mlt_deque_close( this->queue );
pthread_mutex_destroy( &this->audio_mutex );
pthread_cond_destroy( &this->audio_cond );
- // Now clean up the rest
- mlt_consumer_close( parent );
-
// Finally clean up this
free( this );
}