diff --git a/src/audio/MacAudioDevice.cpp b/src/audio/MacAudioDevice.cpp index d284c3b8..0e36130f 100644 --- a/src/audio/MacAudioDevice.cpp +++ b/src/audio/MacAudioDevice.cpp @@ -39,7 +39,6 @@ using namespace std::placeholders; thread_local void* MacAudioDevice::Workgroup_ = nullptr; thread_local void* MacAudioDevice::JoinToken_ = nullptr; thread_local int MacAudioDevice::CurrentCoreAudioId_ = 0; -thread_local int64_t MacAudioDevice::AddedWaitDuration_ = 0; // Conversion factors. constexpr static int MS_TO_SEC = 1000; @@ -880,24 +879,24 @@ void MacAudioDevice::startRealTimeWork() #endif // 0 // Record current time. We'll wait up to (latency) ms after this. - waitTime_ = dispatch_time(DISPATCH_TIME_NOW, 0); + //waitTime_ = dispatch_time(DISPATCH_TIME_NOW, 0); } void MacAudioDevice::stopRealTimeWork(bool fastMode) { auto timeToWaitMilliseconds = ((1000 * chosenFrameSize_) / sampleRate_) >> (fastMode ? 1 : 0); - timeToWaitMilliseconds -= AddedWaitDuration_; + //timeToWaitMilliseconds -= AddedWaitDuration_; - auto waitStart = std::chrono::high_resolution_clock::now(); - dispatch_semaphore_wait(sem_, dispatch_time(waitTime_, MS_TO_NSEC * timeToWaitMilliseconds)); - auto waitEnd = std::chrono::high_resolution_clock::now(); - auto waitDurationMilliseconds = std::chrono::duration_cast(waitEnd - waitStart).count(); + //auto waitStart = std::chrono::high_resolution_clock::now(); + dispatch_semaphore_wait(sem_, dispatch_time(DISPATCH_TIME_NOW, MS_TO_NSEC * timeToWaitMilliseconds)); + //auto waitEnd = std::chrono::high_resolution_clock::now(); + //auto waitDurationMilliseconds = std::chrono::duration_cast(waitEnd - waitStart).count(); - AddedWaitDuration_ += waitDurationMilliseconds - timeToWaitMilliseconds; - if (AddedWaitDuration_ < 0) - { - AddedWaitDuration_ = 0; - } + //AddedWaitDuration_ += waitDurationMilliseconds - timeToWaitMilliseconds; + //if (AddedWaitDuration_ < 0) + //{ + // AddedWaitDuration_ = 0; + //} } void MacAudioDevice::clearHelperRealTime()