-#endif
-
-// 1.024 MHz / 60 = 17066.6... cycles (23.2199 cycles per sample)
-// Need the last frame position in order to calculate correctly...
-
- SDL_LockAudio();
- uint8 sample = (speakerState ? amplitude : 0xFF - amplitude);
-// uint8 sample = (speakerState ? amplitude : amplitude ^ 0xFF);
- uint32 currentPos = sampleBase + (uint32)((double)time / 23.2199);
-
- if (currentPos > 4095)
- {
-#if 0
-WriteLog("ToggleSpeaker() about to go into spinlock at time: %08X (%u) (sampleBase=%u)!\n", time, time, sampleBase);
-#endif
-// Still hanging on this spinlock...
-// That could be because the "time" value is too high and so the buffer will NEVER be
-// empty enough...
-// Now that we're using a conditional, it seems to be working OK--though not perfectly...
-/*
-ToggleSpeaker() about to go into spinlock at time: 00004011 (16401) (sampleBase=3504)!
-16401 -> 706 samples, 3504 + 706 = 4210
-
-And it still thrashed the sound even though it didn't run into a spinlock...
-
-Seems like it's OK now that I've fixed the buffer-less-than-length bug...
-*/
- SDL_UnlockAudio();
- SDL_CondWait(conditional, mutex);
-
-// while (currentPos > 4095) // Spin until buffer empties a bit...
- currentPos = sampleBase + (uint32)((double)time / 23.2199);
- SDL_LockAudio();
-#if 0
-WriteLog("--> after spinlock (sampleBase=%u)...\n", sampleBase);
-#endif
- }