Commit e0130fce authored by luyikei's avatar luyikei

AbstractRenderer: Use shared pointer for eventWatcher

parent 12105541
......@@ -49,9 +49,9 @@ PreviewRuler::setRenderer( AbstractRenderer* renderer )
m_renderer->disconnect( this );
m_renderer = renderer;
connect( m_renderer->eventWatcher(), &RendererEventWatcher::positionChanged,
connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::positionChanged,
this, &PreviewRuler::updateTimecode );
connect( m_renderer->eventWatcher(), SIGNAL( stopped() ),
connect( m_renderer->eventWatcher().data(), SIGNAL( stopped() ),
this, SLOT( clear() ) );
connect( m_renderer, SIGNAL( lengthChanged(qint64) ), this, SLOT( update() ) );
}
......
......@@ -86,11 +86,11 @@ PreviewWidget::setRenderer( AbstractRenderer* renderer )
m_ui->renderWidget->release();
#endif
connect( renderer->eventWatcher(), SIGNAL( stopped() ), this, SLOT( videoStopped() ) );
connect( renderer->eventWatcher(), SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( renderer->eventWatcher(), SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
connect( renderer->eventWatcher(), SIGNAL( errorEncountered() ), this, SLOT( error() ) );
connect( renderer->eventWatcher(), SIGNAL( volumeChanged() ), this, SLOT( volumeChanged() ) );
connect( renderer->eventWatcher().data(), SIGNAL( stopped() ), this, SLOT( videoStopped() ) );
connect( renderer->eventWatcher().data(), SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( renderer->eventWatcher().data(), SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
connect( renderer->eventWatcher().data(), SIGNAL( errorEncountered() ), this, SLOT( error() ) );
connect( renderer->eventWatcher().data(), SIGNAL( volumeChanged() ), this, SLOT( volumeChanged() ) );
connect( m_ui->rulerWidget, SIGNAL( frameChanged(qint64, Vlmc::FrameChangedReason) ),
m_renderer, SLOT( previewWidgetCursorChanged(qint64) ) );
......
......@@ -34,21 +34,20 @@
AbstractRenderer::AbstractRenderer()
: m_input( nullptr )
, m_eventWatcher( new RendererEventWatcher )
{
m_eventWatcher = new RendererEventWatcher;
connect( m_eventWatcher, &RendererEventWatcher::stopped, this, &AbstractRenderer::stop );
connect( m_eventWatcher, &RendererEventWatcher::positionChanged, this, [this]( qint64 pos ){ emit frameChanged( pos, Vlmc::Renderer ); } );
connect( m_eventWatcher, &RendererEventWatcher::lengthChanged, this, &AbstractRenderer::lengthChanged );
connect( m_eventWatcher, &RendererEventWatcher::endReached, this, &AbstractRenderer::stop );
connect( m_eventWatcher.data(), &RendererEventWatcher::stopped, this, &AbstractRenderer::stop );
connect( m_eventWatcher.data(), &RendererEventWatcher::positionChanged, this, [this]( qint64 pos ){ emit frameChanged( pos, Vlmc::Renderer ); } );
connect( m_eventWatcher.data(), &RendererEventWatcher::lengthChanged, this, &AbstractRenderer::lengthChanged );
connect( m_eventWatcher.data(), &RendererEventWatcher::endReached, this, &AbstractRenderer::stop );
}
AbstractRenderer::~AbstractRenderer()
{
stop();
delete m_eventWatcher;
}
RendererEventWatcher*
QSharedPointer<RendererEventWatcher>
AbstractRenderer::eventWatcher()
{
return m_eventWatcher;
......@@ -163,7 +162,7 @@ AbstractRenderer::setInput( Backend::IInput* input )
if ( m_input )
{
m_input->setCallback( m_eventWatcher );
m_input->setCallback( m_eventWatcher.data() );
emit lengthChanged( m_input->playableLength() );
}
else
......@@ -177,7 +176,7 @@ void
AbstractRenderer::setOutput( std::unique_ptr<Backend::IOutput> consuemr )
{
m_output = std::move( consuemr );
m_output->setCallback( m_eventWatcher );
m_output->setCallback( m_eventWatcher.data() );
if ( m_input != nullptr )
m_output->connect( *m_input );
......
......@@ -29,6 +29,7 @@
#endif
#include <memory>
#include <QObject>
#include <QSharedPointer>
#include "Workflow/Types.h"
#include "Backend/IOutput.h"
......@@ -149,12 +150,12 @@ public:
virtual void setInput( Backend::IInput* input );
virtual void setOutput( std::unique_ptr<Backend::IOutput> consuemr );
RendererEventWatcher* eventWatcher();
QSharedPointer<RendererEventWatcher> eventWatcher();
protected:
std::unique_ptr<Backend::IOutput> m_output;
Backend::IInput* m_input;
RendererEventWatcher* m_eventWatcher;
QSharedPointer<RendererEventWatcher> m_eventWatcher;
public slots:
......
......@@ -68,9 +68,9 @@ MainWorkflow::MainWorkflow( Settings* projectSettings, int trackCount ) :
connect( m_sequenceWorkflow.get(), &SequenceWorkflow::clipResized, this, &MainWorkflow::clipResized );
m_renderer->setInput( m_sequenceWorkflow->input() );
connect( m_renderer->eventWatcher(), &RendererEventWatcher::lengthChanged, this, &MainWorkflow::lengthChanged );
connect( m_renderer->eventWatcher(), &RendererEventWatcher::endReached, this, &MainWorkflow::mainWorkflowEndReached );
connect( m_renderer->eventWatcher(), &RendererEventWatcher::positionChanged, this, [this]( qint64 pos )
connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::lengthChanged, this, &MainWorkflow::lengthChanged );
connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::endReached, this, &MainWorkflow::mainWorkflowEndReached );
connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::positionChanged, this, [this]( qint64 pos )
{
emit frameChanged( pos, m_sequenceWorkflow->input()->playableLength(), Vlmc::Renderer );
}, Qt::DirectConnection );
......@@ -340,7 +340,7 @@ MainWorkflow::startRenderToFile( const QString &outputFileName, quint32 width, q
dialog.setOutputFileName( outputFileName );
connect( this, &MainWorkflow::frameChanged, &dialog, &WorkflowFileRendererDialog::frameChanged );
connect( &dialog, &WorkflowFileRendererDialog::stop, this, [&output]{ output.stop(); } );
connect( m_renderer->eventWatcher(), &RendererEventWatcher::positionChanged, &dialog,
connect( m_renderer->eventWatcher().data(), &RendererEventWatcher::positionChanged, &dialog,
[this, input, &dialog, width, height]( qint64 pos )
{
// Update the preview per five seconds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment