A couple of sndfile fixes for the new world order.
[dcpomatic.git] / src / lib / sndfile_decoder.cc
index b5a7f139bbf586722ced1bcb1892aa762b1b5fb1..432f73f0d66f5b30e6c8068a13266719cf9c197b 100644 (file)
@@ -55,9 +55,13 @@ SndfileDecoder::~SndfileDecoder ()
        delete[] _deinterleave_buffer;
 }
 
-void
+bool
 SndfileDecoder::pass ()
 {
+       if (_remaining == 0) {
+               return true;
+       }
+       
        /* Do things in half second blocks as I think there may be limits
           to what FFmpeg (and in particular the resampler) can cope with.
        */
@@ -90,9 +94,11 @@ SndfileDecoder::pass ()
        }
                
        data->set_frames (this_time);
-       audio (data, _done);
+       audio (data, _done * TIME_HZ / audio_frame_rate ());
        _done += this_time;
        _remaining -= this_time;
+
+       return true;
 }
 
 int
@@ -113,14 +119,11 @@ SndfileDecoder::audio_frame_rate () const
        return _info.samplerate;
 }
 
-bool
-SndfileDecoder::done () const
-{
-       return _audio_position >= _sndfile_content->audio_length ();
-}
-
 void
-SndfileDecoder::seek (DCPTime t, bool accurate)
+SndfileDecoder::seek (ContentTime t, bool accurate)
 {
-       /* XXX */
+       Decoder::seek (t, accurate);
+
+       _done = t * audio_frame_rate() / TIME_HZ;
+       _remaining = _info.frames - _done;
 }