diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-24 12:40:43 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-24 12:40:43 +0100 |
| commit | ebd495da2fe5be8c07cf7fb52e8283bb7f4113c1 (patch) | |
| tree | 93c0f449f19258d5f3c2d7b6b205b54966c4c7a7 /src/lib/player.cc | |
| parent | 64a2f1bb6a7b972607fa363631ef7a47444e8217 (diff) | |
Allow drag of content; fix up some problems with timings.
Diffstat (limited to 'src/lib/player.cc')
| -rw-r--r-- | src/lib/player.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc index c87e27ba3..dc802e220 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -116,7 +116,7 @@ Player::pass () if (!earliest) { return true; } - + earliest->decoder->pass (); /* Move position to earliest active next emission */ @@ -199,11 +199,12 @@ Player::seek (Time t) } for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) { - if ((*i)->content->end() < t) { + + if ((*i)->content->start() > t || (*i)->content->end() <= t) { continue; } - (*i)->decoder->seek (t); + (*i)->decoder->seek (t - (*i)->content->start()); } _position = t; @@ -296,18 +297,22 @@ Player::setup_pieces () list<shared_ptr<Piece> > pieces_copy = _pieces; for (list<shared_ptr<Piece> >::iterator i = pieces_copy.begin(); i != pieces_copy.end(); ++i) { if (dynamic_pointer_cast<VideoContent> ((*i)->content)) { - Time const diff = video_pos - (*i)->content->start(); + Time const diff = (*i)->content->start() - video_pos; if (diff > 0) { shared_ptr<NullContent> nc (new NullContent (_film, video_pos, diff)); - _pieces.push_back (shared_ptr<Piece> (new Piece (nc, shared_ptr<Decoder> (new BlackDecoder (_film, nc))))); + shared_ptr<BlackDecoder> bd (new BlackDecoder (_film, nc)); + bd->Video.connect (bind (&Player::process_video, this, nc, _1, _2, _3, _4)); + _pieces.push_back (shared_ptr<Piece> (new Piece (nc, bd))); } video_pos = (*i)->content->end(); } else { - Time const diff = audio_pos - (*i)->content->start(); + Time const diff = (*i)->content->start() - audio_pos; if (diff > 0) { shared_ptr<NullContent> nc (new NullContent (_film, audio_pos, diff)); - _pieces.push_back (shared_ptr<Piece> (new Piece (nc, shared_ptr<Decoder> (new SilenceDecoder (_film, nc))))); + shared_ptr<SilenceDecoder> sd (new SilenceDecoder (_film, nc)); + sd->Audio.connect (bind (&Player::process_audio, this, nc, _1, _2)); + _pieces.push_back (shared_ptr<Piece> (new Piece (nc, sd))); } audio_pos = (*i)->content->end(); } @@ -324,7 +329,7 @@ Player::content_changed (weak_ptr<Content> w, int p) return; } - if (p == VideoContentProperty::VIDEO_LENGTH) { + if (p == ContentProperty::START || p == VideoContentProperty::VIDEO_LENGTH) { _have_valid_pieces = false; } } |
