diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-06-23 22:36:50 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-12-01 16:37:41 +0100 |
| commit | 3a3ec2410363a2e23b6a3ef0e0fda582cbc4270b (patch) | |
| tree | 03b50ec83a4dd10875f3aa36fad467199f172936 /src/lib/player.cc | |
| parent | eb3167445033d600756840b10a3c28b67f5af598 (diff) | |
Move _stream_states into Piece; this seems like a nice change anyway.
Diffstat (limited to 'src/lib/player.cc')
| -rw-r--r-- | src/lib/player.cc | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc index ced7634ea..be2519b63 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -264,15 +264,6 @@ Player::setup_pieces_unlocked () } } - _stream_states.clear (); - 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 ()); - } - } - } - _black = Empty (_film, playlist(), bind(&have_video, _1), _playback_length); _silent = Empty (_film, playlist(), bind(&have_audio, _1), _playback_length); @@ -727,10 +718,8 @@ Player::pass () of our streams, or the position of the _silent. */ DCPTime pull_to = _playback_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_to) { - pull_to = i->second.last_push_end; - } + BOOST_FOREACH (shared_ptr<Piece> i, _pieces) { + i->update_pull_to (pull_to); } if (!_silent.done() && _silent.position() < pull_to) { pull_to = _silent.position(); @@ -982,8 +971,12 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a /* Push */ _audio_merger.push (content_audio.audio, time); - 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()); + /* XXX: this almost certainly needs to be more efficient; perhaps pieces fill a map to find + * the piece from the stream, then we can call the right piece with no loop. + */ + BOOST_FOREACH (shared_ptr<Piece> i, _pieces) { + i->set_last_push_end (stream, time + DCPTime::from_frames(content_audio.audio->frames(), _film->audio_frame_rate())); + } } void |
