Verify that the bit depth argument in love.sound.newSoundData is valid / supported.

This commit is contained in:
Alex Szpakowski
2015-06-14 18:10:40 -03:00
parent aac595525a
commit 57fa9994af
+4 -1
View File
@@ -41,6 +41,9 @@ SoundData::SoundData(Decoder *decoder)
, bitDepth(0)
, channels(0)
{
if (decoder->getBitDepth() != 8 && decoder->getBitDepth() != 16)
throw love::Exception("Invalid bit depth: %d", decoder->getBitDepth());
size_t bufferSize = 524288; // 0x80000
int decoded = decoder->decode();
@@ -117,7 +120,7 @@ void SoundData::load(int samples, int sampleRate, int bitDepth, int channels, vo
if (sampleRate <= 0)
throw love::Exception("Invalid sample rate: %d", sampleRate);
if (bitDepth <= 0)
if (bitDepth != 8 && bitDepth != 16)
throw love::Exception("Invalid bit depth: %d", bitDepth);
if (channels <= 0)