+
+void
+AudioDecoder::flush ()
+{
+ for (ResamplerMap::iterator i = _resamplers.begin(); i != _resamplers.end(); ++i) {
+ shared_ptr<const AudioBuffers> ro = i->second->flush ();
+ if (ro->frames() > 0) {
+ Data (i->first, ContentAudio (ro, _positions[i->first]));
+ _positions[i->first] += ro->frames();
+ }
+ }
+
+ if (_content->delay() < 0) {
+ /* Finish off with the gap caused by the delay */
+ silence (-_content->delay ());
+ }
+}
+
+void
+AudioDecoder::silence (int milliseconds)
+{
+ BOOST_FOREACH (AudioStreamPtr i, _content->streams ()) {
+ int const samples = ContentTime::from_seconds(milliseconds / 1000.0).frames_round(i->frame_rate());
+ shared_ptr<AudioBuffers> silence (new AudioBuffers (i->channels(), samples));
+ silence->make_silent ();
+ Data (i, ContentAudio (silence, _positions[i]));
+ }
+}