summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-06-23 22:36:50 +0200
committerCarl Hetherington <cth@carlh.net>2020-12-01 16:37:41 +0100
commit3a3ec2410363a2e23b6a3ef0e0fda582cbc4270b (patch)
tree03b50ec83a4dd10875f3aa36fad467199f172936
parenteb3167445033d600756840b10a3c28b67f5af598 (diff)
Move _stream_states into Piece; this seems like a nice change anyway.
-rw-r--r--src/lib/piece.h9
-rw-r--r--src/lib/player.cc23
-rw-r--r--src/lib/player.h15
3 files changed, 16 insertions, 31 deletions
diff --git a/src/lib/piece.h b/src/lib/piece.h
index 8309be084..3e4c66aea 100644
--- a/src/lib/piece.h
+++ b/src/lib/piece.h
@@ -21,8 +21,10 @@
#ifndef DCPOMATIC_PIECE_H
#define DCPOMATIC_PIECE_H
-#include "types.h"
+#include "audio_stream.h"
+#include "dcpomatic_time.h"
#include "frame_rate_change.h"
+#include "types.h"
class Content;
class Decoder;
@@ -32,11 +34,16 @@ class Piece
public:
Piece (boost::shared_ptr<Content> c, boost::shared_ptr<Decoder> d, FrameRateChange f);
+ void update_pull_to (dcpomatic::DCPTime& pull_to) const;
+ void set_last_push_end (AudioStreamPtr stream, DCPTime last_push_end);
+
private:
std::vector<boost::shared_ptr<Content> > _content;
std::vector<boost::shared_ptr<Decoder> > _decoder;
FrameRateChange _frc;
bool _done;
+
+ std::map<AudioStreamPtr, dcpomatic::DCPTime> _stream_last_push_end;
};
#endif
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
diff --git a/src/lib/player.h b/src/lib/player.h
index ea81ae939..6b03d4625 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -200,21 +200,6 @@ private:
Shuffler* _shuffler;
std::list<std::pair<boost::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> > _delay;
- class StreamState
- {
- public:
- StreamState () {}
-
- StreamState (boost::shared_ptr<Piece> p, dcpomatic::DCPTime l)
- : piece(p)
- , last_push_end(l)
- {}
-
- boost::shared_ptr<Piece> piece;
- dcpomatic::DCPTime last_push_end;
- };
- std::map<AudioStreamPtr, StreamState> _stream_states;
-
Empty _black;
Empty _silent;