Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPlaybackEngineMLT::StopAndResume Struct Reference

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...

Public Member Functions

 StopAndResume (KisPlaybackEngineMLT::Private *p_d, bool requireFullRestart=false)
 
 ~StopAndResume ()
 

Private Attributes

Privatem_d
 

Detailed Description

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.

Definition at line 289 of file KisPlaybackEngineMLT.cpp.

Constructor & Destructor Documentation

◆ StopAndResume()

KisPlaybackEngineMLT::StopAndResume::StopAndResume ( KisPlaybackEngineMLT::Private * p_d,
bool requireFullRestart = false )
inlineexplicit

Definition at line 291 of file KisPlaybackEngineMLT.cpp.

292 : m_d(p_d)
293 {
294 KIS_ASSERT(p_d);
295
296
297 {
301 }
302
303 m_d->pushConsumer->stop();
304 m_d->pushConsumer->purge();
305 m_d->pullConsumer->stop();
306 m_d->pullConsumer->purge();
307 m_d->pullConsumer->disconnect_all_producers();
308
309 if (requireFullRestart) {
311 }
312 }
#define KIS_ASSERT(cond)
Definition kis_assert.h:33
FrameWaitingInterface frameWaitingInterface
QScopedPointer< Mlt::PushConsumer > pushConsumer
QScopedPointer< Mlt::Consumer > pullConsumer

References KisPlaybackEngineMLT::Private::cleanupConsumers(), KisPlaybackEngineMLT::Private::frameWaitingInterface, KIS_ASSERT, m_d, KisPlaybackEngineMLT::Private::pullConsumer, KisPlaybackEngineMLT::Private::pushConsumer, KisPlaybackEngineMLT::FrameWaitingInterface::renderingAllowed, KisPlaybackEngineMLT::FrameWaitingInterface::renderingControlMutex, and KisPlaybackEngineMLT::FrameWaitingInterface::renderingWaitCondition.

◆ ~StopAndResume()

KisPlaybackEngineMLT::StopAndResume::~StopAndResume ( )
inline

Make sure that all producer properties are initialized before the consumers start pulling stuff from the producer. Otherwise we can get a race condition with the consumer's read-ahead thread.

Definition at line 314 of file KisPlaybackEngineMLT.cpp.

314 {
316 if (!m_d->pushConsumer || !m_d->pullConsumer) {
318 }
319
320 if (m_d->activeCanvas()) {
322 KIS_SAFE_ASSERT_RECOVER_RETURN(animationState);
323
324 {
328
330 }
331
332 m_d->frameStats.reset();
333
334 {
342 m_d->activeProducer()->set("start_frame", animInterface->activePlaybackRange().start());
343 m_d->activeProducer()->set("end_frame", animInterface->activePlaybackRange().end());
344 m_d->activeProducer()->set("speed", m_d->playbackSpeed);
345 const int shouldLimit = m_d->activePlaybackMode() == PLAYBACK_PUSH ? 0 : 1;
346 m_d->activeProducer()->set("limit_enabled", shouldLimit);
347 }
348
350 m_d->pushConsumer->set("volume", m_d->mute ? 0.0 : animationState->currentVolume());
351 m_d->pushConsumer->start();
352 } else {
353 m_d->pullConsumer->connect_producer(*m_d->activeProducer());
354 m_d->pullConsumer->set("volume", m_d->mute ? 0.0 : animationState->currentVolume());
355 m_d->pullConsumer->set("real_time", m_d->dropFrames() ? 1 : 0);
356 m_d->pullConsumer->start();
357 }
358 }
359 }
@ PLAYBACK_PUSH
KisCanvasAnimationState * animationState() const
KisImageWSP image() const
The KisCanvasAnimationState class stores all of the canvas-specific animation state.
const KisTimeSpan & activePlaybackRange() const
activePlaybackRange
KisImageAnimationInterface * animationInterface() const
int start() const
int end() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
QSharedPointer< Mlt::Producer > activeProducer()

References KisPlaybackEngineMLT::Private::activeCanvas(), KisPlaybackEngineMLT::Private::activePlaybackMode(), KisImageAnimationInterface::activePlaybackRange(), KisPlaybackEngineMLT::Private::activeProducer(), KisImage::animationInterface(), KisCanvas2::animationState(), KisCanvasAnimationState::currentVolume(), KisPlaybackEngineMLT::Private::dropFrames(), KisTimeSpan::end(), KisPlaybackEngineMLT::Private::frameStats, KisPlaybackEngineMLT::Private::frameWaitingInterface, KisCanvas2::image(), KisPlaybackEngineMLT::Private::initializeConsumers(), KIS_ASSERT, KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, KisPlaybackEngineMLT::Private::mute, PLAYBACK_PUSH, KisPlaybackEngineMLT::Private::playbackSpeed, KisPlaybackEngineMLT::Private::pullConsumer, KisPlaybackEngineMLT::Private::pushConsumer, KisPlaybackEngineMLT::FrameWaitingInterface::renderingAllowed, KisPlaybackEngineMLT::FrameWaitingInterface::renderingControlMutex, KisPlaybackEngineMLT::FrameWaitingInterface::renderingWaitCondition, KisTimeSpan::start(), and KisPlaybackEngineMLT::FrameWaitingInterface::waitingForFrame.

Member Data Documentation

◆ m_d

Private* KisPlaybackEngineMLT::StopAndResume::m_d
private

Definition at line 362 of file KisPlaybackEngineMLT.cpp.


The documentation for this struct was generated from the following file: