mlt_events_register( properties, "consumer-frame-render", ( mlt_transmitter )mlt_consumer_frame_render );
mlt_events_register( properties, "consumer-thread-started", NULL );
mlt_events_register( properties, "consumer-thread-stopped", NULL );
+ mlt_events_register( properties, "consumer-stopping", NULL );
mlt_events_register( properties, "consumer-stopped", NULL );
mlt_events_listen( properties, self, "consumer-frame-show", ( mlt_listener )on_consumer_frame_show );
mlt_properties_set_int( properties, "sample_aspect_den", profile->sample_aspect_den );
mlt_properties_set_double( properties, "display_ratio", mlt_profile_dar( profile ) );
mlt_properties_set_int( properties, "display_aspect_num", profile->display_aspect_num );
- mlt_properties_set_int( properties, "display_aspect_num", profile->display_aspect_num );
+ mlt_properties_set_int( properties, "display_aspect_den", profile->display_aspect_den );
mlt_properties_set_int( properties, "colorspace", profile->colorspace );
mlt_event_unblock( priv->event_listener );
}
continue;
pos = mlt_frame_get_position( frame );
+ // WebVfx uses this to setup a consumer-stopping event handler.
+ mlt_properties_set_data( MLT_FRAME_PROPERTIES( frame ), "consumer", self, 0, NULL, NULL );
+
// Increment the counter used for averaging processing cost
count ++;
// Remove the last frame
mlt_frame_close( frame );
- mlt_events_fire( properties, "consumer-thread-stopped", NULL );
return NULL;
}
frame = mlt_deque_peek( priv->queue, index );
if ( frame )
{
- mlt_log_debug( MLT_CONSUMER_SERVICE(self), "worker processing index = %d frame %d queue count = %d\n",
+ mlt_log_debug( MLT_CONSUMER_SERVICE(self), "worker processing index = %d frame " MLT_POSITION_FMT " queue count = %d\n",
index, mlt_frame_get_position(frame), mlt_deque_count( priv->queue ) );
frame->is_processing = 1;
mlt_properties_inc_ref( MLT_FRAME_PROPERTIES( frame ) );
if ( frame == NULL )
continue;
+ // WebVfx uses this to setup a consumer-stopping event handler.
+ mlt_properties_set_data( MLT_FRAME_PROPERTIES( frame ), "consumer", self, 0, NULL, NULL );
+
#ifdef DEINTERLACE_ON_NOT_NORMAL_SPEED
// All non normal playback frames should be shown
if ( mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "_speed" ) != 1 )
pthread_cond_broadcast( &priv->done_cond );
pthread_mutex_unlock( &priv->done_mutex );
}
- mlt_events_fire( properties, "consumer-thread-stopped", NULL );
return NULL;
}
{
consumer_private *priv = self->local;
+ if ( priv->started )
+ return;
+
// We're running now
priv->ahead = 1;
{
consumer_private *priv = self->local;
int n = abs( priv->real_time );
- pthread_t *thread = calloc( 1, sizeof( pthread_t ) * n );
+ pthread_t *thread;
+
+ if ( priv->started )
+ return;
+
+ thread = calloc( 1, sizeof( pthread_t ) * n );
// We're running now
priv->ahead = 1;
#endif
// Inform thread to stop
priv->ahead = 0;
+ mlt_events_fire( MLT_CONSUMER_PROPERTIES(self), "consumer-stopping", NULL );
// Broadcast to the condition in case it's waiting
pthread_mutex_lock( &priv->queue_mutex );
// Close the queue
mlt_deque_close( priv->queue );
+
+ mlt_events_fire( MLT_CONSUMER_PROPERTIES(self), "consumer-thread-stopped", NULL );
}
}
#endif
// Inform thread to stop
priv->ahead = 0;
+ mlt_events_fire( MLT_CONSUMER_PROPERTIES(self), "consumer-stopping", NULL );
// Broadcast to the queue condition in case it's waiting
pthread_mutex_lock( &priv->queue_mutex );
// Close the queues
mlt_deque_close( priv->queue );
mlt_deque_close( priv->worker_threads );
+
+ mlt_events_fire( MLT_CONSUMER_PROPERTIES(self), "consumer-thread-stopped", NULL );
}
}
pthread_cond_broadcast( &priv->put_cond );
pthread_mutex_unlock( &priv->put_mutex );
- if ( priv->started && priv->real_time )
- pthread_mutex_lock( &priv->queue_mutex );
-
if ( self->purge )
self->purge( self );
+ if ( priv->started && priv->real_time )
+ pthread_mutex_lock( &priv->queue_mutex );
+
while ( priv->started && mlt_deque_count( priv->queue ) )
mlt_frame_close( mlt_deque_pop_back( priv->queue ) );
+
if ( priv->started && priv->real_time )
{
priv->is_purge = 1;
// This isn't true, but from the consumers perspective it is
if ( frame != NULL )
+ {
mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "rendered", 1 );
+
+ // WebVfx uses this to setup a consumer-stopping event handler.
+ mlt_properties_set_data( MLT_FRAME_PROPERTIES( frame ), "consumer", self, 0, NULL, NULL );
+ }
}
return frame;
mlt_log( MLT_CONSUMER_SERVICE( self ), MLT_LOG_DEBUG, "stopping consumer\n" );
// Cancel the read ahead threads
- priv->ahead = 0;
if ( priv->started )
{
// Unblock the consumer calling mlt_consumer_rt_frame