- AudioFrame const remaining = max ((AudioFrame) 0, available - to_return);
-
- /* Clean up decoded; first, move the data after what we just returned to the start of the buffer */
- _decoded_audio.audio->move (decoded_offset + to_return, 0, remaining);
- /* And set up the number of frames we have left */
- _decoded_audio.audio->set_frames (remaining);
- /* Also bump where those frames are in terms of the content */
- _decoded_audio.frame += decoded_offset + to_return;
-
- return shared_ptr<ContentAudio> (new ContentAudio (out, frame));
-}
-
-/** Called by subclasses when audio data is ready.
- *
- * Audio timestamping is made hard by many factors, but perhaps the most entertaining is resampling.
- * We have to assume that we are feeding continuous data into the resampler, and so we get continuous
- * data out. Hence we do the timestamping here, post-resampler, just by counting samples.
- *
- * The time is passed in here so that after a seek we can set up our _audio_position. The
- * time is ignored once this has been done.
- */
-void
-AudioDecoder::audio (shared_ptr<const AudioBuffers> data, ContentTime time)
-{
- if (_resampler) {
- data = _resampler->run (data);
- }
-
- if (!_audio_position) {
- _audio_position = time.frames (_audio_content->resampled_audio_frame_rate ());
- }
-
- assert (_audio_position.get() >= (_decoded_audio.frame + _decoded_audio.audio->frames()));
-
- /* Resize _decoded_audio to fit the new data */
- int new_size = 0;
- if (_decoded_audio.audio->frames() == 0) {
- /* There's nothing in there, so just store the new data */
- new_size = data->frames ();
- _decoded_audio.frame = _audio_position.get ();
- } else {
- /* Otherwise we need to extend _decoded_audio to include the new stuff */
- new_size = _audio_position.get() + data->frames() - _decoded_audio.frame;