Fix piece video_position, player _video_position and FFmpegDecoder _video_position...
authorCarl Hetherington <cth@carlh.net>
Sun, 14 Jul 2013 20:54:51 +0000 (21:54 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 14 Jul 2013 20:54:51 +0000 (21:54 +0100)
src/lib/ffmpeg_decoder.cc
src/lib/player.cc

index 637e2b187f2ae4f33e32b9836e52086bb59bd2be..18834c90e1b5249251bf6ba9e14bba1a8a8885f0 100644 (file)
@@ -313,7 +313,8 @@ FFmpegDecoder::seek (VideoContent::Frame frame, bool accurate)
        }
 
        _just_sought = true;
-
+       _video_position = frame;
+       
        if (frame == 0 || !accurate) {
                /* We're already there, or we're as close as we need to be */
                return;
index 8532b5417b588bfbe9c26f0b4d630570607b880f..c8c2064248a941560b22f6684e9121f7098ead37 100644 (file)
@@ -45,7 +45,7 @@ using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
 
-//#define DEBUG_PLAYER 1
+#define DEBUG_PLAYER 1
 
 class Piece
 {
@@ -168,7 +168,7 @@ Player::pass ()
        case VIDEO:
                if (earliest_t > _video_position) {
 #ifdef DEBUG_PLAYER
-                       cout << "no video here; emitting black frame.\n";
+                       cout << "no video here; emitting black frame (earliest=" << earliest_t << ", video_position=" << _video_position << ").\n";
 #endif
                        emit_black ();
                } else {
@@ -308,10 +308,6 @@ Player::process_audio (weak_ptr<Piece> weak_piece, shared_ptr<const AudioBuffers
                        _audio_buffers.make_silent (0, _audio_buffers.frames());
                        _audio_buffers.set_frames (N);
                }
-                       
-               if (N > _audio_buffers.frames()) {
-                       cout << "N=" << N << ", ab=" << _audio_buffers.frames() << "\n";
-               }
                assert (N <= _audio_buffers.frames());
                 shared_ptr<AudioBuffers> emit (new AudioBuffers (_audio_buffers.channels(), N));
                 emit->copy_from (&_audio_buffers, N, 0, 0);
@@ -375,11 +371,14 @@ Player::seek (Time t, bool accurate)
                s = max (static_cast<Time> (0), s);
                s = min (vc->length(), s);
 
+               (*i)->video_position = (*i)->audio_position = vc->start() + s;
+
                FrameRateConversion frc (vc->video_frame_rate(), _film->dcp_video_frame_rate());
                VideoContent::Frame f = s * vc->video_frame_rate() / (frc.factor() * TIME_HZ);
                dynamic_pointer_cast<VideoDecoder>((*i)->decoder)->seek (f, accurate);
        }
 
+       _video_position = _audio_position = t;
        /* XXX: don't seek audio because we don't need to... */
 }