Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPlaybackEngineMLT.cpp File Reference
#include "KisPlaybackEngineMLT.h"
#include <QMap>
#include <QMutex>
#include <QMutexLocker>
#include <QElapsedTimer>
#include <QWaitCondition>
#include "kis_canvas2.h"
#include "KisCanvasAnimationState.h"
#include "kis_image_animation_interface.h"
#include "kis_raster_keyframe_channel.h"
#include "kis_signal_compressor_with_param.h"
#include "animation/KisFrameDisplayProxy.h"
#include "KisViewManager.h"
#include "kis_onion_skin_compositor.h"
#include <mlt++/Mlt.h>
#include <mlt++/MltConsumer.h>
#include <mlt++/MltFrame.h>
#include <mlt++/MltFilter.h>
#include <mlt-7/framework/mlt_service.h>
#include "KisRollingMeanAccumulatorWrapper.h"
#include "KisRollingSumAccumulatorWrapper.h"
#include "kis_debug.h"
#include "KisMLTProducerKrita.h"

Go to the source code of this file.

Classes

struct  KisPlaybackEngineMLT::FrameWaitingInterface
 
struct  KisPlaybackEngineMLT::Private
 
struct  KisPlaybackEngineMLT::StopAndResume
 The StopAndResumeConsumer struct is used to encapsulate optional stop-and-then-resume behavior of a consumer. Using RAII, we can stop a consumer at construction and simply resume it when it exits scope. More...
 

Functions

static void mltOnConsumerFrameShow (mlt_consumer c, void *p_self, mlt_frame p_frame)
 

Variables

const float SCRUB_AUDIO_SECONDS = 0.128f
 

Function Documentation

◆ mltOnConsumerFrameShow()

static void mltOnConsumerFrameShow ( mlt_consumer c,
void * p_self,
mlt_frame p_frame )
static

This static function responds to MLT consumer requests for frames. This may continue to be called even when playback is stopped due to it running simultaneously in a separate thread.

This function is called from the non-gui thread owned by MLT, so we should wait until the frame would be really rendered. This way MLT will have information about frame rendering speed and will be able to drop frames accordingly.

NOTE: we cannot use BlockingQueuedConnection here because it would deadlock on any stream property change, when the the GUI thread would call consumer->stop().

Definition at line 113 of file KisPlaybackEngineMLT.cpp.

113 {
114 KisPlaybackEngineMLT* self = static_cast<KisPlaybackEngineMLT*>(p_self);
115 Mlt::Frame frame(p_frame);
116 Mlt::Consumer consumer(c);
117 const int position = frame.get_position();
118
120
132 QMutexLocker l(&iface->renderingControlMutex);
133
134 if (!iface->renderingAllowed) return;
135
137 iface->waitingForFrame = true;
138
139 Q_EMIT self->sigChangeActiveCanvasFrame(position);
140
141 while (iface->renderingAllowed && iface->waitingForFrame) {
143 }
144}
The KisPlaybackEngineMLT class is an implementation of KisPlaybackEngine that uses MLT (Media Lovin' ...
void sigChangeActiveCanvasFrame(int p_frame)
FrameWaitingInterface * frameWaitingInterface()
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KisPlaybackEngineMLT::frameWaitingInterface(), KIS_SAFE_ASSERT_RECOVER_RETURN, KisPlaybackEngineMLT::FrameWaitingInterface::renderingAllowed, KisPlaybackEngineMLT::FrameWaitingInterface::renderingControlMutex, KisPlaybackEngineMLT::FrameWaitingInterface::renderingWaitCondition, KisPlaybackEngineMLT::sigChangeActiveCanvasFrame(), and KisPlaybackEngineMLT::FrameWaitingInterface::waitingForFrame.

Variable Documentation

◆ SCRUB_AUDIO_SECONDS

const float SCRUB_AUDIO_SECONDS = 0.128f

Definition at line 80 of file KisPlaybackEngineMLT.cpp.