Merge master.
[dcpomatic.git] / src / lib / sndfile_decoder.cc
index c7311112acdd28cf4303acb5fb581912bdaa932e..9ba972e565ffbdb47b52056f2aaede885dcee560 100644 (file)
@@ -42,14 +42,13 @@ 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;
 }
 
 SndfileDecoder::~SndfileDecoder ()
 {
-       if (_sndfile) {
-               sf_close (_sndfile);
-       }
+       sf_close (_sndfile);
 }
 
 bool
@@ -64,7 +63,8 @@ SndfileDecoder::pass ()
        shared_ptr<AudioBuffers> audio (new AudioBuffers (_sndfile_content->audio_channels(), this_time));
        sf_read_float (_sndfile, audio->data(0), this_time);
        audio->set_frames (this_time);
-       Audio (audio);
+       Audio (audio, double(_done) / audio_frame_rate());
+       _done += this_time;
        _remaining -= this_time;
 
        return (_remaining == 0);