mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- clamp the loop end point to the sample size for sound effects so that bogus values do not render the loop start ineffective.
This commit is contained in:
parent
dc3df4e897
commit
882279d600
1 changed files with 7 additions and 5 deletions
|
@ -1218,15 +1218,16 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int
|
||||||
if(!decoder) return std::make_pair(retval, true);
|
if(!decoder) return std::make_pair(retval, true);
|
||||||
|
|
||||||
decoder->getInfo(&srate, &chans, &type);
|
decoder->getInfo(&srate, &chans, &type);
|
||||||
|
int samplesize = 1;
|
||||||
if(chans == ChannelConfig_Mono || monoize)
|
if(chans == ChannelConfig_Mono || monoize)
|
||||||
{
|
{
|
||||||
if(type == SampleType_UInt8) format = AL_FORMAT_MONO8;
|
if(type == SampleType_UInt8) format = AL_FORMAT_MONO8, samplesize = 1;
|
||||||
if(type == SampleType_Int16) format = AL_FORMAT_MONO16;
|
if(type == SampleType_Int16) format = AL_FORMAT_MONO16, samplesize = 2;
|
||||||
}
|
}
|
||||||
else if(chans == ChannelConfig_Stereo)
|
else if(chans == ChannelConfig_Stereo)
|
||||||
{
|
{
|
||||||
if(type == SampleType_UInt8) format = AL_FORMAT_STEREO8;
|
if(type == SampleType_UInt8) format = AL_FORMAT_STEREO8, samplesize = 2;
|
||||||
if(type == SampleType_Int16) format = AL_FORMAT_STEREO16;
|
if(type == SampleType_Int16) format = AL_FORMAT_STEREO16, samplesize = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(format == AL_NONE)
|
if(format == AL_NONE)
|
||||||
|
@ -1282,13 +1283,14 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(uint8_t *sfxdata, int
|
||||||
if (!startass) loop_start = Scale(loop_start, srate, 1000);
|
if (!startass) loop_start = Scale(loop_start, srate, 1000);
|
||||||
if (!endass) loop_end = Scale(loop_end, srate, 1000);
|
if (!endass) loop_end = Scale(loop_end, srate, 1000);
|
||||||
if (loop_start < 0) loop_start = 0;
|
if (loop_start < 0) loop_start = 0;
|
||||||
|
if (loop_end >= data.Size() / samplesize) loop_end = data.Size() / samplesize - 1;
|
||||||
|
|
||||||
if ((loop_start > 0 || loop_end > 0) && loop_end > loop_start && AL.SOFT_loop_points)
|
if ((loop_start > 0 || loop_end > 0) && loop_end > loop_start && AL.SOFT_loop_points)
|
||||||
{
|
{
|
||||||
ALint loops[2] = { static_cast<ALint>(loop_start), static_cast<ALint>(loop_end) };
|
ALint loops[2] = { static_cast<ALint>(loop_start), static_cast<ALint>(loop_end) };
|
||||||
DPrintf(DMSG_NOTIFY, "Setting loop points %d -> %d\n", loops[0], loops[1]);
|
DPrintf(DMSG_NOTIFY, "Setting loop points %d -> %d\n", loops[0], loops[1]);
|
||||||
alBufferiv(buffer, AL_LOOP_POINTS_SOFT, loops);
|
alBufferiv(buffer, AL_LOOP_POINTS_SOFT, loops);
|
||||||
getALError();
|
// no console messages here, please!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue