+ void purge()
+ {
+ if ( running )
+ {
+ pthread_mutex_lock( &video_mutex );
+ mlt_frame frame = MLT_FRAME( mlt_deque_peek_back( queue ) );
+ // When playing rewind or fast forward then we need to keep one
+ // frame in the queue to prevent playback stalling.
+ double speed = frame? mlt_properties_get_double( MLT_FRAME_PROPERTIES(frame), "_speed" ) : 0;
+ int n = ( speed == 0.0 || speed == 1.0 ) ? 0 : 1;
+ while ( mlt_deque_count( queue ) > n )
+ mlt_frame_close( MLT_FRAME( mlt_deque_pop_back( queue ) ) );
+ is_purge = true;
+ pthread_cond_broadcast( &video_cond );
+ pthread_mutex_unlock( &video_mutex );
+ }
+ }
+