Fix this bug again
This commit is contained in:
parent
52a3bf5f24
commit
40868df759
@ -309,16 +309,17 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
|
|||||||
GB_set_sample_rate(&gb, 96000);
|
GB_set_sample_rate(&gb, 96000);
|
||||||
self.audioClient = [[GBAudioClient alloc] initWithRendererBlock:^(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer) {
|
self.audioClient = [[GBAudioClient alloc] initWithRendererBlock:^(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer) {
|
||||||
[audioLock lock];
|
[audioLock lock];
|
||||||
if (stopping) {
|
|
||||||
memset(buffer, 0, nFrames * sizeof(*buffer));
|
|
||||||
[audioLock unlock];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (audioBufferPosition < nFrames) {
|
if (audioBufferPosition < nFrames) {
|
||||||
audioBufferNeeded = nFrames;
|
audioBufferNeeded = nFrames;
|
||||||
[audioLock wait];
|
[audioLock wait];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stopping) {
|
||||||
|
memset(buffer, 0, nFrames * sizeof(*buffer));
|
||||||
|
[audioLock unlock];
|
||||||
|
}
|
||||||
|
|
||||||
if (audioBufferPosition >= nFrames && audioBufferPosition < nFrames + 4800) {
|
if (audioBufferPosition >= nFrames && audioBufferPosition < nFrames + 4800) {
|
||||||
memcpy(buffer, audioBuffer, nFrames * sizeof(*buffer));
|
memcpy(buffer, audioBuffer, nFrames * sizeof(*buffer));
|
||||||
memmove(audioBuffer, audioBuffer + nFrames, (audioBufferPosition - nFrames) * sizeof(*buffer));
|
memmove(audioBuffer, audioBuffer + nFrames, (audioBufferPosition - nFrames) * sizeof(*buffer));
|
||||||
@ -376,6 +377,7 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
|
|||||||
}
|
}
|
||||||
[audioLock lock];
|
[audioLock lock];
|
||||||
stopping = true;
|
stopping = true;
|
||||||
|
[audioLock signal];
|
||||||
[audioLock unlock];
|
[audioLock unlock];
|
||||||
running = false;
|
running = false;
|
||||||
while (stopping);
|
while (stopping);
|
||||||
|
Loading…
Reference in New Issue
Block a user