From 119f7c71af8b751368fd06aeb212630a7c0533a3 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Fri, 5 Dec 2014 21:16:43 -0500 Subject: [PATCH] win64 fixes --- src/audio/AudioThread.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/audio/AudioThread.cpp b/src/audio/AudioThread.cpp index ad19978..0a1d812 100644 --- a/src/audio/AudioThread.cpp +++ b/src/audio/AudioThread.cpp @@ -43,7 +43,6 @@ static int audioCallback(void *outputBuffer, void *inputBuffer, unsigned int nBu return 0; } - wait_for_it = 0; std::vector nextBuffer = audio_queue->front(); int nextBufferSize = nextBuffer.size(); @@ -56,6 +55,8 @@ static int audioCallback(void *outputBuffer, void *inputBuffer, unsigned int nBu if (audio_queue->empty()) { #ifdef __APPLE__ + wait_for_it = 0; + while (wait_for_it++ < 5) { // Can we wait it out? std::this_thread::sleep_for(std::chrono::microseconds(100000)); if (!audio_queue->empty()) { @@ -65,8 +66,8 @@ static int audioCallback(void *outputBuffer, void *inputBuffer, unsigned int nBu } #endif if (audio_queue->empty()) { + std::cout << "Audio buffer underflow mid request.." << (src->underflow_count++) << std::endl; for (int j = i; j < nBufferFrames * 2; j++) { - std::cout << "Audio buffer underflow mid request.." << (src->underflow_count++) << std::endl; out[i] = 0; } return 0; @@ -91,7 +92,11 @@ void AudioThread::threadMain() { parameters.nChannels = 2; parameters.firstChannel = 0; unsigned int sampleRate = AUDIO_FREQUENCY; +#ifdef __APPLE__ unsigned int bufferFrames = 0; +#else + unsigned int bufferFrames = 256; +#endif RtAudio::StreamOptions opts; // opts.flags = RTAUDIO_SCHEDULE_REALTIME | RTAUDIO_MINIMIZE_LATENCY;