summaryrefslogtreecommitdiff
path: root/src/lib/audio_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-06-20 10:04:25 +0100
committerCarl Hetherington <cth@carlh.net>2014-06-20 10:04:25 +0100
commit0444ddab72c195d91e422ac659594e6d81fbf938 (patch)
tree7993e0b4c8b5462c3fbb808331ce853786d4571b /src/lib/audio_decoder.cc
parent0da7c88a1afb221f97e2e96c159b1a984e4e2f71 (diff)
Don't allow _decoded_audio to grow to very large sizes during seek.
Diffstat (limited to 'src/lib/audio_decoder.cc')
-rw-r--r--src/lib/audio_decoder.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc
index 4a543cea9..2c0388fc3 100644
--- a/src/lib/audio_decoder.cc
+++ b/src/lib/audio_decoder.cc
@@ -132,7 +132,16 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, ContentTime time)
assert (_audio_position.get() >= (_decoded_audio.frame + _decoded_audio.audio->frames()));
/* Resize _decoded_audio to fit the new data */
- int const new_size = _audio_position.get() + data->frames() - _decoded_audio.frame;
+ 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;
+ }
+
_decoded_audio.audio->ensure_size (new_size);
_decoded_audio.audio->set_frames (new_size);