*/
#undef DEINTERLACE_ON_NOT_NORMAL_SPEED
+/** This is not the ideal place for this, but it is needed by VDPAU as well.
+ */
+pthread_mutex_t mlt_sdl_mutex = PTHREAD_MUTEX_INITIALIZER;
+
static void mlt_consumer_frame_render( mlt_listener listener, mlt_properties owner, mlt_service this, void **args );
static void mlt_consumer_frame_show( mlt_listener listener, mlt_properties owner, mlt_service this, void **args );
static void mlt_consumer_property_changed( mlt_service owner, mlt_consumer this, char *name );
{
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0 )
{
- fprintf( stderr, "Failed to initialize SDL: %s\n", SDL_GetError() );
+ mlt_log_error( MLT_CONSUMER_SERVICE(parent), "Failed to initialize SDL: %s\n", SDL_GetError() );
return -1;
}
SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
SDL_EnableUNICODE( 1 );
+
+#ifndef __DARWIN__
+ // Get the wm structure
+ SDL_SysWMinfo wm;
+ SDL_VERSION( &wm.version );
+ // Only on X11
+ if ( SDL_GetWMInfo( &wm ) == 1 && wm.subsystem == SDL_SYSWM_X11 )
+ {
+ // Set the x11_display property for use by VDPAU
+ mlt_properties_set_int( this->properties, "x11_display", (int) wm.info.x11.display );
+ mlt_log_verbose( MLT_CONSUMER_SERVICE(parent), "X11 Display = %p\n", wm.info.x11.display );
+ char tmp[20];
+ sprintf( tmp, "%p", wm.info.x11.display );
+ mlt_environment_set( "x11_display", tmp );
+ }
+#endif
}
else if ( display_off == 0 )
{
SDL_QuitSubSystem( SDL_INIT_AUDIO );
}
- if ( mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent ), "sdl_started" ) == 0 )
- {
- pthread_mutex_lock( &mlt_sdl_mutex );
- SDL_Quit( );
- pthread_mutex_unlock( &mlt_sdl_mutex );
- }
-
this->sdl_screen = NULL;
}
start = ( ( int64_t )now.tv_sec * 1000000 + now.tv_usec ) - scheduled + 20000;
}
}
+ else
+ {
+ mlt_log_debug( MLT_CONSUMER_SERVICE(&this->parent), "dropped video frame\n" );
+ }
// This frame can now be closed
mlt_frame_close( next );
{
// Get the actual object
consumer_sdl this = parent->child;
+ int sdl_started = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent ), "sdl_started" );
// Stop the consumer
///mlt_consumer_stop( parent );
pthread_mutex_destroy( &this->audio_mutex );
pthread_cond_destroy( &this->audio_cond );
+ if ( sdl_started == 0 )
+ {
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ SDL_Quit( );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ }
+
// Finally clean up this
free( this );
}
#include <SDL/SDL.h>
#include <SDL/SDL_syswm.h>
-pthread_mutex_t mlt_sdl_mutex = PTHREAD_MUTEX_INITIALIZER;
+extern pthread_mutex_t mlt_sdl_mutex;
typedef struct consumer_sdl_s *consumer_sdl;
this->joined = 1;
if ( app_locked && lock ) lock( );
-
- pthread_mutex_lock( &mlt_sdl_mutex );
- SDL_Quit( );
- pthread_mutex_unlock( &mlt_sdl_mutex );
}
return 0;
// Now clean up the rest
mlt_consumer_close( parent );
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ SDL_Quit( );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+
// Finally clean up this
free( this );
}
SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
SDL_EnableUNICODE( 1 );
+
+#ifndef __DARWIN__
+ // Get the wm structure
+ SDL_SysWMinfo wm;
+ SDL_VERSION( &wm.version );
+ // Only on X11
+ if ( SDL_GetWMInfo( &wm ) == 1 && wm.subsystem == SDL_SYSWM_X11 )
+ {
+ // Set the x11_display property for use by VDPAU
+ mlt_properties_set_int( this->properties, "x11_display", (int) wm.info.x11.display );
+ mlt_log_verbose( MLT_CONSUMER_SERVICE(parent), "X11 Display = %p\n", wm.info.x11.display );
+ char tmp[20];
+ sprintf( tmp, "%p", wm.info.x11.display );
+ mlt_environment_set( "x11_display", tmp );
+ }
+#endif
}
else if ( preview_off == 0 )
{
if ( this->joined == 0 )
{
- int preview_off = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent ), "preview_off" );
- int sdl_started = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent ), "sdl_started" );
-
// Kill the thread and clean up
this->running = 0;
pthread_join( this->thread, NULL );
this->joined = 1;
- if ( sdl_started == 0 && preview_off == 0 )
- {
- pthread_mutex_lock( &mlt_sdl_mutex );
- SDL_Quit( );
- pthread_mutex_unlock( &mlt_sdl_mutex );
- }
-
this->sdl_screen = NULL;
}
{
// Get the actual object
consumer_sdl this = parent->child;
+ int preview_off = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent ), "preview_off" );
+ int sdl_started = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent ), "sdl_started" );
// Stop the consumer
mlt_consumer_stop( parent );
// Now clean up the rest
mlt_consumer_close( parent );
+ if ( sdl_started == 0 && preview_off == 0 )
+ {
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ SDL_Quit( );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ }
+
// Finally clean up this
free( this );
}