Browse Source

Make sure the mpg123 decoder tries to read data on creation

So it can fail if it's not actually an mp3 file

Preparation for issue #1487
Bart van Strien 6 years ago
parent
commit
4662580059
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/modules/sound/lullaby/Mpg123Decoder.cpp

+ 6 - 0
src/modules/sound/lullaby/Mpg123Decoder.cpp

@@ -158,6 +158,12 @@ Mpg123Decoder::Mpg123Decoder(Data *data, int bufferSize)
 		mpg123_format(handle, rate, channels, MPG123_ENC_SIGNED_16);
 		mpg123_format(handle, rate, channels, MPG123_ENC_SIGNED_16);
 
 
 		sampleRate = (int) rate;
 		sampleRate = (int) rate;
+
+		// Force a read, so we can determine if it's actually an mp3
+		struct mpg123_frameinfo info;
+		ret = mpg123_info(handle, &info);
+		if (ret != MPG123_OK)
+			throw love::Exception("Could not read mp3 data.");
 	}
 	}
 	catch (love::Exception &)
 	catch (love::Exception &)
 	{
 	{