+ for (auto i: _resamplers) {
+ i.second->flush ();
+ i.second->reset ();
+ }
+
+ for (auto& i: _positions) {
+ i.second = 0;
+ }
+}
+
+
+void
+AudioDecoder::flush ()
+{
+ for (auto const& i: _resamplers) {
+ auto 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)
+{
+ for (auto i: _content->streams()) {
+ int const samples = ContentTime::from_seconds(milliseconds / 1000.0).frames_round(i->frame_rate());
+ auto silence = make_shared<AudioBuffers>(i->channels(), samples);
+ silence->make_silent ();
+ Data (i, ContentAudio (silence, _positions[i]));