summaryrefslogtreecommitdiff
path: root/src/lib/audio_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-11-15 00:44:37 +0100
committerCarl Hetherington <cth@carlh.net>2022-11-15 22:42:43 +0100
commitd42bc731c125170efb1bb7b8c9f990a3e9fa5b57 (patch)
treec612e631ba68c07672b337e9769607a5f24eed38 /src/lib/audio_decoder.cc
parent5e09964bf1801b76970ed960122249e1d273abea (diff)
Improve flushing behaviour when there is a lot of space to fill (#2364).
Previously a call to flush() could result in a lot of audio being emitted from the decoder (if there is a big gap between the end of the audio and the video). This would end up being emitted in one chunk from the player, crashing the audio analyser with an OOM in some cases.
Diffstat (limited to 'src/lib/audio_decoder.cc')
-rw-r--r--src/lib/audio_decoder.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc
index ca1faa010..ad3374762 100644
--- a/src/lib/audio_decoder.cc
+++ b/src/lib/audio_decoder.cc
@@ -52,14 +52,14 @@ AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr<const AudioContent> cont
/** @param time_already_delayed true if the delay should not be added to time */
void
-AudioDecoder::emit (shared_ptr<const Film> film, AudioStreamPtr stream, shared_ptr<const AudioBuffers> data, ContentTime time, bool time_already_delayed)
+AudioDecoder::emit(shared_ptr<const Film> film, AudioStreamPtr stream, shared_ptr<const AudioBuffers> data, ContentTime time, bool flushing)
{
if (ignore ()) {
return;
}
int const resampled_rate = _content->resampled_frame_rate(film);
- if (!time_already_delayed) {
+ if (!flushing) {
time += ContentTime::from_seconds (_content->delay() / 1000.0);
}
@@ -119,7 +119,7 @@ AudioDecoder::emit (shared_ptr<const Film> film, AudioStreamPtr stream, shared_p
}
}
- if (resampler) {
+ if (resampler && !flushing) {
auto ro = resampler->run (data);
if (ro->frames() == 0) {
return;