2 * mlt_consumer.c -- abstraction for all consumer services
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Charles Yates <charles.yates@pandora.be>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include "mlt_consumer.h"
23 #include "mlt_factory.h"
24 #include "mlt_producer.h"
25 #include "mlt_frame.h"
31 static void mlt_consumer_frame_render( mlt_listener listener
, mlt_properties owner
, mlt_service
this, void **args
);
32 static void mlt_consumer_frame_show( mlt_listener listener
, mlt_properties owner
, mlt_service
this, void **args
);
34 /** Public final methods
37 int mlt_consumer_init( mlt_consumer
this, void *child
)
40 memset( this, 0, sizeof( struct mlt_consumer_s
) );
42 error
= mlt_service_init( &this->parent
, this );
45 // Get the properties from the service
46 mlt_properties properties
= MLT_SERVICE_PROPERTIES( &this->parent
);
48 // Get the normalisation preference
49 char *normalisation
= mlt_environment( "MLT_NORMALISATION" );
51 // Deal with normalisation
52 if ( normalisation
== NULL
|| strcmp( normalisation
, "NTSC" ) )
54 mlt_properties_set( properties
, "normalisation", "PAL" );
55 mlt_properties_set_double( properties
, "fps", 25.0 );
56 mlt_properties_set_int( properties
, "frame_rate_num", 25 );
57 mlt_properties_set_int( properties
, "frame_rate_den", 1 );
58 mlt_properties_set_int( properties
, "width", 720 );
59 mlt_properties_set_int( properties
, "height", 576 );
60 mlt_properties_set_int( properties
, "progressive", 0 );
61 mlt_properties_set_double( properties
, "aspect_ratio", 59.0 / 54.0 );
62 mlt_properties_set_int( properties
, "aspect_ratio_num", 59 );
63 mlt_properties_set_int( properties
, "aspect_ratio_den", 54 );
64 mlt_properties_set_double( properties
, "display_ratio", 4.0 / 3.0 );
65 mlt_properties_set_int( properties
, "display_ratio_num", 4 );
66 mlt_properties_set_int( properties
, "display_ratio_den", 3 );
70 mlt_properties_set( properties
, "normalisation", "NTSC" );
71 mlt_properties_set_double( properties
, "fps", 30000.0 / 1001.0 );
72 mlt_properties_set_int( properties
, "frame_rate_num", 30000 );
73 mlt_properties_set_int( properties
, "frame_rate_den", 1001 );
74 mlt_properties_set_int( properties
, "width", 720 );
75 mlt_properties_set_int( properties
, "height", 480 );
76 mlt_properties_set_int( properties
, "progressive", 0 );
77 mlt_properties_set_double( properties
, "aspect_ratio", 10.0 / 11.0 );
78 mlt_properties_set_int( properties
, "aspect_ratio_num", 10 );
79 mlt_properties_set_int( properties
, "aspect_ratio_den", 11 );
80 mlt_properties_set_double( properties
, "display_ratio", 4.0 / 3.0 );
81 mlt_properties_set_int( properties
, "display_ratio_num", 4 );
82 mlt_properties_set_int( properties
, "display_ratio_den", 3 );
85 // Default rescaler for all consumers
86 mlt_properties_set( properties
, "rescale", "bilinear" );
88 // Default read ahead buffer size
89 mlt_properties_set_int( properties
, "buffer", 25 );
91 // Default audio frequency and channels
92 mlt_properties_set_int( properties
, "frequency", 48000 );
93 mlt_properties_set_int( properties
, "channels", 2 );
95 // Default of all consumers is real time
96 mlt_properties_set_int( properties
, "real_time", 1 );
98 // Default to environment test card
99 mlt_properties_set( properties
, "test_card", mlt_environment( "MLT_TEST_CARD" ) );
101 // Hmm - default all consumers to yuv422 :-/
102 this->format
= mlt_image_yuv422
;
104 mlt_events_register( properties
, "consumer-frame-show", ( mlt_transmitter
)mlt_consumer_frame_show
);
105 mlt_events_register( properties
, "consumer-frame-render", ( mlt_transmitter
)mlt_consumer_frame_render
);
106 mlt_events_register( properties
, "consumer-stopped", NULL
);
108 // Create the push mutex and condition
109 pthread_mutex_init( &this->put_mutex
, NULL
);
110 pthread_cond_init( &this->put_cond
, NULL
);
116 static void mlt_consumer_frame_show( mlt_listener listener
, mlt_properties owner
, mlt_service
this, void **args
)
118 if ( listener
!= NULL
)
119 listener( owner
, this, ( mlt_frame
)args
[ 0 ] );
122 static void mlt_consumer_frame_render( mlt_listener listener
, mlt_properties owner
, mlt_service
this, void **args
)
124 if ( listener
!= NULL
)
125 listener( owner
, this, ( mlt_frame
)args
[ 0 ] );
128 /** Create a new consumer.
131 mlt_consumer
mlt_consumer_new( )
133 // Create the memory for the structure
134 mlt_consumer
this = malloc( sizeof( struct mlt_consumer_s
) );
138 mlt_consumer_init( this, NULL
);
144 /** Get the parent service object.
147 mlt_service
mlt_consumer_service( mlt_consumer
this )
149 return this != NULL ?
&this->parent
: NULL
;
152 /** Get the consumer properties.
155 mlt_properties
mlt_consumer_properties( mlt_consumer
this )
157 return this != NULL ?
MLT_SERVICE_PROPERTIES( &this->parent
) : NULL
;
160 /** Connect the consumer to the producer.
163 int mlt_consumer_connect( mlt_consumer
this, mlt_service producer
)
165 return mlt_service_connect_producer( &this->parent
, producer
, 0 );
168 /** Start the consumer.
171 int mlt_consumer_start( mlt_consumer
this )
174 mlt_properties properties
= MLT_CONSUMER_PROPERTIES( this );
176 // Determine if there's a test card producer
177 char *test_card
= mlt_properties_get( properties
, "test_card" );
180 char *profile
= mlt_properties_get( properties
, "profile" );
181 int profile_ok
= mlt_consumer_profile( properties
, profile
);
183 // Check that everything is OK
185 fprintf( stderr
, "Unrecognised profile %s - continuing with defaults.\n", mlt_properties_get( properties
, "profile" ) );
186 else if ( profile_ok
< 0 )
187 fprintf( stderr
, "Recognised profile %s with warnings - trying to continue with some defaults.\n", mlt_properties_get( properties
, "profile" ) );
189 // Just to make sure nothing is hanging around...
190 mlt_frame_close( this->put
);
192 this->put_active
= 1;
195 if ( test_card
!= NULL
)
197 if ( mlt_properties_get_data( properties
, "test_card_producer", NULL
) == NULL
)
199 // Create a test card producer
200 mlt_producer producer
= mlt_factory_producer( NULL
, test_card
);
202 // Do we have a producer
203 if ( producer
!= NULL
)
205 // Test card should loop I guess...
206 mlt_properties_set( MLT_PRODUCER_PROPERTIES( producer
), "eof", "loop" );
207 //mlt_producer_set_speed( producer, 0 );
208 //mlt_producer_set_in_and_out( producer, 0, 0 );
210 // Set the test card on the consumer
211 mlt_properties_set_data( properties
, "test_card_producer", producer
, 0, ( mlt_destructor
)mlt_producer_close
, NULL
);
217 // Allow the hash table to speed things up
218 mlt_properties_set_data( properties
, "test_card_producer", NULL
, 0, NULL
, NULL
);
221 // Check and run an ante command
222 if ( mlt_properties_get( properties
, "ante" ) )
223 system( mlt_properties_get( properties
, "ante" ) );
225 // Set the real_time preference
226 this->real_time
= mlt_properties_get_int( properties
, "real_time" );
229 if ( this->start
!= NULL
)
230 return this->start( this );
235 /** An alternative method to feed frames into the consumer - only valid if
236 the consumer itself is not connected.
239 int mlt_consumer_put_frame( mlt_consumer
this, mlt_frame frame
)
243 // Get the service assoicated to the consumer
244 mlt_service service
= MLT_CONSUMER_SERVICE( this );
246 if ( mlt_service_producer( service
) == NULL
)
250 pthread_mutex_lock( &this->put_mutex
);
251 while ( this->put_active
&& this->put
!= NULL
)
253 gettimeofday( &now
, NULL
);
254 tm
.tv_sec
= now
.tv_sec
+ 1;
255 tm
.tv_nsec
= now
.tv_usec
* 1000;
256 pthread_cond_timedwait( &this->put_cond
, &this->put_mutex
, &tm
);
258 if ( this->put_active
&& this->put
== NULL
)
261 mlt_frame_close( frame
);
262 pthread_cond_broadcast( &this->put_cond
);
263 pthread_mutex_unlock( &this->put_mutex
);
267 mlt_frame_close( frame
);
273 /** Protected method for consumer to get frames from connected service
276 mlt_frame
mlt_consumer_get_frame( mlt_consumer
this )
279 mlt_frame frame
= NULL
;
281 // Get the service assoicated to the consumer
282 mlt_service service
= MLT_CONSUMER_SERVICE( this );
284 // Get the consumer properties
285 mlt_properties properties
= MLT_CONSUMER_PROPERTIES( this );
288 if ( mlt_service_producer( service
) == NULL
&& mlt_properties_get_int( properties
, "put_mode" ) )
292 pthread_mutex_lock( &this->put_mutex
);
293 while ( this->put_active
&& this->put
== NULL
)
295 gettimeofday( &now
, NULL
);
296 tm
.tv_sec
= now
.tv_sec
+ 1;
297 tm
.tv_nsec
= now
.tv_usec
* 1000;
298 pthread_cond_timedwait( &this->put_cond
, &this->put_mutex
, &tm
);
302 pthread_cond_broadcast( &this->put_cond
);
303 pthread_mutex_unlock( &this->put_mutex
);
305 mlt_service_apply_filters( service
, frame
, 0 );
307 else if ( mlt_service_producer( service
) != NULL
)
309 mlt_service_get_frame( service
, &frame
, 0 );
313 frame
= mlt_frame_init( );
318 // Get the frame properties
319 mlt_properties frame_properties
= MLT_FRAME_PROPERTIES( frame
);
321 // Get the test card producer
322 mlt_producer test_card
= mlt_properties_get_data( properties
, "test_card_producer", NULL
);
324 // Attach the test frame producer to it.
325 if ( test_card
!= NULL
)
326 mlt_properties_set_data( frame_properties
, "test_card_producer", test_card
, 0, NULL
, NULL
);
328 // Attach the rescale property
329 mlt_properties_set( frame_properties
, "rescale.interp", mlt_properties_get( properties
, "rescale" ) );
331 // Aspect ratio and other jiggery pokery
332 mlt_properties_set_double( frame_properties
, "consumer_aspect_ratio", mlt_properties_get_double( properties
, "aspect_ratio" ) );
333 mlt_properties_set_int( frame_properties
, "consumer_deinterlace", mlt_properties_get_int( properties
, "progressive" ) | mlt_properties_get_int( properties
, "deinterlace" ) );
334 mlt_properties_set( frame_properties
, "deinterlace_method", mlt_properties_get( properties
, "deinterlace_method" ) );
341 static inline long time_difference( struct timeval
*time1
)
343 struct timeval time2
;
344 time2
.tv_sec
= time1
->tv_sec
;
345 time2
.tv_usec
= time1
->tv_usec
;
346 gettimeofday( time1
, NULL
);
347 return time1
->tv_sec
* 1000000 + time1
->tv_usec
- time2
.tv_sec
* 1000000 - time2
.tv_usec
;
350 int mlt_consumer_profile( mlt_properties properties
, char *profile
)
352 double fps
= mlt_properties_get_double( properties
, "fps" );
354 double display_num
= 0;
355 double display_den
= 0;
356 double pixel_num
= 0;
357 double pixel_den
= 0;
361 if ( fps
== 25.0 && profile
!= NULL
)
370 if ( !strcmp( profile
, "dv_wide" ) )
377 else if ( !strncmp( profile
, "square_wide", 11 ) )
386 else if ( !strncmp( profile
, "square", 6 ) )
393 else if ( !strncmp( profile
, "vcd", 3 ) )
398 else if ( !strncmp( profile
, "cvd", 3 ) )
405 else if ( !strncmp( profile
, "svcd_wide", 9 ) )
414 else if ( !strncmp( profile
, "svcd", 4 ) )
421 else if ( strncmp( profile
, "frame", 5 ) && strcmp( profile
, "dv" ) )
426 else if ( profile
!= NULL
)
435 if ( !strcmp( profile
, "dv_wide" ) )
442 else if ( !strncmp( profile
, "square_wide", 11 ) )
451 else if ( !strncmp( profile
, "square", 6 ) )
458 else if ( !strncmp( profile
, "vcd", 3 ) )
463 else if ( !strncmp( profile
, "cvd", 3 ) )
470 else if ( !strncmp( profile
, "svcd_wide", 9 ) )
479 else if ( !strncmp( profile
, "svcd", 4 ) )
486 else if ( strncmp( profile
, "frame", 5 ) && strcmp( profile
, "dv" ) )
492 // If width (or any of the above are 0), we use defaults otherwise we switch to recognised
493 if ( width
!= 0 && recognised
)
495 if ( recognised
&& strchr( profile
, ':' ) )
496 if ( sscanf( strchr( profile
, ':' ) + 1, "%dx%d", &width
, &height
) != 2 )
499 mlt_properties_set_int( properties
, "width", width
);
500 mlt_properties_set_int( properties
, "height", height
);
501 mlt_properties_set_double( properties
, "aspect_ratio", pixel_num
/ pixel_den
);
502 mlt_properties_set_int( properties
, "aspect_ratio_num", pixel_num
);
503 mlt_properties_set_int( properties
, "aspect_ratio_den", pixel_den
);
504 mlt_properties_set_double( properties
, "display_ratio", display_num
/ display_den
);
505 mlt_properties_set_int( properties
, "display_ratio_num", display_num
);
506 mlt_properties_set_int( properties
, "display_ratio_den", display_den
);
512 static void *consumer_read_ahead_thread( void *arg
)
514 // The argument is the consumer
515 mlt_consumer
this = arg
;
517 // Get the properties of the consumer
518 mlt_properties properties
= MLT_CONSUMER_PROPERTIES( this );
520 // Get the width and height
521 int width
= mlt_properties_get_int( properties
, "width" );
522 int height
= mlt_properties_get_int( properties
, "height" );
524 // See if video is turned off
525 int video_off
= mlt_properties_get_int( properties
, "video_off" );
527 // Get the audio settings
528 mlt_audio_format afmt
= mlt_audio_pcm
;
530 double fps
= mlt_properties_get_double( properties
, "fps" );
531 int channels
= mlt_properties_get_int( properties
, "channels" );
532 int frequency
= mlt_properties_get_int( properties
, "frequency" );
536 // See if audio is turned off
537 int audio_off
= mlt_properties_get_int( properties
, "audio_off" );
539 // Get the maximum size of the buffer
540 int buffer
= mlt_properties_get_int( properties
, "buffer" ) + 1;
542 // General frame variable
543 mlt_frame frame
= NULL
;
544 uint8_t *image
= NULL
;
549 // Average time for get_frame and get_image
552 int64_t time_wait
= 0;
553 int64_t time_frame
= 0;
554 int64_t time_process
= 0;
556 mlt_service lock_object
= NULL
;
558 // Get the first frame
559 frame
= mlt_consumer_get_frame( this );
561 // Get the lock object
562 lock_object
= mlt_properties_get_data( MLT_FRAME_PROPERTIES( frame
), "consumer_lock_service", NULL
);
565 if ( lock_object
) mlt_service_lock( lock_object
);
567 // Get the image of the first frame
570 mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-frame-render", frame
, NULL
);
571 mlt_frame_get_image( frame
, &image
, &this->format
, &width
, &height
, 0 );
576 samples
= mlt_sample_calculator( fps
, frequency
, counter
++ );
577 mlt_frame_get_audio( frame
, &pcm
, &afmt
, &frequency
, &channels
, &samples
);
580 // Unlock the lock object
581 if ( lock_object
) mlt_service_unlock( lock_object
);
584 mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame
), "rendered", 1 );
586 // Get the starting time (can ignore the times above)
587 gettimeofday( &ante
, NULL
);
589 // Continue to read ahead
590 while ( this->ahead
)
592 // Fetch width/height again
593 width
= mlt_properties_get_int( properties
, "width" );
594 height
= mlt_properties_get_int( properties
, "height" );
596 // Put the current frame into the queue
597 pthread_mutex_lock( &this->mutex
);
598 while( this->ahead
&& mlt_deque_count( this->queue
) >= buffer
)
599 pthread_cond_wait( &this->cond
, &this->mutex
);
600 mlt_deque_push_back( this->queue
, frame
);
601 pthread_cond_broadcast( &this->cond
);
602 pthread_mutex_unlock( &this->mutex
);
604 time_wait
+= time_difference( &ante
);
606 // Get the next frame
607 frame
= mlt_consumer_get_frame( this );
608 time_frame
+= time_difference( &ante
);
610 // If there's no frame, we're probably stopped...
614 // Attempt to fetch the lock object
615 lock_object
= mlt_properties_get_data( MLT_FRAME_PROPERTIES( frame
), "consumer_lock_service", NULL
);
617 // Increment the count
620 // Lock if there's a lock object
621 if ( lock_object
) mlt_service_lock( lock_object
);
623 // All non normal playback frames should be shown
624 if ( mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame
), "_speed" ) != 1 )
626 mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame
), "consumer_deinterlace", 1 );
638 // Get the image, mark as rendered and time it
641 mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-frame-render", frame
, NULL
);
642 mlt_frame_get_image( frame
, &image
, &this->format
, &width
, &height
, 0 );
644 mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame
), "rendered", 1 );
648 // Increment the number of sequentially skipped frames
652 // If we've reached an unacceptable level, reset everything
663 // Always process audio
666 samples
= mlt_sample_calculator( fps
, frequency
, counter
++ );
667 mlt_frame_get_audio( frame
, &pcm
, &afmt
, &frequency
, &channels
, &samples
);
670 // Increment the time take for this frame
671 time_process
+= time_difference( &ante
);
673 // Determine if the next frame should be skipped
674 if ( mlt_deque_count( this->queue
) <= 5 && ( ( time_wait
+ time_frame
+ time_process
) / count
) > 40000 )
677 // Unlock if there's a lock object
678 if ( lock_object
) mlt_service_unlock( lock_object
);
681 // Remove the last frame
682 mlt_frame_close( frame
);
687 static void consumer_read_ahead_start( mlt_consumer
this )
692 // Create the frame queue
693 this->queue
= mlt_deque_init( );
696 pthread_mutex_init( &this->mutex
, NULL
);
698 // Create the condition
699 pthread_cond_init( &this->cond
, NULL
);
701 // Create the read ahead
702 pthread_create( &this->ahead_thread
, NULL
, consumer_read_ahead_thread
, this );
705 static void consumer_read_ahead_stop( mlt_consumer
this )
707 // Make sure we're running
710 // Inform thread to stop
713 // Broadcast to the condition in case it's waiting
714 pthread_mutex_lock( &this->mutex
);
715 pthread_cond_broadcast( &this->cond
);
716 pthread_mutex_unlock( &this->mutex
);
718 // Broadcast to the put condition in case it's waiting
719 pthread_mutex_lock( &this->put_mutex
);
720 pthread_cond_broadcast( &this->put_cond
);
721 pthread_mutex_unlock( &this->put_mutex
);
724 pthread_join( this->ahead_thread
, NULL
);
727 pthread_mutex_destroy( &this->mutex
);
729 // Destroy the condition
730 pthread_cond_destroy( &this->cond
);
733 while ( mlt_deque_count( this->queue
) )
734 mlt_frame_close( mlt_deque_pop_back( this->queue
) );
737 mlt_deque_close( this->queue
);
741 void mlt_consumer_purge( mlt_consumer
this )
745 pthread_mutex_lock( &this->mutex
);
746 while ( mlt_deque_count( this->queue
) )
747 mlt_frame_close( mlt_deque_pop_back( this->queue
) );
748 pthread_cond_broadcast( &this->cond
);
749 pthread_mutex_unlock( &this->mutex
);
753 mlt_frame
mlt_consumer_rt_frame( mlt_consumer
this )
756 mlt_frame frame
= NULL
;
758 // Get the properties
759 mlt_properties properties
= MLT_CONSUMER_PROPERTIES( this );
761 // Check if the user has requested real time or not
762 if ( this->real_time
)
766 // Is the read ahead running?
767 if ( this->ahead
== 0 )
769 int buffer
= mlt_properties_get_int( properties
, "buffer" );
770 int prefill
= mlt_properties_get_int( properties
, "prefill" );
771 consumer_read_ahead_start( this );
773 size
= prefill
> 0 && prefill
< buffer ? prefill
: buffer
;
776 // Get frame from queue
777 pthread_mutex_lock( &this->mutex
);
778 while( this->ahead
&& mlt_deque_count( this->queue
) < size
)
779 pthread_cond_wait( &this->cond
, &this->mutex
);
780 frame
= mlt_deque_pop_front( this->queue
);
781 pthread_cond_broadcast( &this->cond
);
782 pthread_mutex_unlock( &this->mutex
);
786 // Get the frame in non real time
787 frame
= mlt_consumer_get_frame( this );
789 // This isn't true, but from the consumers perspective it is
791 mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame
), "rendered", 1 );
797 /** Callback for the implementation to indicate a stopped condition.
800 void mlt_consumer_stopped( mlt_consumer
this )
802 mlt_properties_set_int( MLT_CONSUMER_PROPERTIES( this ), "running", 0 );
803 mlt_events_fire( MLT_CONSUMER_PROPERTIES( this ), "consumer-stopped", NULL
);
806 /** Stop the consumer.
809 int mlt_consumer_stop( mlt_consumer
this )
812 mlt_properties properties
= MLT_CONSUMER_PROPERTIES( this );
813 char *debug
= mlt_properties_get( MLT_CONSUMER_PROPERTIES( this ), "debug" );
816 if ( debug
) fprintf( stderr
, "%s: stopping put waiting\n", debug
);
817 pthread_mutex_lock( &this->put_mutex
);
818 this->put_active
= 0;
819 pthread_cond_broadcast( &this->put_cond
);
820 pthread_mutex_unlock( &this->put_mutex
);
823 if ( debug
) fprintf( stderr
, "%s: stopping consumer\n", debug
);
824 if ( this->stop
!= NULL
)
827 // Check if the user has requested real time or not and stop if necessary
828 if ( debug
) fprintf( stderr
, "%s: stopping read_ahead\n", debug
);
829 if ( mlt_properties_get_int( properties
, "real_time" ) )
830 consumer_read_ahead_stop( this );
832 // Kill the test card
833 mlt_properties_set_data( properties
, "test_card_producer", NULL
, 0, NULL
, NULL
);
835 // Check and run a post command
836 if ( mlt_properties_get( properties
, "post" ) )
837 system( mlt_properties_get( properties
, "post" ) );
839 if ( debug
) fprintf( stderr
, "%s: stopped\n", debug
);
844 /** Determine if the consumer is stopped.
847 int mlt_consumer_is_stopped( mlt_consumer
this )
849 // Check if the consumer is stopped
850 if ( this->is_stopped
!= NULL
)
851 return this->is_stopped( this );
856 /** Close the consumer.
859 void mlt_consumer_close( mlt_consumer
this )
861 if ( this != NULL
&& mlt_properties_dec_ref( MLT_CONSUMER_PROPERTIES( this ) ) <= 0 )
863 // Get the childs close function
864 void ( *consumer_close
)( ) = this->close
;
866 if ( consumer_close
)
869 //mlt_consumer_stop( this );
872 consumer_close( this );
876 // Make sure it only gets called once
877 this->parent
.close
= NULL
;
879 // Destroy the push mutex and condition
880 pthread_mutex_destroy( &this->put_mutex
);
881 pthread_cond_destroy( &this->put_cond
);
883 mlt_service_close( &this->parent
);