2 * consumer_sdl.c -- A Simple DirectMedia Layer consumer
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Dan Dennedy <dan@dennedy.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "consumer_sdl.h"
22 #include <framework/mlt_frame.h>
23 #include <framework/mlt_deque.h>
24 #include <framework/mlt_factory.h>
25 #include <framework/mlt_filter.h>
31 #include <SDL/SDL_syswm.h>
34 /** This classes definition.
37 typedef struct consumer_sdl_s
*consumer_sdl
;
41 struct mlt_consumer_s parent
;
42 mlt_properties properties
;
47 uint8_t audio_buffer
[ 4096 * 10 ];
49 pthread_mutex_t audio_mutex
;
50 pthread_cond_t audio_cond
;
51 pthread_mutex_t video_mutex
;
52 pthread_cond_t video_cond
;
61 SDL_Surface
*sdl_screen
;
62 SDL_Overlay
*sdl_overlay
;
69 /** Forward references to static functions.
72 static int consumer_start( mlt_consumer parent
);
73 static int consumer_stop( mlt_consumer parent
);
74 static int consumer_is_stopped( mlt_consumer parent
);
75 static void consumer_close( mlt_consumer parent
);
76 static void *consumer_thread( void * );
77 static int consumer_get_dimensions( int *width
, int *height
);
78 static void consumer_sdl_event( mlt_listener listener
, mlt_properties owner
, mlt_service
this, void **args
);
80 /** This is what will be called by the factory - anything can be passed in
81 via the argument, but keep it simple.
84 mlt_consumer
consumer_sdl_init( char *arg
)
86 // Create the consumer object
87 consumer_sdl
this = calloc( sizeof( struct consumer_sdl_s
), 1 );
89 // If no malloc'd and consumer init ok
90 if ( this != NULL
&& mlt_consumer_init( &this->parent
, this ) == 0 )
93 this->queue
= mlt_deque_init( );
95 // Get the parent consumer object
96 mlt_consumer parent
= &this->parent
;
98 // We have stuff to clean up, so override the close method
99 parent
->close
= consumer_close
;
101 // get a handle on properties
102 mlt_service service
= MLT_CONSUMER_SERVICE( parent
);
103 this->properties
= MLT_SERVICE_PROPERTIES( service
);
105 // Set the default volume
106 mlt_properties_set_double( this->properties
, "volume", 1.0 );
108 // This is the initialisation of the consumer
109 pthread_mutex_init( &this->audio_mutex
, NULL
);
110 pthread_cond_init( &this->audio_cond
, NULL
);
111 pthread_mutex_init( &this->video_mutex
, NULL
);
112 pthread_cond_init( &this->video_cond
, NULL
);
114 // Default scaler (for now we'll use nearest)
115 mlt_properties_set( this->properties
, "rescale", "nearest" );
117 // Default buffer for low latency
118 mlt_properties_set_int( this->properties
, "buffer", 1 );
120 // Default progressive true
121 mlt_properties_set_int( this->properties
, "progressive", 0 );
123 // Default audio buffer
124 mlt_properties_set_int( this->properties
, "audio_buffer", 512 );
126 // Ensure we don't join on a non-running object
129 // process actual param
130 if ( arg
== NULL
|| sscanf( arg
, "%dx%d", &this->width
, &this->height
) != 2 )
132 this->width
= mlt_properties_get_int( this->properties
, "width" );
133 this->height
= mlt_properties_get_int( this->properties
, "height" );
137 this->sdl_flags
= SDL_HWSURFACE
| SDL_ASYNCBLIT
| SDL_HWACCEL
| SDL_RESIZABLE
| SDL_DOUBLEBUF
;
139 // Allow thread to be started/stopped
140 parent
->start
= consumer_start
;
141 parent
->stop
= consumer_stop
;
142 parent
->is_stopped
= consumer_is_stopped
;
144 // Register specific events
145 mlt_events_register( this->properties
, "consumer-sdl-event", ( mlt_transmitter
)consumer_sdl_event
);
147 // Return the consumer produced
151 // malloc or consumer init failed
158 static void consumer_sdl_event( mlt_listener listener
, mlt_properties owner
, mlt_service
this, void **args
)
160 if ( listener
!= NULL
)
161 listener( owner
, this, ( SDL_Event
* )args
[ 0 ] );
164 int consumer_start( mlt_consumer parent
)
166 consumer_sdl
this = parent
->child
;
168 if ( !this->running
)
170 int video_off
= mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent
), "video_off" );
171 int preview_off
= mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent
), "preview_off" );
172 int display_off
= video_off
| preview_off
;
173 int audio_off
= mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent
), "audio_off" );
174 int sdl_started
= mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent
), "sdl_started" );
176 consumer_stop( parent
);
181 this->width
= mlt_properties_get_int( this->properties
, "width" );
182 this->height
= mlt_properties_get_int( this->properties
, "height" );
184 this->bpp
= mlt_properties_get_int( this->properties
, "bpp" );
186 // Attach a colour space converter
187 if ( preview_off
&& !this->filtered
)
189 mlt_filter filter
= mlt_factory_filter( "avcolour_space", NULL
);
190 mlt_properties_set_int( MLT_FILTER_PROPERTIES( filter
), "forced", mlt_image_yuv422
);
191 mlt_service_attach( MLT_CONSUMER_SERVICE( parent
), filter
);
192 mlt_filter_close( filter
);
196 if ( sdl_started
== 0 && display_off
== 0 )
198 if ( SDL_Init( SDL_INIT_VIDEO
| SDL_INIT_NOPARACHUTE
) < 0 )
200 fprintf( stderr
, "Failed to initialize SDL: %s\n", SDL_GetError() );
204 SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY
, SDL_DEFAULT_REPEAT_INTERVAL
);
205 SDL_EnableUNICODE( 1 );
207 else if ( display_off
== 0 )
209 this->sdl_screen
= SDL_GetVideoSurface( );
212 if ( audio_off
== 0 )
213 SDL_InitSubSystem( SDL_INIT_AUDIO
);
215 // Default window size
216 double display_ratio
= mlt_properties_get_double( this->properties
, "display_ratio" );
217 this->window_width
= ( double )this->height
* display_ratio
;
218 this->window_height
= this->height
;
220 if ( this->sdl_screen
== NULL
&& display_off
== 0 )
221 this->sdl_screen
= SDL_SetVideoMode( this->window_width
, this->window_height
, 0, this->sdl_flags
);
223 pthread_create( &this->thread
, NULL
, consumer_thread
, this );
229 int consumer_stop( mlt_consumer parent
)
231 // Get the actual object
232 consumer_sdl
this = parent
->child
;
234 if ( this->joined
== 0 )
236 // Kill the thread and clean up
239 pthread_join( this->thread
, NULL
);
242 if ( this->sdl_overlay
!= NULL
)
243 SDL_FreeYUVOverlay( this->sdl_overlay
);
244 this->sdl_overlay
= NULL
;
246 if ( !mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent
), "audio_off" ) )
248 pthread_mutex_lock( &this->audio_mutex
);
249 pthread_cond_broadcast( &this->audio_cond
);
250 pthread_mutex_unlock( &this->audio_mutex
);
251 SDL_QuitSubSystem( SDL_INIT_AUDIO
);
254 if ( mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( parent
), "sdl_started" ) == 0 )
257 this->sdl_screen
= NULL
;
263 int consumer_is_stopped( mlt_consumer parent
)
265 consumer_sdl
this = parent
->child
;
266 return !this->running
;
269 static int sdl_lock_display( )
271 SDL_Surface
*screen
= SDL_GetVideoSurface( );
272 return screen
!= NULL
&& ( !SDL_MUSTLOCK( screen
) || SDL_LockSurface( screen
) >= 0 );
275 static void sdl_unlock_display( )
277 SDL_Surface
*screen
= SDL_GetVideoSurface( );
278 if ( screen
!= NULL
&& SDL_MUSTLOCK( screen
) )
279 SDL_UnlockSurface( screen
);
282 static void sdl_fill_audio( void *udata
, uint8_t *stream
, int len
)
284 consumer_sdl
this = udata
;
287 double volume
= mlt_properties_get_double( this->properties
, "volume" );
289 pthread_mutex_lock( &this->audio_mutex
);
291 // Block until audio received
292 while ( this->running
&& len
> this->audio_avail
)
293 pthread_cond_wait( &this->audio_cond
, &this->audio_mutex
);
295 if ( this->audio_avail
>= len
)
297 // Place in the audio buffer
299 SDL_MixAudio( stream
, this->audio_buffer
, len
, ( int )( ( float )SDL_MIX_MAXVOLUME
* volume
) );
301 memcpy( stream
, this->audio_buffer
, len
);
303 // Remove len from the audio available
304 this->audio_avail
-= len
;
306 // Remove the samples
307 memmove( this->audio_buffer
, this->audio_buffer
+ len
, this->audio_avail
);
311 // Just to be safe, wipe the stream first
312 memset( stream
, 0, len
);
315 SDL_MixAudio( stream
, this->audio_buffer
, len
, ( int )( ( float )SDL_MIX_MAXVOLUME
* volume
) );
318 this->audio_avail
= 0;
321 // We're definitely playing now
324 pthread_cond_broadcast( &this->audio_cond
);
325 pthread_mutex_unlock( &this->audio_mutex
);
328 static int consumer_play_audio( consumer_sdl
this, mlt_frame frame
, int init_audio
, int *duration
)
330 // Get the properties of this consumer
331 mlt_properties properties
= this->properties
;
332 mlt_audio_format afmt
= mlt_audio_pcm
;
334 // Set the preferred params of the test card signal
335 int channels
= mlt_properties_get_int( properties
, "channels" );
336 int frequency
= mlt_properties_get_int( properties
, "frequency" );
337 static int counter
= 0;
339 int samples
= mlt_sample_calculator( mlt_properties_get_double( this->properties
, "fps" ), frequency
, counter
++ );
344 mlt_frame_get_audio( frame
, &pcm
, &afmt
, &frequency
, &channels
, &samples
);
345 *duration
= ( ( samples
* 1000 ) / frequency
);
347 if ( mlt_properties_get_int( properties
, "audio_off" ) )
354 if ( init_audio
== 1 )
356 SDL_AudioSpec request
;
359 int audio_buffer
= mlt_properties_get_int( properties
, "audio_buffer" );
361 // specify audio format
362 memset( &request
, 0, sizeof( SDL_AudioSpec
) );
364 request
.freq
= frequency
;
365 request
.format
= AUDIO_S16SYS
;
366 request
.channels
= channels
;
367 request
.samples
= audio_buffer
;
368 request
.callback
= sdl_fill_audio
;
369 request
.userdata
= (void *)this;
370 if ( SDL_OpenAudio( &request
, &got
) != 0 )
372 fprintf( stderr
, "SDL failed to open audio: %s\n", SDL_GetError() );
375 else if ( got
.size
!= 0 )
382 if ( init_audio
== 0 )
384 mlt_properties properties
= MLT_FRAME_PROPERTIES( frame
);
385 bytes
= ( samples
* channels
* 2 );
386 pthread_mutex_lock( &this->audio_mutex
);
387 while ( this->running
&& bytes
> ( sizeof( this->audio_buffer
) - this->audio_avail
) )
388 pthread_cond_wait( &this->audio_cond
, &this->audio_mutex
);
391 if ( mlt_properties_get_double( properties
, "_speed" ) == 1 )
392 memcpy( &this->audio_buffer
[ this->audio_avail
], pcm
, bytes
);
394 memset( &this->audio_buffer
[ this->audio_avail
], 0, bytes
);
395 this->audio_avail
+= bytes
;
397 pthread_cond_broadcast( &this->audio_cond
);
398 pthread_mutex_unlock( &this->audio_mutex
);
408 static int consumer_play_video( consumer_sdl
this, mlt_frame frame
)
410 // Get the properties of this consumer
411 mlt_properties properties
= this->properties
;
413 mlt_image_format vfmt
= mlt_image_yuv422
;
414 int width
= this->width
, height
= this->height
;
418 int video_off
= mlt_properties_get_int( properties
, "video_off" );
419 int preview_off
= mlt_properties_get_int( properties
, "preview_off" );
420 mlt_image_format preview_format
= mlt_properties_get_int( properties
, "preview_format" );
421 int display_off
= video_off
| preview_off
;
423 if ( this->running
&& display_off
== 0 )
425 // Get the image, width and height
426 mlt_frame_get_image( frame
, &image
, &vfmt
, &width
, &height
, 0 );
427 mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame
), "format", vfmt
);
428 mlt_events_fire( properties
, "consumer-frame-show", frame
, NULL
);
431 if ( this->sdl_screen
!= NULL
)
436 changed
= consumer_get_dimensions( &this->window_width
, &this->window_height
);
437 sdl_unlock_display( );
439 while ( SDL_PollEvent( &event
) )
441 mlt_events_fire( this->properties
, "consumer-sdl-event", &event
, NULL
);
445 case SDL_VIDEORESIZE
:
446 this->window_width
= event
.resize
.w
;
447 this->window_height
= event
.resize
.h
;
455 mlt_producer producer
= mlt_properties_get_data( properties
, "transport_producer", NULL
);
456 char keyboard
[ 2 ] = " ";
457 void (*callback
)( mlt_producer
, char * ) = mlt_properties_get_data( properties
, "transport_callback", NULL
);
458 if ( callback
!= NULL
&& producer
!= NULL
&& event
.key
.keysym
.unicode
< 0x80 && event
.key
.keysym
.unicode
> 0 )
460 keyboard
[ 0 ] = ( char )event
.key
.keysym
.unicode
;
461 callback( producer
, keyboard
);
471 if ( width
!= this->width
|| height
!= this->height
)
473 if ( this->sdl_overlay
!= NULL
)
474 SDL_FreeYUVOverlay( this->sdl_overlay
);
475 this->sdl_overlay
= NULL
;
478 if ( this->running
&& ( this->sdl_screen
== NULL
|| changed
) )
480 // Force an overlay recreation
481 if ( this->sdl_overlay
!= NULL
)
482 SDL_FreeYUVOverlay( this->sdl_overlay
);
483 this->sdl_overlay
= NULL
;
485 // open SDL window with video overlay, if possible
486 this->sdl_screen
= SDL_SetVideoMode( this->window_width
, this->window_height
, this->bpp
, this->sdl_flags
);
487 if ( consumer_get_dimensions( &this->window_width
, &this->window_height
) )
488 this->sdl_screen
= SDL_SetVideoMode( this->window_width
, this->window_height
, this->bpp
, this->sdl_flags
);
493 // Determine window's new display aspect ratio
494 double this_aspect
= ( double )this->window_width
/ this->window_height
;
496 // Get the display aspect ratio
497 double display_ratio
= mlt_properties_get_double( properties
, "display_ratio" );
499 // Determine frame's display aspect ratio
500 double frame_aspect
= mlt_frame_get_aspect_ratio( frame
) * width
/ height
;
502 // Store the width and height received
504 this->height
= height
;
506 // If using hardware scaler
507 if ( mlt_properties_get( properties
, "rescale" ) != NULL
&&
508 !strcmp( mlt_properties_get( properties
, "rescale" ), "none" ) )
510 // Use hardware scaler to normalise display aspect ratio
511 this->rect
.w
= frame_aspect
/ this_aspect
* this->window_width
;
512 this->rect
.h
= this->window_height
;
513 if ( this->rect
.w
> this->window_width
)
515 this->rect
.w
= this->window_width
;
516 this->rect
.h
= this_aspect
/ frame_aspect
* this->window_height
;
519 // Special case optimisation to negate odd effect of sample aspect ratio
520 // not corresponding exactly with image resolution.
521 else if ( (int)( this_aspect
* 1000 ) == (int)( display_ratio
* 1000 ) )
523 this->rect
.w
= this->window_width
;
524 this->rect
.h
= this->window_height
;
526 // Use hardware scaler to normalise sample aspect ratio
527 else if ( this->window_height
* display_ratio
> this->window_width
)
529 this->rect
.w
= this->window_width
;
530 this->rect
.h
= this->window_width
/ display_ratio
;
534 this->rect
.w
= this->window_height
* display_ratio
;
535 this->rect
.h
= this->window_height
;
538 this->rect
.x
= ( this->window_width
- this->rect
.w
) / 2;
539 this->rect
.y
= ( this->window_height
- this->rect
.h
) / 2;
540 this->rect
.x
-= this->rect
.x
% 2;
542 mlt_properties_set_int( this->properties
, "rect_x", this->rect
.x
);
543 mlt_properties_set_int( this->properties
, "rect_y", this->rect
.y
);
544 mlt_properties_set_int( this->properties
, "rect_w", this->rect
.w
);
545 mlt_properties_set_int( this->properties
, "rect_h", this->rect
.h
);
547 SDL_SetClipRect( this->sdl_screen
, &this->rect
);
550 if ( this->running
&& this->sdl_screen
!= NULL
&& this->sdl_overlay
== NULL
)
552 SDL_SetClipRect( this->sdl_screen
, &this->rect
);
553 this->sdl_overlay
= SDL_CreateYUVOverlay( width
, height
, SDL_YUY2_OVERLAY
, this->sdl_screen
);
556 if ( this->running
&& this->sdl_screen
!= NULL
&& this->sdl_overlay
!= NULL
)
558 this->buffer
= this->sdl_overlay
->pixels
[ 0 ];
559 if ( SDL_LockYUVOverlay( this->sdl_overlay
) >= 0 )
562 memcpy( this->buffer
, image
, width
* height
* 2 );
563 SDL_UnlockYUVOverlay( this->sdl_overlay
);
564 SDL_DisplayYUVOverlay( this->sdl_overlay
, &this->sdl_screen
->clip_rect
);
568 sdl_unlock_display();
570 else if ( this->running
)
572 vfmt
= preview_format
== mlt_image_none ? mlt_image_rgb24a
: preview_format
;
574 mlt_frame_get_image( frame
, &image
, &vfmt
, &width
, &height
, 0 );
575 mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame
), "format", vfmt
);
576 mlt_events_fire( properties
, "consumer-frame-show", frame
, NULL
);
582 static void *video_thread( void *arg
)
585 consumer_sdl
this = arg
;
587 // Obtain time of thread start
592 mlt_frame next
= NULL
;
593 mlt_properties properties
= NULL
;
596 // Get real time flag
597 int real_time
= mlt_properties_get_int( this->properties
, "real_time" );
599 // Get the current time
600 gettimeofday( &now
, NULL
);
602 // Determine start time
603 start
= ( int64_t )now
.tv_sec
* 1000000 + now
.tv_usec
;
605 while ( this->running
)
607 // Pop the next frame
608 pthread_mutex_lock( &this->video_mutex
);
609 next
= mlt_deque_pop_front( this->queue
);
610 while ( next
== NULL
&& this->running
)
612 pthread_cond_wait( &this->video_cond
, &this->video_mutex
);
613 next
= mlt_deque_pop_front( this->queue
);
615 pthread_mutex_unlock( &this->video_mutex
);
617 if ( !this->running
|| next
== NULL
) break;
619 // Get the properties
620 properties
= MLT_FRAME_PROPERTIES( next
);
622 // Get the speed of the frame
623 speed
= mlt_properties_get_double( properties
, "_speed" );
625 // Get the current time
626 gettimeofday( &now
, NULL
);
628 // Get the elapsed time
629 elapsed
= ( ( int64_t )now
.tv_sec
* 1000000 + now
.tv_usec
) - start
;
631 // See if we have to delay the display of the current frame
632 if ( mlt_properties_get_int( properties
, "rendered" ) == 1 && this->running
)
634 // Obtain the scheduled playout time
635 int64_t scheduled
= mlt_properties_get_int( properties
, "playtime" );
637 // Determine the difference between the elapsed time and the scheduled playout time
638 int64_t difference
= scheduled
- elapsed
;
640 // Smooth playback a bit
641 if ( real_time
&& ( difference
> 20000 && speed
== 1.0 ) )
643 tm
.tv_sec
= difference
/ 1000000;
644 tm
.tv_nsec
= ( difference
% 1000000 ) * 500;
645 nanosleep( &tm
, NULL
);
648 // Show current frame if not too old
649 if ( !real_time
|| ( difference
> -10000 || speed
!= 1.0 || mlt_deque_count( this->queue
) < 2 ) )
650 consumer_play_video( this, next
);
652 // If the queue is empty, recalculate start to allow build up again
653 if ( real_time
&& ( mlt_deque_count( this->queue
) == 0 && speed
== 1.0 ) )
655 gettimeofday( &now
, NULL
);
656 start
= ( ( int64_t )now
.tv_sec
* 1000000 + now
.tv_usec
) - scheduled
+ 20000;
660 // This frame can now be closed
661 mlt_frame_close( next
);
666 mlt_frame_close( next
);
668 mlt_consumer_stopped( &this->parent
);
673 /** Threaded wrapper for pipe.
676 static void *consumer_thread( void *arg
)
679 consumer_sdl
this = arg
;
682 mlt_consumer consumer
= &this->parent
;
684 // Convenience functionality
685 int terminate_on_pause
= mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer
), "terminate_on_pause" );
691 // internal intialization
694 mlt_frame frame
= NULL
;
695 mlt_properties properties
= NULL
;
697 int64_t playtime
= 0;
698 struct timespec tm
= { 0, 100000 };
700 // Loop until told not to
701 while( !terminated
&& this->running
)
703 // Get a frame from the attached producer
704 frame
= mlt_consumer_rt_frame( consumer
);
706 // Check for termination
707 if ( terminate_on_pause
&& frame
!= NULL
)
708 terminated
= mlt_properties_get_double( MLT_FRAME_PROPERTIES( frame
), "_speed" ) == 0.0;
710 // Ensure that we have a frame
713 // Get the frame properties
714 properties
= MLT_FRAME_PROPERTIES( frame
);
717 init_audio
= consumer_play_audio( this, frame
, init_audio
, &duration
);
719 // Determine the start time now
720 if ( this->playing
&& init_video
)
722 // Create the video thread
723 pthread_create( &thread
, NULL
, video_thread
, this );
725 // Video doesn't need to be initialised any more
729 // Set playtime for this frame
730 mlt_properties_set_int( properties
, "playtime", playtime
);
732 while ( this->running
&& mlt_deque_count( this->queue
) > 15 )
733 nanosleep( &tm
, NULL
);
735 // Push this frame to the back of the queue
736 pthread_mutex_lock( &this->video_mutex
);
737 mlt_deque_push_back( this->queue
, frame
);
738 pthread_cond_broadcast( &this->video_cond
);
739 pthread_mutex_unlock( &this->video_mutex
);
741 // Calculate the next playtime
742 playtime
+= ( duration
* 1000 );
748 // Kill the video thread
749 if ( init_video
== 0 )
751 pthread_mutex_lock( &this->video_mutex
);
752 pthread_cond_broadcast( &this->video_cond
);
753 pthread_mutex_unlock( &this->video_mutex
);
754 pthread_join( thread
, NULL
);
757 while( mlt_deque_count( this->queue
) )
758 mlt_frame_close( mlt_deque_pop_back( this->queue
) );
760 this->sdl_screen
= NULL
;
761 this->audio_avail
= 0;
766 static int consumer_get_dimensions( int *width
, int *height
)
770 // SDL windows manager structure
773 // Specify the SDL Version
774 SDL_VERSION( &wm
.version
);
777 //sdl_lock_display();
780 // Get the wm structure
781 if ( SDL_GetWMInfo( &wm
) == 1 )
783 // Check that we have the X11 wm
784 if ( wm
.subsystem
== SDL_SYSWM_X11
)
786 // Get the SDL window
787 Window window
= wm
.info
.x11
.window
;
789 // Get the display session
790 Display
*display
= wm
.info
.x11
.display
;
792 // Get the window attributes
793 XWindowAttributes attr
;
794 XGetWindowAttributes( display
, window
, &attr
);
796 // Determine whether window has changed
797 changed
= *width
!= attr
.width
|| *height
!= attr
.height
;
799 // Return width and height
801 *height
= attr
.height
;
806 // Unlock the display
807 //sdl_unlock_display();
812 /** Callback to allow override of the close method.
815 static void consumer_close( mlt_consumer parent
)
817 // Get the actual object
818 consumer_sdl
this = parent
->child
;
821 ///mlt_consumer_stop( parent );
823 // Now clean up the rest
824 mlt_consumer_close( parent
);
827 mlt_deque_close( this->queue
);
830 pthread_mutex_destroy( &this->audio_mutex
);
831 pthread_cond_destroy( &this->audio_cond
);
833 // Finally clean up this