Sound: Add checks for incorrect sample rate, channel num and rate

Log a message instead of asserting
This commit is contained in:
Jonathan G Rennison
2017-08-11 19:53:24 +01:00
parent 10766f116c
commit 724d19f47d

View File

@@ -115,6 +115,19 @@ static bool SetBankSource(MixerChannel *mc, const SoundEntry *sound)
/* Check for valid sound size. */
if (sound->file_size == 0 || sound->file_size > ((size_t)-1) - 2) return false;
if (!(sound->bits_per_sample == 8 || sound->bits_per_sample == 16)) {
DEBUG(sound, 0, "SetBankSource: Incorrect bits_per_sample: %u", sound->bits_per_sample);
return false;
}
if (sound->channels != 1) {
DEBUG(sound, 0, "SetBankSource: Incorrect number of channels: %u", sound->channels);
return false;
}
if (sound->rate == 0) {
DEBUG(sound, 0, "SetBankSource: Incorrect rate: %u", sound->rate);
return false;
}
int8 *mem = MallocT<int8>(sound->file_size + 2);
/* Add two extra bytes so rate conversion can read these
* without reading out of its input buffer. */