mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-12-26 15:29:19 +00:00
Avoid buffer overflow
- Appears to fix a crash on Kindle Fire 1st Gen
This commit is contained in:
parent
84fe0dd479
commit
20f79dc5eb
@ -417,7 +417,7 @@ static long opensl_createSoundBuffer(const AudioContext_s *audio_context, INOUT
|
||||
unsigned long bufferSize = opensles_audio_backend.systemSettings.stereoBufferSizeSamples * opensles_audio_backend.systemSettings.bytesPerSample * NUM_CHANNELS;
|
||||
|
||||
if (ctx->recycledVoices) {
|
||||
LOG("Recycling previously SLVoice ...");
|
||||
LOG("Recycling previous SLVoice ...");
|
||||
voice = ctx->recycledVoices;
|
||||
ctx->recycledVoices = voice->next;
|
||||
uint8_t *prevBuffer = voice->ringBuffer;
|
||||
|
@ -307,6 +307,13 @@ static unsigned int _submit_samples_buffer(const unsigned long num_channel_sampl
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned long maxSpeakerBytes = channelsSampleRateHz * sizeof(int16_t);
|
||||
|
||||
if (system_buffer_size > maxSpeakerBytes) {
|
||||
RELEASE_LOG("AVOIDING BUFOVER...");
|
||||
system_buffer_size = maxSpeakerBytes;
|
||||
}
|
||||
|
||||
memcpy(system_samples_buffer, &samples_buffer[samples_idx], system_buffer_size);
|
||||
|
||||
err = speakerBuffer->Unlock(speakerBuffer, system_buffer_size);
|
||||
|
Loading…
Reference in New Issue
Block a user