Only mark _suspended as false at the appropriate times; previously
[dcpomatic.git] / src / lib / player.cc
index 7156e31228eb17fb369356f41d070e1656ae18e5..537a7190606e2e3effe394c356d2dfca9657003b 100644 (file)
@@ -231,7 +231,6 @@ Player::setup_pieces_unlocked ()
        _last_video_time = DCPTime ();
        _last_video_eyes = EYES_BOTH;
        _last_audio_time = DCPTime ();
-       _suspended = false;
 }
 
 void
@@ -247,6 +246,7 @@ Player::playlist_content_change (ChangeType type, int property, bool frequent)
        } else if (type == CHANGE_TYPE_DONE) {
                /* A change in our content has gone through.  Re-build our pieces. */
                setup_pieces ();
+               _suspended = false;
        } else if (type == CHANGE_TYPE_CANCELLED) {
                boost::mutex::scoped_lock lm (_mutex);
                _suspended = false;
@@ -619,11 +619,10 @@ Player::pass ()
                DCPTimePeriod period (_silent.period_at_position());
                if (_last_audio_time) {
                        /* Sometimes the thing that happened last finishes fractionally before
-                          this silence.  Bodge the start time of the silence to fix it.  I'm
-                          not sure if this is the right solution --- maybe the last thing should
-                          be padded `forward' rather than this thing padding `back'.
+                          or after this silence.  Bodge the start time of the silence to fix it.
                        */
-                       period.from = min(period.from, *_last_audio_time);
+                       DCPOMATIC_ASSERT (labs(period.from.get() - _last_audio_time->get()) < 2);
+                       period.from = *_last_audio_time;
                }
                if (period.duration() > one_video_frame()) {
                        period.to = period.from + one_video_frame();