More fixes to when to pull from the audio merger.
authorCarl Hetherington <cth@carlh.net>
Wed, 22 Feb 2017 14:09:50 +0000 (14:09 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 19 Apr 2017 22:04:32 +0000 (23:04 +0100)
src/lib/player.cc
src/lib/transcoder.cc

index eeeef2cb3ed4006170127a7d647a186c056d029f..0011f7ab25cdfef3704e8f4c6a68b2ededa7293b 100644 (file)
@@ -146,6 +146,14 @@ Player::setup_pieces ()
                }
        }
 
+       BOOST_FOREACH (shared_ptr<Piece> i, _pieces) {
+               if (i->content->audio) {
+                       BOOST_FOREACH (AudioStreamPtr j, i->content->audio->streams()) {
+                               _stream_states[j] = StreamState (i, i->content->position ());
+                       }
+               }
+       }
+
        _have_valid_pieces = true;
 }
 
@@ -555,6 +563,7 @@ Player::pass ()
                }
        }
 
+//     cout << "PULL " << to_string(pull_from) << "\n";
        pair<shared_ptr<AudioBuffers>, DCPTime> audio = _audio_merger.pull (pull_from);
        if (audio.first->frames() > 0) {
                DCPOMATIC_ASSERT (audio.second >= _last_audio_time);
@@ -740,13 +749,11 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
                content_audio.audio = _audio_processor->run (content_audio.audio, _film->audio_channels ());
        }
 
+//     cout << "PUSH " << content_audio.audio->frames() << " @ " << to_string(time) << "\n";
        _audio_merger.push (content_audio.audio, time);
 
-       if (_stream_states.find (stream) == _stream_states.end ()) {
-               _stream_states[stream] = StreamState (piece, time);
-       } else {
-               _stream_states[stream].last_push_end = time + DCPTime::from_frames (content_audio.audio->frames(), _film->audio_frame_rate());
-       }
+       DCPOMATIC_ASSERT (_stream_states.find (stream) != _stream_states.end ());
+       _stream_states[stream].last_push_end = time + DCPTime::from_frames (content_audio.audio->frames(), _film->audio_frame_rate());
 }
 
 void
index e2bbca98e2fa2ff879dc5c3644f406231025f8fe..de2fb1d3388b73d94b1b5889c8b91b7d153083be 100644 (file)
@@ -115,7 +115,6 @@ Transcoder::video (shared_ptr<PlayerVideo> data, DCPTime time)
 void
 Transcoder::audio (shared_ptr<AudioBuffers> data, DCPTime time)
 {
-       cout << "tx receives " << data->frames() << " @ " << to_string(time) << "\n";
        _writer->write (data);
 
        shared_ptr<Job> job = _job.lock ();