aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/plugins/MadDecoderPlugin.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder/plugins/MadDecoderPlugin.cxx')
-rw-r--r--src/decoder/plugins/MadDecoderPlugin.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx
index ea2c9ac6c..9baa6fb9c 100644
--- a/src/decoder/plugins/MadDecoderPlugin.cxx
+++ b/src/decoder/plugins/MadDecoderPlugin.cxx
@@ -167,6 +167,15 @@ struct MadDecoder {
bool DecodeFirstFrame(Tag **tag);
+ void AllocateBuffers() {
+ assert(max_frames > 0);
+ assert(frame_offsets == nullptr);
+ assert(times == nullptr);
+
+ frame_offsets = new long[max_frames];
+ times = new mad_timer_t[max_frames];
+ }
+
gcc_pure
long TimeToFrame(SongTime t) const;
@@ -819,9 +828,6 @@ MadDecoder::DecodeFirstFrame(Tag **tag)
return false;
}
- frame_offsets = new long[max_frames];
- times = new mad_timer_t[max_frames];
-
return true;
}
@@ -1049,6 +1055,8 @@ mp3_decode(Decoder &decoder, InputStream &input_stream)
return;
}
+ data.AllocateBuffers();
+
Error error;
AudioFormat audio_format;
if (!audio_format_init_checked(audio_format,