#include <framework/mlt_deque.h>
#include <framework/mlt_factory.h>
#include <framework/mlt_filter.h>
+#include <framework/mlt_log.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL_syswm.h>
#include <sys/time.h>
+extern pthread_mutex_t mlt_sdl_mutex;
+
/** This classes definition.
*/
uint8_t *buffer;
int last_position;
mlt_producer last_producer;
- int filtered;
};
/** Forward references to static functions.
// We're always going to run this in non-realtime mode
mlt_properties_set( this->properties, "real_time", "0" );
- // Default progressive true
- mlt_properties_set_int( this->properties, "progressive", 1 );
-
// Ensure we don't join on a non-running object
this->joined = 1;
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" );
- // Attach a colour space converter
- if ( !this->filtered )
- {
- mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( parent ) );
- mlt_filter filter = mlt_factory_filter( profile, "avcolour_space", NULL );
- mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter ), "forced", mlt_image_yuv422 );
- mlt_service_attach( MLT_CONSUMER_SERVICE( parent ), filter );
- mlt_filter_close( filter );
- this->filtered = 1;
- }
-
consumer_stop( parent );
this->last_position = -1;
}
if ( this->sdl_screen == NULL && preview_off == 0 )
+ {
+ pthread_mutex_lock( &mlt_sdl_mutex );
this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ }
pthread_create( &this->thread, NULL, consumer_thread, this );
}
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;
}
static int sdl_lock_display( )
{
+ pthread_mutex_lock( &mlt_sdl_mutex );
SDL_Surface *screen = SDL_GetVideoSurface( );
- return screen != NULL && ( !SDL_MUSTLOCK( screen ) || SDL_LockSurface( screen ) >= 0 );
+ int result = screen != NULL && ( !SDL_MUSTLOCK( screen ) || SDL_LockSurface( screen ) >= 0 );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ return result;
}
static void sdl_unlock_display( )
{
+ pthread_mutex_lock( &mlt_sdl_mutex );
SDL_Surface *screen = SDL_GetVideoSurface( );
if ( screen != NULL && SDL_MUSTLOCK( screen ) )
SDL_UnlockSurface( screen );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
}
static inline void display_1( SDL_Surface *screen, SDL_Rect rect, uint8_t *image, int width, int height )
{
SDL_Event event;
+ pthread_mutex_lock( &mlt_sdl_mutex );
changed = consumer_get_dimensions( &this->window_width, &this->window_height );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
while ( SDL_PollEvent( &event ) )
{
if ( this->sdl_screen == NULL || changed )
{
- // open SDL window
+ // open SDL window
+ pthread_mutex_lock( &mlt_sdl_mutex );
this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags );
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 );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+
uint32_t color = mlt_properties_get_int( this->properties, "window_background" );
SDL_FillRect( this->sdl_screen, NULL, color >> 8 );
changed = 1;
}
- else
- {
- changed = 1;
- }
if ( changed == 0 &&
this->last_position == mlt_frame_get_position( frame ) &&
- this->last_producer == mlt_properties_get_data( MLT_FRAME_PROPERTIES( frame ), "_producer", NULL ) )
+ this->last_producer == mlt_frame_get_original_producer( frame ) &&
+ !mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "refresh" ) )
{
sdl_unlock_display( );
if ( unlock != NULL ) unlock( );
+ struct timespec tm = { 0, 100000 };
+ nanosleep( &tm, NULL );
return 0;
}
// Update last frame shown info
this->last_position = mlt_frame_get_position( frame );
- this->last_producer = mlt_properties_get_data( MLT_FRAME_PROPERTIES( frame ), "_producer", NULL );
+ this->last_producer = mlt_frame_get_original_producer( frame );
// Get the image, width and height
mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
// Get the consumer
mlt_consumer consumer = &this->parent;
mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
-
- // internal intialization
mlt_frame frame = NULL;
- mlt_image_format vfmt = mlt_image_rgb24a;
- int height = this->height;
- int width = this->width;
- uint8_t *image = NULL;
// Allow the hosting app to provide the preview
int preview_off = mlt_properties_get_int( properties, "preview_off" );
- mlt_image_format preview_format = mlt_properties_get_int( properties, "preview_format" );
-
- // Check if a specific colour space has been requested
- if ( preview_off && preview_format != mlt_image_none )
- vfmt = preview_format;
// Loop until told not to
while( this->running )
}
else
{
+ mlt_image_format vfmt = mlt_image_rgb24a;
+ int height = this->height;
+ int width = this->width;
+ uint8_t *image = NULL;
+ mlt_image_format preview_format = mlt_properties_get_int( properties, "preview_format" );
+
+ // Check if a specific colour space has been requested
+ if ( preview_off && preview_format != mlt_image_none )
+ vfmt = preview_format;
+
mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 );
mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "format", vfmt );
mlt_events_fire( properties, "consumer-frame-show", frame, NULL );