]> git.sesse.net Git - mlt/blobdiff - src/modules/sdl/consumer_sdl_audio.c
Initial port to Windows using MinGW.
[mlt] / src / modules / sdl / consumer_sdl_audio.c
index 207ec8431da5aa7b7fe0069a40eb83866e009bff..f15bbf2106efc5140c5ba4311a30ed8e5aabdfea 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * 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 <stdlib.h>
 #include <string.h>
 #include <pthread.h>
-#include <SDL/SDL.h>
+#include <SDL.h>
 #include <sys/time.h>
 
+extern pthread_mutex_t mlt_sdl_mutex;
+
 /** This classes definition.
 */
 
@@ -103,6 +105,7 @@ mlt_consumer consumer_sdl_audio_init( mlt_profile profile, mlt_service_type type
 
                // Default scaler (for now we'll use nearest)
                mlt_properties_set( this->properties, "rescale", "nearest" );
+               mlt_properties_set( this->properties, "deinterlace_method", "onefield" );
 
                // Default buffer for low latency
                mlt_properties_set_int( this->properties, "buffer", 1 );
@@ -140,7 +143,7 @@ static void consumer_refresh_cb( mlt_consumer sdl, mlt_consumer parent, char *na
        {
                consumer_sdl this = parent->child;
                pthread_mutex_lock( &this->refresh_mutex );
-               this->refresh_count = this->refresh_count <= 0 ? 1 : this->refresh_count ++;
+               this->refresh_count = this->refresh_count <= 0 ? 1 : this->refresh_count + 1;
                pthread_cond_broadcast( &this->refresh_cond );
                pthread_mutex_unlock( &this->refresh_mutex );
        }
@@ -157,7 +160,11 @@ int consumer_start( mlt_consumer parent )
                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;
@@ -186,7 +193,9 @@ int consumer_stop( mlt_consumer parent )
                pthread_mutex_unlock( &this->refresh_mutex );
 
                // Cleanup the main thread
+#ifndef WIN32
                if ( this->thread )
+#endif
                        pthread_join( this->thread, NULL );
 
                // Unlatch the audio callback
@@ -522,9 +531,12 @@ static void *consumer_thread( void *arg )
                                        consumer_play_video( this, frame );
                                        pthread_cond_wait( &this->refresh_cond, &this->refresh_mutex );
                                }
+                               mlt_frame_close( frame );
                                this->refresh_count --;
                                pthread_mutex_unlock( &this->refresh_mutex );
                        }
+                       else
+                               mlt_frame_close( frame );
 
                        // Optimisation to reduce latency
                        if ( speed == 1.0 )