Merge branch 'master' of ssh://git.carlh.net/home/carl/git/dcpomatic
authorCarl Hetherington <cth@carlh.net>
Tue, 16 May 2017 08:59:06 +0000 (09:59 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 16 May 2017 08:59:06 +0000 (09:59 +0100)
src/lib/audio_merger.cc
src/lib/audio_merger.h
src/lib/player.cc

index 8a69dee5204036381253a4f23e54ba12892587e6..a16c378c67309dac758c90abd27fc275ef7db769 100644 (file)
@@ -56,11 +56,9 @@ AudioMerger::pull (DCPTime time)
 {
        list<pair<shared_ptr<AudioBuffers>, DCPTime> > out;
 
-       DCPTimePeriod period (_last_pull, time);
-       _buffers.sort (AudioMerger::BufferComparator());
-
        list<Buffer> new_buffers;
 
+       _buffers.sort (AudioMerger::BufferComparator());
        BOOST_FOREACH (Buffer i, _buffers) {
                if (i.period().to <= time) {
                        /* Completely within the pull period */
@@ -98,7 +96,6 @@ AudioMerger::pull (DCPTime time)
 void
 AudioMerger::push (boost::shared_ptr<const AudioBuffers> audio, DCPTime time)
 {
-       DCPOMATIC_ASSERT (time >= _last_pull);
        DCPOMATIC_ASSERT (audio->frames() > 0);
 
        DCPTimePeriod period (time, time + DCPTime::from_frames (audio->frames(), _frame_rate));
@@ -164,5 +161,4 @@ void
 AudioMerger::clear ()
 {
        _buffers.clear ();
-       _last_pull = DCPTime ();
 }
index c3e627fcd7ccc60656254ee3f5f40e21e4f232f5..6c9d87097c6fc4458706317338f3dac426d863d8 100644 (file)
@@ -79,6 +79,5 @@ private:
        };
 
        std::list<Buffer> _buffers;
-       DCPTime _last_pull;
        int _frame_rate;
 };
index a711c80c03521ad24aa2dd7fb21372b87911c85d..8ebeb236d2fb27428ff03b571380bef51f68b976 100644 (file)
@@ -584,20 +584,16 @@ Player::pass ()
                filled = true;
        }
 
-       if (!earliest && !filled) {
-               return true;
-       }
-
        /* Emit any audio that is ready */
 
-       DCPTime pull_from = _playlist->length ();
+       DCPTime pull_to = _playlist->length ();
        for (map<AudioStreamPtr, StreamState>::const_iterator i = _stream_states.begin(); i != _stream_states.end(); ++i) {
-               if (!i->second.piece->done && i->second.last_push_end < pull_from) {
-                       pull_from = i->second.last_push_end;
+               if (!i->second.piece->done && i->second.last_push_end < pull_to) {
+                       pull_to = i->second.last_push_end;
                }
        }
 
-       list<pair<shared_ptr<AudioBuffers>, DCPTime> > audio = _audio_merger.pull (pull_from);
+       list<pair<shared_ptr<AudioBuffers>, DCPTime> > audio = _audio_merger.pull (pull_to);
        for (list<pair<shared_ptr<AudioBuffers>, DCPTime> >::iterator i = audio.begin(); i != audio.end(); ++i) {
                if (_last_audio_time && i->second < *_last_audio_time) {
                        /* There has been an accurate seek and we have received some audio before the seek time;
@@ -617,7 +613,7 @@ Player::pass ()
                emit_audio (i->first, i->second);
        }
 
-       return false;
+       return !earliest && !filled;
 }
 
 optional<PositionImage>
@@ -808,6 +804,13 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
        /* And the end of this block in the DCP */
        DCPTime end = time + DCPTime::from_frames(content_audio.audio->frames(), content->resampled_frame_rate());
 
+       /* Pad any gap which may be caused by audio delay */
+       if (_last_audio_time) {
+               fill_audio (DCPTimePeriod (*_last_audio_time, time));
+       } else if (_last_seek_time && _last_seek_accurate) {
+               fill_audio (DCPTimePeriod (*_last_seek_time, time));
+       }
+
        /* Remove anything that comes before the start or after the end of the content */
        if (time < piece->content->position()) {
                pair<shared_ptr<AudioBuffers>, DCPTime> cut = discard_audio (content_audio.audio, time, piece->content->position());