X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fsndfile_decoder.cc;h=f98d4d8be83ae0e8c6bb23ce90d1d2b2d0017344;hb=cc3900735839ff4b0da0c046b5c606c440ba917a;hp=f66a7c7dc9dd363f649f2c71632a9a5057d78949;hpb=713b673456dee8e2a089e9193080b3c91f8aee94;p=dcpomatic.git diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc index f66a7c7dc..f98d4d8be 100644 --- a/src/lib/sndfile_decoder.cc +++ b/src/lib/sndfile_decoder.cc @@ -66,9 +66,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. */ @@ -101,9 +105,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 _remaining == 0; } int @@ -112,7 +118,7 @@ SndfileDecoder::audio_channels () const return _info.channels; } -AudioContent::Frame +AudioFrame SndfileDecoder::audio_length () const { return _info.frames; @@ -124,8 +130,12 @@ SndfileDecoder::audio_frame_rate () const return _info.samplerate; } -bool -SndfileDecoder::done () const +void +SndfileDecoder::seek (ContentTime t, bool accurate) { - return _audio_position >= _sndfile_content->audio_length (); + Decoder::seek (t, accurate); + AudioDecoder::seek (t, accurate); + + _done = t * audio_frame_rate() / TIME_HZ; + _remaining = _info.frames - _done; }