#include <libgen.h>
#include <limits.h>
#include <unistd.h>
+#include <signal.h>
#include <framework/mlt.h>
#include "io.h"
+static mlt_producer melt = NULL;
+
+static void stop_handler(int signum)
+{
+ if ( melt )
+ {
+ mlt_properties properties = MLT_PRODUCER_PROPERTIES( melt );
+ mlt_properties_set_int( properties, "done", 1 );
+ }
+}
+
static void transport_action( mlt_producer producer, char *value )
{
mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
{
int i;
mlt_consumer consumer = NULL;
- mlt_producer melt = NULL;
FILE *store = NULL;
char *name = NULL;
mlt_profile profile = NULL;
mlt_events_listen( properties, consumer, "consumer-fatal-error", ( mlt_listener )on_fatal_error );
if ( mlt_consumer_start( consumer ) == 0 )
{
+ // Try to exit gracefully upon these signals
+ signal( SIGHUP, stop_handler );
+ signal( SIGINT, stop_handler );
+ signal( SIGPIPE, stop_handler );
+ signal( SIGTERM, stop_handler );
+
// Transport functionality
transport( melt, consumer );