From ebd495da2fe5be8c07cf7fb52e8283bb7f4113c1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 24 May 2013 12:40:43 +0100 Subject: Allow drag of content; fix up some problems with timings. --- src/lib/player.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/lib/player.cc') 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 >::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 > pieces_copy = _pieces; for (list >::iterator i = pieces_copy.begin(); i != pieces_copy.end(); ++i) { if (dynamic_pointer_cast ((*i)->content)) { - Time const diff = video_pos - (*i)->content->start(); + Time const diff = (*i)->content->start() - video_pos; if (diff > 0) { shared_ptr nc (new NullContent (_film, video_pos, diff)); - _pieces.push_back (shared_ptr (new Piece (nc, shared_ptr (new BlackDecoder (_film, nc))))); + shared_ptr bd (new BlackDecoder (_film, nc)); + bd->Video.connect (bind (&Player::process_video, this, nc, _1, _2, _3, _4)); + _pieces.push_back (shared_ptr (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 nc (new NullContent (_film, audio_pos, diff)); - _pieces.push_back (shared_ptr (new Piece (nc, shared_ptr (new SilenceDecoder (_film, nc))))); + shared_ptr sd (new SilenceDecoder (_film, nc)); + sd->Audio.connect (bind (&Player::process_audio, this, nc, _1, _2)); + _pieces.push_back (shared_ptr (new Piece (nc, sd))); } audio_pos = (*i)->content->end(); } @@ -324,7 +329,7 @@ Player::content_changed (weak_ptr w, int p) return; } - if (p == VideoContentProperty::VIDEO_LENGTH) { + if (p == ContentProperty::START || p == VideoContentProperty::VIDEO_LENGTH) { _have_valid_pieces = false; } } -- cgit v1.2.3