X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fsdl%2Fconsumer_sdl.c;h=9870e448ea668199afa3c4684afbaf12cfc50e26;hb=f4963a6aa07644399b273b5d2b1f9299c9047414;hp=70e65d9cf3ca13204ce25c69ac68116b0e6c58fa;hpb=40b169c095486ba1b868486eb98a47c41f36ce8c;p=melted diff --git a/src/modules/sdl/consumer_sdl.c b/src/modules/sdl/consumer_sdl.c index 70e65d9..9870e44 100644 --- a/src/modules/sdl/consumer_sdl.c +++ b/src/modules/sdl/consumer_sdl.c @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "consumer_sdl.h" +#include #include #include #include @@ -81,13 +81,13 @@ static void consumer_sdl_event( mlt_listener listener, mlt_properties owner, mlt via the argument, but keep it simple. */ -mlt_consumer consumer_sdl_init( char *arg ) +mlt_consumer consumer_sdl_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg ) { // Create the consumer object consumer_sdl this = calloc( sizeof( struct consumer_sdl_s ), 1 ); // If no malloc'd and consumer init ok - if ( this != NULL && mlt_consumer_init( &this->parent, this ) == 0 ) + if ( this != NULL && mlt_consumer_init( &this->parent, this, profile ) == 0 ) { // Create the queue this->queue = mlt_deque_init( ); @@ -178,18 +178,24 @@ int consumer_start( mlt_consumer parent ) this->running = 1; this->joined = 0; - this->width = mlt_properties_get_int( this->properties, "width" ); - this->height = mlt_properties_get_int( this->properties, "height" ); + if ( mlt_properties_get_int( this->properties, "width" ) > 0 ) + this->width = mlt_properties_get_int( this->properties, "width" ); + if ( mlt_properties_get_int( this->properties, "height" ) > 0 ) + this->height = mlt_properties_get_int( this->properties, "height" ); this->bpp = mlt_properties_get_int( this->properties, "bpp" ); // Attach a colour space converter if ( preview_off && !this->filtered ) { - mlt_filter filter = mlt_factory_filter( "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 ); + mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( parent ) ); + mlt_filter filter = mlt_factory_filter( profile, "avcolour_space", NULL ); + if ( filter ) + { + 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; } @@ -218,7 +224,17 @@ int consumer_start( mlt_consumer parent ) this->window_height = this->height; if ( this->sdl_screen == NULL && display_off == 0 ) + { + if ( mlt_properties_get_int( this->properties, "fullscreen" ) ) + { + const SDL_VideoInfo *vi = SDL_GetVideoInfo(); + this->window_width = vi->current_w; + this->window_height = vi->current_h; + this->sdl_flags |= SDL_FULLSCREEN; + SDL_ShowCursor( SDL_DISABLE ); + } this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags ); + } pthread_create( &this->thread, NULL, consumer_thread, this ); } @@ -236,7 +252,8 @@ int consumer_stop( mlt_consumer parent ) // Kill the thread and clean up this->joined = 1; this->running = 0; - pthread_join( this->thread, NULL ); + if ( this->thread ) + pthread_join( this->thread, NULL ); // internal cleanup if ( this->sdl_overlay != NULL ) @@ -486,6 +503,10 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame ) this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, this->bpp, this->sdl_flags ); 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 ); + + uint32_t color = mlt_properties_get_int( this->properties, "window_background" ); + SDL_FillRect( this->sdl_screen, NULL, color >> 8 ); + SDL_Flip( this->sdl_screen ); } if ( this->running )