From 4662580059852a16104f12e6633db1b3b54c9849 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 4 May 2019 11:26:16 +0200 Subject: [PATCH] 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 --- src/modules/sound/lullaby/Mpg123Decoder.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/sound/lullaby/Mpg123Decoder.cpp b/src/modules/sound/lullaby/Mpg123Decoder.cpp index 986939799..8f5668cb7 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.cpp +++ b/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); 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 &) {