From da068e30e6407821c364aeef0bda73841473c7fd Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Fri, 19 Jan 2018 20:58:12 -0800 Subject: [PATCH] Ensure BPS=16 is set in MP3 decoder Valgrind found another uninitialized use. BitsPerSample was not being called by the LIBMAD decoder, so it was possible to start out in a bad state. Now always set it to 16, the decoder native output size. Channels are initialized to 2, but this setting is always reset on a per-frame basis anyway. --- src/AudioGeneratorMP3.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/AudioGeneratorMP3.cpp b/src/AudioGeneratorMP3.cpp index 7e0e50c..6a3672f 100644 --- a/src/AudioGeneratorMP3.cpp +++ b/src/AudioGeneratorMP3.cpp @@ -203,6 +203,10 @@ bool AudioGeneratorMP3::begin(AudioFileSource *source, AudioOutput *output) Serial.printf_P(PSTR("MP3 source file not open\n")); return false; // Error } + + output->SetBitsPerSample(16); // Constant for MP3 decoder + output->SetChannels(2); + if (!output->begin()) return false; // Where we are in generating one frame's data, set to invalid so we will run loop on first getsample()