Skip to content

Commit

Permalink
Cleanup transport control handling when opening new producer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Aug 30, 2014
1 parent 3a2b46d commit 2d9ba49
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,6 @@ void MainWindow::on_actionOpenOther_triggered()
void MainWindow::onProducerOpened()
{
m_meltedServerDock->disconnect(SIGNAL(positionUpdated(int,double,int,int,int,bool)));
m_player->connectTransport(MLT.transportControl());

// Remove the help page.
if (ui->stackedWidget->count() > 1)
Expand Down
13 changes: 13 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Player::Player(QWidget *parent)
, m_zoomToggleFactor(Settings.playerZoom() == 0.0f? 1.0f : Settings.playerZoom())
, m_pauseAfterPlay(false)
, m_monitorScreen(-1)
, m_currentTransport(0)
{
setObjectName("Player");
Mlt::Controller::singleton();
Expand Down Expand Up @@ -226,6 +227,8 @@ Player::Player(QWidget *parent)

void Player::connectTransport(const TransportControllable* receiver)
{
if (receiver == m_currentTransport) return;
m_currentTransport = receiver;
disconnect(SIGNAL(played(double)));
disconnect(SIGNAL(paused()));
disconnect(SIGNAL(stopped()));
Expand Down Expand Up @@ -440,6 +443,16 @@ void Player::onProducerOpened()

if (!MLT.profile().is_explicit())
emit profileChanged();
connectTransport(MLT.transportControl());
// Closing the previous producer might call pause() milliseconds before
// calling play() here. Delays while purging the consumer on pause can
// interfere with the play() call. So, we delay play a little to let
// pause purging to complete.
QTimer::singleShot(500, this, SLOT(postProducerOpened()));
}

void Player::postProducerOpened()
{
play();
if (m_pauseAfterPlay) {
m_pauseAfterPlay = false;
Expand Down
2 changes: 2 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public slots:
void togglePlayPaused();
void seek(int position);
void onProducerOpened();
void postProducerOpened();
void onMeltedUnitOpened();
void onProducerModified();
void onShowFrame(int position, double fps, int in, int out, int length, bool isPlaying);
Expand Down Expand Up @@ -147,6 +148,7 @@ public slots:
QWidget* m_videoWidget;
QHBoxLayout* m_videoLayout;
QWidget* m_videoScrollWidget;
const TransportControllable* m_currentTransport;

private slots:
void updateSelection();
Expand Down

0 comments on commit 2d9ba49

Please sign in to comment.