mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Verify that the bit depth argument in love.sound.newSoundData is valid / supported.
This commit is contained in:
@@ -41,6 +41,9 @@ SoundData::SoundData(Decoder *decoder)
|
|||||||
, bitDepth(0)
|
, bitDepth(0)
|
||||||
, channels(0)
|
, channels(0)
|
||||||
{
|
{
|
||||||
|
if (decoder->getBitDepth() != 8 && decoder->getBitDepth() != 16)
|
||||||
|
throw love::Exception("Invalid bit depth: %d", decoder->getBitDepth());
|
||||||
|
|
||||||
size_t bufferSize = 524288; // 0x80000
|
size_t bufferSize = 524288; // 0x80000
|
||||||
int decoded = decoder->decode();
|
int decoded = decoder->decode();
|
||||||
|
|
||||||
@@ -117,7 +120,7 @@ void SoundData::load(int samples, int sampleRate, int bitDepth, int channels, vo
|
|||||||
if (sampleRate <= 0)
|
if (sampleRate <= 0)
|
||||||
throw love::Exception("Invalid sample rate: %d", sampleRate);
|
throw love::Exception("Invalid sample rate: %d", sampleRate);
|
||||||
|
|
||||||
if (bitDepth <= 0)
|
if (bitDepth != 8 && bitDepth != 16)
|
||||||
throw love::Exception("Invalid bit depth: %d", bitDepth);
|
throw love::Exception("Invalid bit depth: %d", bitDepth);
|
||||||
|
|
||||||
if (channels <= 0)
|
if (channels <= 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user