Merge branch '1.0' into 1.0-seek
[dcpomatic.git] / src / lib / sndfile_decoder.cc
index c12152e673fcbc0eca679d0da1e08f31e39d4aa8..3af683c570a89b21a59cf6fd68d8a9f6d37d3fb7 100644 (file)
@@ -39,7 +39,8 @@ SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<const Sndfi
        , _sndfile_content (c)
        , _deinterleave_buffer (0)
 {
-       _sndfile = sf_open (_sndfile_content->file().string().c_str(), SFM_READ, &_info);
+       _info.format = 0;
+       _sndfile = sf_open (_sndfile_content->path(0).string().c_str(), SFM_READ, &_info);
        if (!_sndfile) {
                throw DecodeError (_("could not open audio file for reading"));
        }
@@ -54,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.
        */
@@ -89,9 +94,11 @@ SndfileDecoder::pass ()
        }
                
        data->set_frames (this_time);
-       audio (data, double(_done) / audio_frame_rate());
+       audio (data, _done);
        _done += this_time;
        _remaining -= this_time;
+
+       return true;
 }
 
 int
@@ -100,7 +107,7 @@ SndfileDecoder::audio_channels () const
        return _info.channels;
 }
 
-ContentAudioFrame
+AudioContent::Frame
 SndfileDecoder::audio_length () const
 {
        return _info.frames;
@@ -112,14 +119,10 @@ SndfileDecoder::audio_frame_rate () const
        return _info.samplerate;
 }
 
-Time
-SndfileDecoder::next () const
-{
-       return _next_audio;
-}
-
-bool
-SndfileDecoder::done () const
+void
+SndfileDecoder::seek (ContentTime t, bool accurate)
 {
-       return audio_done ();
+       Decoder::seek (t, accurate);
+       
+       /* XXX */
 }