/*
* consumer_sdl.c -- A Simple DirectMedia Layer consumer
- * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Copyright (C) 2003-2004, 2010 Ushodaya Enterprises Limited
* Author: Dan Dennedy <dan@dennedy.org>
*
* This library is free software; you can redistribute it and/or
if ( sdl_started == 0 && display_off == 0 )
{
- if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0 )
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ int ret = SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ if ( ret < 0 )
{
mlt_log_error( MLT_CONSUMER_SERVICE(parent), "Failed to initialize SDL: %s\n", SDL_GetError() );
return -1;
}
else if ( display_off == 0 )
{
+ pthread_mutex_lock( &mlt_sdl_mutex );
this->sdl_screen = SDL_GetVideoSurface( );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
}
if ( audio_off == 0 )
{
if ( mlt_properties_get_int( this->properties, "fullscreen" ) )
{
- const SDL_VideoInfo *vi = SDL_GetVideoInfo();
+ const SDL_VideoInfo *vi;
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ vi = SDL_GetVideoInfo();
+ pthread_mutex_unlock( &mlt_sdl_mutex );
this->window_width = vi->current_w;
this->window_height = vi->current_h;
this->sdl_flags |= SDL_FULLSCREEN;
/*
* consumer_sdl_audio.c -- A Simple DirectMedia Layer audio-only consumer
- * Copyright (C) 2009 Ushodaya Enterprises Limited
+ * Copyright (C) 2009, 2010 Ushodaya Enterprises Limited
* Author: Dan Dennedy <dan@dennedy.org>
*
* This library is free software; you can redistribute it and/or
#include <SDL/SDL.h>
#include <sys/time.h>
+extern pthread_mutex_t mlt_sdl_mutex;
+
/** This classes definition.
*/
this->running = 1;
this->joined = 0;
- if ( SDL_Init( SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE ) < 0 )
+
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ int ret = SDL_Init( SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ if ( ret < 0 )
{
mlt_log_error( MLT_CONSUMER_SERVICE(parent), "Failed to initialize SDL: %s\n", SDL_GetError() );
return -1;
/*
* consumer_sdl_preview.c -- A Simple DirectMedia Layer consumer
- * Copyright (C) 2004-2005 Ushodaya Enterprises Limited
+ * Copyright (C) 2004-2005, 2010 Ushodaya Enterprises Limited
* Author: Charles Yates
*
* This library is free software; you can redistribute it and/or
if ( audio_device != NULL )
setenv( "AUDIODEV", audio_device, 1 );
- if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0 )
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ int ret = SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ if ( ret < 0 )
{
fprintf( stderr, "Failed to initialize SDL: %s\n", SDL_GetError() );
return -1;
/*
* consumer_sdl_still.c -- A Simple DirectMedia Layer consumer
- * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
+ * Copyright (C) 2003-2004, 2010 Ushodaya Enterprises Limited
* Author: Charles Yates
*
* This library is free software; you can redistribute it and/or
if ( sdl_started == 0 && preview_off == 0 )
{
- if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0 )
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ int ret = SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ if ( ret < 0 )
{
fprintf( stderr, "Failed to initialize SDL: %s\n", SDL_GetError() );
return -1;
}
else if ( preview_off == 0 )
{
- if ( SDL_GetVideoSurface( ) != NULL )
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ SDL_Surface *screen = SDL_GetVideoSurface( );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ if ( screen != NULL )
{
- this->sdl_screen = SDL_GetVideoSurface( );
+ this->sdl_screen = screen;
}
}
mlt_properties_set_int( this->properties, "rect_h", this->rect.h );
}
- if ( !mlt_consumer_is_stopped( &this->parent ) && SDL_GetVideoSurface( ) != NULL && this->sdl_screen != NULL && this->sdl_screen->pixels != NULL )
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ SDL_Surface *screen = SDL_GetVideoSurface( );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ if ( !mlt_consumer_is_stopped( &this->parent ) && screen != NULL && this->sdl_screen != NULL && this->sdl_screen->pixels != NULL )
{
switch( this->sdl_screen->format->BytesPerPixel )
{