added clear to the miracle command set and valerie api
[melted] / src / miracle / miracle_unit.c
1 /*
2 * miracle_unit.c -- DV Transmission Unit Implementation
3 * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
4 * Author: Dan Dennedy <dan@dennedy.org>
5 *
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.
10 *
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.
15 *
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.
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24
25 #include <stdio.h>
26 #include <unistd.h>
27 #include <sys/ioctl.h>
28 #include <sys/mman.h>
29 #include <sys/poll.h>
30 #include <sys/types.h>
31 #include <fcntl.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <errno.h>
35 #include <signal.h>
36 #include <limits.h>
37
38 #include <sys/mman.h>
39
40 #include "miracle_unit.h"
41 #include "miracle_log.h"
42 #include "miracle_local.h"
43
44 #include <framework/mlt.h>
45
46 /* Forward references */
47 static void miracle_unit_status_communicate( miracle_unit );
48
49 /** Allocate a new DV transmission unit.
50
51 \return A new miracle_unit handle.
52 */
53
54 miracle_unit miracle_unit_init( int index, char *constructor )
55 {
56 miracle_unit this = NULL;
57 mlt_consumer consumer = NULL;
58
59 char *id = strdup( constructor );
60 char *arg = strchr( id, ':' );
61
62 if ( arg != NULL )
63 *arg ++ = '\0';
64
65 consumer = mlt_factory_consumer( id, arg );
66
67 if ( consumer != NULL )
68 {
69 mlt_playlist playlist = mlt_playlist_init( );
70 this = calloc( sizeof( miracle_unit_t ), 1 );
71 this->properties = mlt_properties_new( );
72 this->producers = mlt_properties_new( );
73 mlt_properties_init( this->properties, this );
74 mlt_properties_set_int( this->properties, "unit", index );
75 mlt_properties_set_int( this->properties, "generation", 0 );
76 mlt_properties_set( this->properties, "constructor", constructor );
77 mlt_properties_set( this->properties, "id", id );
78 mlt_properties_set( this->properties, "arg", arg );
79 mlt_properties_set_data( this->properties, "consumer", consumer, 0, ( mlt_destructor )mlt_consumer_close, NULL );
80 mlt_properties_set_data( this->properties, "playlist", playlist, 0, ( mlt_destructor )mlt_playlist_close, NULL );
81 mlt_consumer_connect( consumer, mlt_playlist_service( playlist ) );
82 }
83
84 return this;
85 }
86
87 static char *strip_root( miracle_unit unit, char *file )
88 {
89 mlt_properties properties = unit->properties;
90 char *root = mlt_properties_get( properties, "root" );
91 if ( file != NULL && root != NULL )
92 {
93 int length = strlen( root );
94 if ( root[ length - 1 ] == '/' )
95 length --;
96 if ( !strncmp( file, root, length ) )
97 file += length;
98 }
99 return file;
100 }
101
102 /** Communicate the current status to all threads waiting on the notifier.
103 */
104
105 static void miracle_unit_status_communicate( miracle_unit unit )
106 {
107 if ( unit != NULL )
108 {
109 mlt_properties properties = unit->properties;
110 char *root_dir = mlt_properties_get( properties, "root" );
111 valerie_notifier notifier = mlt_properties_get_data( properties, "notifier", NULL );
112 valerie_status_t status;
113
114 if ( root_dir != NULL && notifier != NULL )
115 {
116 if ( miracle_unit_get_status( unit, &status ) == 0 )
117 /* if ( !( ( status.status == unit_playing || status.status == unit_paused ) &&
118 strcmp( status.clip, "" ) &&
119 !strcmp( status.tail_clip, "" ) &&
120 status.position == 0 &&
121 status.in == 0 &&
122 status.out == 0 ) ) */
123 valerie_notifier_put( notifier, &status );
124 }
125 }
126 }
127
128 /** Set the notifier info
129 */
130
131 void miracle_unit_set_notifier( miracle_unit this, valerie_notifier notifier, char *root_dir )
132 {
133 mlt_properties properties = this->properties;
134 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
135 mlt_properties playlist_properties = mlt_playlist_properties( playlist );
136
137 mlt_properties_set( properties, "root", root_dir );
138 mlt_properties_set_data( properties, "notifier", notifier, 0, NULL, NULL );
139 mlt_properties_set_data( playlist_properties, "notifier_arg", this, 0, NULL, NULL );
140 mlt_properties_set_data( playlist_properties, "notifier", miracle_unit_status_communicate, 0, NULL, NULL );
141
142 miracle_unit_status_communicate( this );
143 }
144
145 static mlt_producer create_producer( char *file )
146 {
147 return mlt_factory_producer( "fezzik", file );
148 }
149
150 /** Create or locate a producer for the file specified.
151 */
152
153 static mlt_producer locate_producer( miracle_unit unit, char *file )
154 {
155 // Get the unit properties
156 mlt_properties properties = unit->producers;
157
158 // Check if we already have loaded this file
159 mlt_producer result = mlt_properties_get_data( properties, file, NULL );
160
161 if ( result == NULL )
162 {
163 // Create the producer
164 result = create_producer( file );
165
166 // Now store the result
167 if ( result != NULL )
168 mlt_properties_set_data( properties, file, result, 0, ( mlt_destructor )mlt_producer_close, NULL );
169 }
170
171 return result;
172 }
173
174 /** Update the generation count.
175 */
176
177 static void update_generation( miracle_unit unit )
178 {
179 mlt_properties properties = unit->properties;
180 int generation = mlt_properties_get_int( properties, "generation" );
181 mlt_properties_set_int( properties, "generation", ++ generation );
182 }
183
184 /** Wipe all clips on the playlist for this unit.
185 */
186
187 static void clear_unit( miracle_unit unit )
188 {
189 mlt_properties properties = unit->properties;
190 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
191 mlt_producer producer = mlt_playlist_producer( playlist );
192
193 mlt_playlist_clear( playlist );
194 mlt_producer_seek( producer, 0 );
195
196 if ( unit->old_producers != NULL )
197 mlt_properties_close( unit->old_producers );
198 unit->old_producers = unit->producers;
199 unit->producers = mlt_properties_new( );
200
201 update_generation( unit );
202 }
203
204 /** Wipe all but the playing clip from the unit.
205 */
206
207 static void clean_unit( miracle_unit unit )
208 {
209 mlt_properties properties = unit->properties;
210 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
211 mlt_playlist_clip_info info;
212 int current = mlt_playlist_current_clip( playlist );
213 mlt_producer producer = mlt_playlist_producer( playlist );
214 mlt_position position = mlt_producer_frame( producer );
215 double speed = mlt_producer_get_speed( producer );
216 mlt_playlist_get_clip_info( playlist, &info, current );
217
218 if ( info.resource != NULL )
219 {
220 void *instance = mlt_properties_get_data( unit->producers, info.resource, NULL );
221 position -= info.start;
222 mlt_properties_set_data( unit->producers, info.resource, instance, 0, NULL, NULL );
223 clear_unit( unit );
224 mlt_playlist_append_io( playlist, instance, info.frame_in, info.frame_out );
225 mlt_properties_set_data( unit->producers, info.resource, instance, 0, ( mlt_destructor )mlt_producer_close, NULL );
226 mlt_producer_seek( producer, position );
227 mlt_producer_set_speed( producer, speed );
228 }
229
230 update_generation( unit );
231 }
232
233 /** Generate a report on all loaded clips.
234 */
235
236 void miracle_unit_report_list( miracle_unit unit, valerie_response response )
237 {
238 int i;
239 mlt_properties properties = unit->properties;
240 int generation = mlt_properties_get_int( properties, "generation" );
241 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
242
243 valerie_response_printf( response, 1024, "%d\n", generation );
244
245 for ( i = 0; i < mlt_playlist_count( playlist ); i ++ )
246 {
247 mlt_playlist_clip_info info;
248 mlt_playlist_get_clip_info( playlist , &info, i );
249 valerie_response_printf( response, 10240, "%d \"%s\" %d %d %d %d %.2f\n",
250 i,
251 strip_root( unit, info.resource ),
252 info.frame_in,
253 info.frame_out,
254 info.frame_count,
255 info.length,
256 info.fps );
257 }
258 valerie_response_printf( response, 1024, "\n" );
259 }
260
261 /** Load a clip into the unit clearing existing play list.
262
263 \todo error handling
264 \param unit A miracle_unit handle.
265 \param clip The absolute file name of the clip to load.
266 \param in The starting frame (-1 for 0)
267 \param out The ending frame (-1 for maximum)
268 */
269
270 valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int32_t in, int32_t out, int flush )
271 {
272 // Now try to create an producer
273 mlt_producer instance = create_producer( clip );
274
275 if ( instance != NULL )
276 {
277 clear_unit( unit );
278 mlt_properties properties = unit->properties;
279 mlt_properties_set_data( unit->producers, clip, instance, 0, ( mlt_destructor )mlt_producer_close, NULL );
280 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
281 mlt_playlist_append_io( playlist, instance, in, out );
282 miracle_log( LOG_DEBUG, "loaded clip %s", clip );
283 miracle_unit_status_communicate( unit );
284 return valerie_ok;
285 }
286
287 return valerie_invalid_file;
288 }
289
290 valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int32_t in, int32_t out )
291 {
292 mlt_producer instance = locate_producer( unit, clip );
293
294 if ( instance != NULL )
295 {
296 mlt_properties properties = unit->properties;
297 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
298 fprintf( stderr, "inserting clip %s before %d\n", clip, index );
299 mlt_playlist_insert( playlist, instance, index, in, out );
300 miracle_log( LOG_DEBUG, "inserted clip %s at %d", clip, index );
301 update_generation( unit );
302 miracle_unit_status_communicate( unit );
303 return valerie_ok;
304 }
305
306 return valerie_invalid_file;
307 }
308
309 valerie_error_code miracle_unit_remove( miracle_unit unit, int index )
310 {
311 mlt_properties properties = unit->properties;
312 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
313 mlt_playlist_remove( playlist, index );
314 miracle_log( LOG_DEBUG, "removed clip at %d", index );
315 update_generation( unit );
316 miracle_unit_status_communicate( unit );
317 return valerie_ok;
318 }
319
320 valerie_error_code miracle_unit_clean( miracle_unit unit )
321 {
322 clean_unit( unit );
323 miracle_log( LOG_DEBUG, "Cleaned playlist" );
324 miracle_unit_status_communicate( unit );
325 return valerie_ok;
326 }
327
328 valerie_error_code miracle_unit_clear( miracle_unit unit )
329 {
330 clear_unit( unit );
331 miracle_log( LOG_DEBUG, "Cleared playlist" );
332 miracle_unit_status_communicate( unit );
333 return valerie_ok;
334 }
335
336 valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest )
337 {
338 mlt_properties properties = unit->properties;
339 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
340 mlt_playlist_move( playlist, src, dest );
341 miracle_log( LOG_DEBUG, "moved clip %d to %d", src, dest );
342 update_generation( unit );
343 miracle_unit_status_communicate( unit );
344 return valerie_ok;
345 }
346
347 /** Add a clip to the unit play list.
348
349 \todo error handling
350 \param unit A miracle_unit handle.
351 \param clip The absolute file name of the clip to load.
352 \param in The starting frame (-1 for 0)
353 \param out The ending frame (-1 for maximum)
354 */
355
356 valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int32_t in, int32_t out )
357 {
358 mlt_producer instance = locate_producer( unit, clip );
359
360 if ( instance != NULL )
361 {
362 mlt_properties properties = unit->properties;
363 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
364 mlt_playlist_append_io( playlist, instance, in, out );
365 miracle_log( LOG_DEBUG, "appended clip %s", clip );
366 update_generation( unit );
367 miracle_unit_status_communicate( unit );
368 return valerie_ok;
369 }
370
371 return valerie_invalid_file;
372 }
373
374 /** Start playing the unit.
375
376 \todo error handling
377 \param unit A miracle_unit handle.
378 \param speed An integer that specifies the playback rate as a
379 percentage multiplied by 100.
380 */
381
382 void miracle_unit_play( miracle_unit_t *unit, int speed )
383 {
384 mlt_properties properties = unit->properties;
385 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
386 mlt_producer producer = mlt_playlist_producer( playlist );
387 mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL );
388 mlt_producer_set_speed( producer, ( double )speed / 1000 );
389 mlt_consumer_start( consumer );
390 miracle_unit_status_communicate( unit );
391 }
392
393 /** Stop playback.
394
395 Terminates the dv_pump and halts dv1394 transmission.
396
397 \param unit A miracle_unit handle.
398 */
399
400 void miracle_unit_terminate( miracle_unit unit )
401 {
402 mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL );
403 mlt_playlist playlist = mlt_properties_get_data( unit->properties, "playlist", NULL );
404 mlt_producer producer = mlt_playlist_producer( playlist );
405 mlt_producer_set_speed( producer, 0 );
406 mlt_consumer_stop( consumer );
407 miracle_unit_status_communicate( unit );
408 }
409
410 /** Query the status of unit playback.
411
412 \param unit A miracle_unit handle.
413 \return 1 if the unit is not playing, 0 if playing.
414 */
415
416 int miracle_unit_has_terminated( miracle_unit unit )
417 {
418 mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL );
419 return mlt_consumer_is_stopped( consumer );
420 }
421
422 /** Transfer the currently loaded clip to another unit
423 */
424
425 int miracle_unit_transfer( miracle_unit dest_unit, miracle_unit src_unit )
426 {
427 int i;
428 mlt_properties dest_properties = dest_unit->properties;
429 mlt_playlist dest_playlist = mlt_properties_get_data( dest_properties, "playlist", NULL );
430 mlt_properties src_properties = src_unit->properties;
431 mlt_playlist src_playlist = mlt_properties_get_data( src_properties, "playlist", NULL );
432
433 for ( i = 0; i < mlt_playlist_count( src_playlist ); i ++ )
434 {
435 mlt_playlist_clip_info info;
436 mlt_playlist_get_clip_info( src_playlist, &info, i );
437 mlt_producer producer = locate_producer( dest_unit, info.resource );
438 if ( producer != NULL )
439 {
440 mlt_playlist_append_io( dest_playlist, producer, info.frame_in, info.frame_out );
441 if ( i == 0 )
442 {
443 miracle_unit_change_position( dest_unit, mlt_playlist_count( dest_playlist ) - 1, 0 );
444 clean_unit( dest_unit );
445 }
446 }
447 }
448
449 return 0;
450 }
451
452 /** Determine if unit is offline.
453 */
454
455 int miracle_unit_is_offline( miracle_unit unit )
456 {
457 return 0;
458 }
459
460 /** Obtain the status for a given unit
461 */
462
463 int miracle_unit_get_status( miracle_unit unit, valerie_status status )
464 {
465 int error = unit == NULL;
466
467 memset( status, 0, sizeof( valerie_status_t ) );
468
469 if ( !error )
470 {
471 mlt_properties properties = unit->properties;
472 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
473 mlt_producer producer = mlt_playlist_producer( playlist );
474 mlt_producer clip = mlt_playlist_current( playlist );
475
476 mlt_playlist_clip_info info;
477 int clip_index = mlt_playlist_current_clip( playlist );
478 mlt_playlist_get_clip_info( playlist, &info, clip_index );
479
480 if ( info.resource != NULL && strcmp( info.resource, "" ) )
481 {
482 strncpy( status->clip, strip_root( unit, info.resource ), sizeof( status->clip ) );
483 status->speed = (int)( mlt_producer_get_speed( producer ) * 1000.0 );
484 status->fps = mlt_producer_get_fps( producer );
485 status->in = info.frame_in;
486 status->out = info.frame_out;
487 status->position = mlt_producer_position( clip );
488 status->length = mlt_producer_get_length( clip );
489 strncpy( status->tail_clip, strip_root( unit, info.resource ), sizeof( status->tail_clip ) );
490 status->tail_in = info.frame_in;
491 status->tail_out = info.frame_out;
492 status->tail_position = mlt_producer_position( clip );
493 status->tail_length = mlt_producer_get_length( clip );
494 status->clip_index = mlt_playlist_current_clip( playlist );
495 status->seek_flag = 1;
496 }
497
498 status->generation = mlt_properties_get_int( properties, "generation" );
499
500 if ( miracle_unit_has_terminated( unit ) )
501 status->status = unit_stopped;
502 else if ( !strcmp( status->clip, "" ) )
503 status->status = unit_not_loaded;
504 else if ( status->speed == 0 )
505 status->status = unit_paused;
506 else
507 status->status = unit_playing;
508 }
509 else
510 {
511 status->status = unit_undefined;
512 }
513
514 status->unit = mlt_properties_get_int( unit->properties, "unit" );
515
516 return error;
517 }
518
519 /** Change position in the playlist.
520 */
521
522 void miracle_unit_change_position( miracle_unit unit, int clip, int32_t position )
523 {
524 mlt_properties properties = unit->properties;
525 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
526 mlt_producer producer = mlt_playlist_producer( playlist );
527 mlt_playlist_clip_info info;
528
529 if ( clip < 0 )
530 {
531 clip = 0;
532 position = 0;
533 }
534 else if ( clip >= mlt_playlist_count( playlist ) )
535 {
536 clip = mlt_playlist_count( playlist ) - 1;
537 position = LONG_MAX;
538 }
539
540 if ( mlt_playlist_get_clip_info( playlist, &info, clip ) == 0 )
541 {
542 int32_t frame_start = info.start;
543 int32_t frame_offset = position;
544
545 if ( frame_offset < 0 )
546 frame_offset = info.frame_out;
547 if ( frame_offset < info.frame_in )
548 frame_offset = info.frame_in;
549 if ( frame_offset >= info.frame_out )
550 frame_offset = info.frame_out;
551
552 mlt_producer_seek( producer, frame_start + frame_offset - info.frame_in );
553 }
554
555 miracle_unit_status_communicate( unit );
556 }
557
558 /** Get the index of the current clip.
559 */
560
561 int miracle_unit_get_current_clip( miracle_unit unit )
562 {
563 mlt_properties properties = unit->properties;
564 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
565 int clip_index = mlt_playlist_current_clip( playlist );
566 return clip_index;
567 }
568
569 /** Set a clip's in point
570 */
571
572 int miracle_unit_set_clip_in( miracle_unit unit, int index, int32_t position )
573 {
574 mlt_properties properties = unit->properties;
575 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
576 mlt_playlist_clip_info info;
577 int error = mlt_playlist_get_clip_info( playlist, &info, index );
578
579 if ( error == 0 )
580 {
581 miracle_unit_play( unit, 0 );
582 error = mlt_playlist_resize_clip( playlist, index, position, info.frame_out );
583 update_generation( unit );
584 miracle_unit_change_position( unit, index, 0 );
585 }
586
587 return error;
588 }
589
590 /** Set a clip's out point.
591 */
592
593 int miracle_unit_set_clip_out( miracle_unit unit, int index, int32_t position )
594 {
595 mlt_properties properties = unit->properties;
596 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
597 mlt_playlist_clip_info info;
598 int error = mlt_playlist_get_clip_info( playlist, &info, index );
599
600 if ( error == 0 )
601 {
602 miracle_unit_play( unit, 0 );
603 error = mlt_playlist_resize_clip( playlist, index, info.frame_in, position );
604 update_generation( unit );
605 miracle_unit_status_communicate( unit );
606 miracle_unit_change_position( unit, index, -1 );
607 }
608
609 return error;
610 }
611
612 /** Step by specified position.
613 */
614
615 void miracle_unit_step( miracle_unit unit, int32_t offset )
616 {
617 mlt_properties properties = unit->properties;
618 mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
619 mlt_producer producer = mlt_playlist_producer( playlist );
620 mlt_position position = mlt_producer_frame( producer );
621 mlt_producer_seek( producer, position + offset );
622 }
623
624 /** Set the unit's clip mode regarding in and out points.
625 */
626
627 //void miracle_unit_set_mode( miracle_unit unit, dv_player_clip_mode mode )
628 //{
629 //dv_player player = miracle_unit_get_dv_player( unit );
630 //if ( player != NULL )
631 //dv_player_set_clip_mode( player, mode );
632 //miracle_unit_status_communicate( unit );
633 //}
634
635 /** Get the unit's clip mode regarding in and out points.
636 */
637
638 //dv_player_clip_mode miracle_unit_get_mode( miracle_unit unit )
639 //{
640 //dv_player player = miracle_unit_get_dv_player( unit );
641 //return dv_player_get_clip_mode( player );
642 //}
643
644 /** Set the unit's clip mode regarding eof handling.
645 */
646
647 //void miracle_unit_set_eof_action( miracle_unit unit, dv_player_eof_action action )
648 //{
649 //dv_player player = miracle_unit_get_dv_player( unit );
650 //dv_player_set_eof_action( player, action );
651 //miracle_unit_status_communicate( unit );
652 //}
653
654 /** Get the unit's clip mode regarding eof handling.
655 */
656
657 //dv_player_eof_action miracle_unit_get_eof_action( miracle_unit unit )
658 //{
659 //dv_player player = miracle_unit_get_dv_player( unit );
660 //return dv_player_get_eof_action( player );
661 //}
662
663 int miracle_unit_set( miracle_unit unit, char *name_value )
664 {
665 mlt_properties properties = NULL;
666
667 if ( strncmp( name_value, "consumer.", 9 ) )
668 {
669 mlt_playlist playlist = mlt_properties_get_data( unit->properties, "playlist", NULL );
670 properties = mlt_playlist_properties( playlist );
671 }
672 else
673 {
674 mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL );
675 properties = mlt_consumer_properties( consumer );
676 name_value += 9;
677 }
678
679 return mlt_properties_parse( properties, name_value );
680 }
681
682 char *miracle_unit_get( miracle_unit unit, char *name )
683 {
684 mlt_playlist playlist = mlt_properties_get_data( unit->properties, "playlist", NULL );
685 mlt_properties properties = mlt_playlist_properties( playlist );
686 return mlt_properties_get( properties, name );
687 }
688
689 /** Release the unit
690
691 \todo error handling
692 \param unit A miracle_unit handle.
693 */
694
695 void miracle_unit_close( miracle_unit unit )
696 {
697 if ( unit != NULL )
698 {
699 miracle_log( LOG_DEBUG, "closing unit..." );
700 if ( unit->old_producers != NULL )
701 mlt_properties_close( unit->old_producers );
702 mlt_properties_close( unit->properties );
703 mlt_properties_close( unit->producers );
704 free( unit );
705 miracle_log( LOG_DEBUG, "... unit closed." );
706 }
707 }
708