Various attempted fixes to audio sync.
[dcpomatic.git] / src / lib / sndfile_decoder.cc
index 1c651e6142abb1cc583011adee35723dad6d505f..d6537843e8970ebde3ae6872bb99f04fd66e5de3 100644 (file)
@@ -45,6 +45,7 @@ SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<const Sndfi
                throw DecodeError (_("could not open audio file for reading"));
        }
 
+       _done = 0;
        _remaining = _info.frames;
 }
 
@@ -93,7 +94,8 @@ SndfileDecoder::pass ()
        }
                
        data->set_frames (this_time);
-       audio (data);
+       audio (data, _done * TIME_HZ / audio_frame_rate ());
+       _done += this_time;
        _remaining -= this_time;
 
        return _remaining == 0;
@@ -123,5 +125,6 @@ SndfileDecoder::seek (ContentTime t, bool accurate)
        Decoder::seek (t, accurate);
        AudioDecoder::seek (t, accurate);
 
+       _done = t * audio_frame_rate() / TIME_HZ;
        _remaining = _info.frames - _done;
 }