mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-09 04:21:38 +12:00
Revert to spinlocking for audio sync
This commit is contained in:
parent
426162f709
commit
56f716c1f1
3 changed files with 105 additions and 91 deletions
|
@ -92,6 +92,14 @@ void MiniAudioDevice::init(Samples& samples, bool safe) {
|
|||
auto self = reinterpret_cast<MiniAudioDevice*>(device->pUserData);
|
||||
s16* output = reinterpret_cast<ma_int16*>(out);
|
||||
|
||||
// Wait until there's enough samples to pop
|
||||
while (self->samples->size() < frameCount * channelCount) {
|
||||
// If audio output is disabled from the emulator thread, make sure that this callback will return and not hang
|
||||
if (!self->running) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
self->samples->pop(output, frameCount * channelCount);
|
||||
};
|
||||
|
||||
|
|
|
@ -128,6 +128,11 @@ void TeakraDSP::setAudioEnabled(bool enable) {
|
|||
// Push our samples at the end of an audio frame
|
||||
if (audioFrameIndex >= audioFrame.size()) {
|
||||
audioFrameIndex -= audioFrame.size();
|
||||
|
||||
// Wait until we've actually got room to do so
|
||||
while (sampleBuffer.size() + 2 > sampleBuffer.Capacity()) {
|
||||
}
|
||||
|
||||
sampleBuffer.push(audioFrame.data(), audioFrame.size());
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue