]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_frame.c
service stack, various fixes
[mlt] / src / framework / mlt_frame.c
index 409d3687a862555dc9a852299044c336dbeca705..c0d75d666de754491645dd47a829bf68fc6ca1c8 100644 (file)
@@ -65,8 +65,12 @@ mlt_frame mlt_frame_init( )
                mlt_properties_set_data( properties, "audio", NULL, 0, NULL, NULL );
                mlt_properties_set_data( properties, "alpha", NULL, 0, NULL, NULL );
 
-
+               // Construct stacks for frames and methods
+               this->stack_get_image = mlt_deque_init( );
+               this->stack_frame = mlt_deque_init( );
+               this->stack_service = mlt_deque_init( );
        }
+
        return this;
 }
 
@@ -131,10 +135,7 @@ int mlt_frame_set_position( mlt_frame this, mlt_position value )
 
 int mlt_frame_push_get_image( mlt_frame this, mlt_get_image get_image )
 {
-       int ret = this->stack_get_image_size >= 10;
-       if ( ret == 0 )
-               this->stack_get_image[ this->stack_get_image_size ++ ] = get_image;
-       return ret;
+       return mlt_deque_push_back( this->stack_get_image, get_image );
 }
 
 /** Pop a get_image callback.
@@ -142,10 +143,7 @@ int mlt_frame_push_get_image( mlt_frame this, mlt_get_image get_image )
 
 mlt_get_image mlt_frame_pop_get_image( mlt_frame this )
 {
-       mlt_get_image result = NULL;
-       if ( this->stack_get_image_size > 0 )
-               result = this->stack_get_image[ -- this->stack_get_image_size ];
-       return result;
+       return mlt_deque_pop_back( this->stack_get_image );
 }
 
 /** Push a frame.
@@ -153,10 +151,7 @@ mlt_get_image mlt_frame_pop_get_image( mlt_frame this )
 
 int mlt_frame_push_frame( mlt_frame this, mlt_frame that )
 {
-       int ret = this->stack_frame_size >= 10;
-       if ( ret == 0 )
-               this->stack_frame[ this->stack_frame_size ++ ] = that;
-       return ret;
+       return mlt_deque_push_back( this->stack_frame, that );
 }
 
 /** Pop a frame.
@@ -164,10 +159,23 @@ int mlt_frame_push_frame( mlt_frame this, mlt_frame that )
 
 mlt_frame mlt_frame_pop_frame( mlt_frame this )
 {
-       mlt_frame result = NULL;
-       if ( this->stack_frame_size > 0 )
-               result = this->stack_frame[ -- this->stack_frame_size ];
-       return result;
+       return mlt_deque_pop_back( this->stack_frame );
+}
+
+/** Push a service.
+*/
+
+int mlt_frame_push_service( mlt_frame this, void *that )
+{
+       return mlt_deque_push_back( this->stack_service, that );
+}
+
+/** Pop a service.
+*/
+
+void *mlt_frame_pop_service( mlt_frame this )
+{
+       return mlt_deque_pop_back( this->stack_service );
 }
 
 int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
@@ -302,8 +310,14 @@ int mlt_frame_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *for
 
 void mlt_frame_close( mlt_frame this )
 {
-       mlt_properties_close( &this->parent );
-       free( this );
+       if ( this != NULL )
+       {
+               mlt_deque_close( this->stack_get_image );
+               mlt_deque_close( this->stack_frame );
+               mlt_deque_close( this->stack_service );
+               mlt_properties_close( &this->parent );
+               free( this );
+       }
 }
 
 /***** convenience functions *****/