Revert previous changes as they didn't help.
parent
4a80fa9496
commit
b94815abfa
|
@ -89,7 +89,6 @@ private:
|
||||||
static thread_local void* Workgroup_;
|
static thread_local void* Workgroup_;
|
||||||
static thread_local void* JoinToken_;
|
static thread_local void* JoinToken_;
|
||||||
static thread_local int CurrentCoreAudioId_;
|
static thread_local int CurrentCoreAudioId_;
|
||||||
std::atomic<int> numRealTimeThreads_;
|
|
||||||
|
|
||||||
static int DeviceIsAliveCallback_(
|
static int DeviceIsAliveCallback_(
|
||||||
AudioObjectID inObjectID,
|
AudioObjectID inObjectID,
|
||||||
|
|
|
@ -261,10 +261,7 @@ void MacAudioDevice::start()
|
||||||
onAudioDataFunction(*this, inputFrames_, frameCount, onAudioDataState);
|
onAudioDataFunction(*this, inputFrames_, frameCount, onAudioDataState);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto count = 0; count < numRealTimeThreads_; count++)
|
dispatch_semaphore_signal(sem_);
|
||||||
{
|
|
||||||
dispatch_semaphore_signal(sem_);
|
|
||||||
}
|
|
||||||
|
|
||||||
return OSStatus(noErr);
|
return OSStatus(noErr);
|
||||||
};
|
};
|
||||||
|
@ -638,8 +635,6 @@ void MacAudioDevice::setHelperRealTime()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
numRealTimeThreads_++;
|
|
||||||
|
|
||||||
// Going real-time is a prerequisite for joining workgroups
|
// Going real-time is a prerequisite for joining workgroups
|
||||||
joinWorkgroup_();
|
joinWorkgroup_();
|
||||||
}
|
}
|
||||||
|
@ -719,7 +714,6 @@ void MacAudioDevice::stopRealTimeWork()
|
||||||
void MacAudioDevice::clearHelperRealTime()
|
void MacAudioDevice::clearHelperRealTime()
|
||||||
{
|
{
|
||||||
leaveWorkgroup_();
|
leaveWorkgroup_();
|
||||||
numRealTimeThreads_--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacAudioDevice::leaveWorkgroup_()
|
void MacAudioDevice::leaveWorkgroup_()
|
||||||
|
|
|
@ -245,7 +245,6 @@ void PulseAudioDevice::setHelperRealTime()
|
||||||
sigaddset(&signal_set, SIGXCPU);
|
sigaddset(&signal_set, SIGXCPU);
|
||||||
sigprocmask(SIG_UNBLOCK, &signal_set, NULL);
|
sigprocmask(SIG_UNBLOCK, &signal_set, NULL);
|
||||||
#endif // 0
|
#endif // 0
|
||||||
numRealTimeThreads_++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PulseAudioDevice::startRealTimeWork()
|
void PulseAudioDevice::startRealTimeWork()
|
||||||
|
@ -301,7 +300,6 @@ void PulseAudioDevice::stopRealTimeWork()
|
||||||
void PulseAudioDevice::clearHelperRealTime()
|
void PulseAudioDevice::clearHelperRealTime()
|
||||||
{
|
{
|
||||||
IAudioDevice::clearHelperRealTime();
|
IAudioDevice::clearHelperRealTime();
|
||||||
numRealTimeThreads_--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PulseAudioDevice::mustStopWork()
|
bool PulseAudioDevice::mustStopWork()
|
||||||
|
@ -326,11 +324,7 @@ void PulseAudioDevice::StreamReadCallback_(pa_stream *s, size_t length, void *us
|
||||||
{
|
{
|
||||||
thisObj->onAudioDataFunction(*thisObj, const_cast<void*>(data), length / thisObj->getNumChannels() / sizeof(short), thisObj->onAudioDataState);
|
thisObj->onAudioDataFunction(*thisObj, const_cast<void*>(data), length / thisObj->getNumChannels() / sizeof(short), thisObj->onAudioDataState);
|
||||||
}
|
}
|
||||||
|
sem_post(&thisObj->sem_);
|
||||||
for (auto count = 0; count < thisObj->numRealTimeThreads_; count++)
|
|
||||||
{
|
|
||||||
sem_post(&thisObj->sem_);
|
|
||||||
}
|
|
||||||
pa_stream_drop(s);
|
pa_stream_drop(s);
|
||||||
} while (pa_stream_readable_size(s) > 0);
|
} while (pa_stream_readable_size(s) > 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <pulse/pulseaudio.h>
|
#include <pulse/pulseaudio.h>
|
||||||
|
@ -87,7 +86,6 @@ private:
|
||||||
|
|
||||||
thread_local static std::chrono::high_resolution_clock::time_point StartTime_;
|
thread_local static std::chrono::high_resolution_clock::time_point StartTime_;
|
||||||
thread_local static bool MustStopWork_;
|
thread_local static bool MustStopWork_;
|
||||||
std::atomic<int> numRealTimeThreads_;
|
|
||||||
|
|
||||||
sem_t sem_;
|
sem_t sem_;
|
||||||
struct timespec ts_;
|
struct timespec ts_;
|
||||||
|
|
|
@ -257,7 +257,7 @@ void WASAPIAudioDevice::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create semaphore
|
// Create semaphore
|
||||||
semaphore_ = CreateSemaphore(nullptr, 0, 1000, nullptr);
|
semaphore_ = CreateSemaphore(nullptr, 0, 1, nullptr);
|
||||||
if (semaphore_ == nullptr)
|
if (semaphore_ == nullptr)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -407,10 +407,7 @@ void WASAPIAudioDevice::stop()
|
||||||
// occurs!
|
// occurs!
|
||||||
auto tmpSem = semaphore_;
|
auto tmpSem = semaphore_;
|
||||||
semaphore_ = nullptr;
|
semaphore_ = nullptr;
|
||||||
for (auto count = 0; count < numRealTimeThreads_; count++)
|
ReleaseSemaphore(tmpSem, 1, nullptr);
|
||||||
{
|
|
||||||
ReleaseSemaphore(tmpSem, 1, nullptr);
|
|
||||||
}
|
|
||||||
CloseHandle(tmpSem);
|
CloseHandle(tmpSem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,8 +436,6 @@ void WASAPIAudioDevice::setHelperRealTime()
|
||||||
{
|
{
|
||||||
log_warn("Could not increase thread priority");
|
log_warn("Could not increase thread priority");
|
||||||
}
|
}
|
||||||
|
|
||||||
numRealTimeThreads_++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WASAPIAudioDevice::startRealTimeWork()
|
void WASAPIAudioDevice::startRealTimeWork()
|
||||||
|
@ -469,8 +464,6 @@ void WASAPIAudioDevice::stopRealTimeWork()
|
||||||
|
|
||||||
void WASAPIAudioDevice::clearHelperRealTime()
|
void WASAPIAudioDevice::clearHelperRealTime()
|
||||||
{
|
{
|
||||||
numRealTimeThreads_--;
|
|
||||||
|
|
||||||
if (HelperTask_ != nullptr)
|
if (HelperTask_ != nullptr)
|
||||||
{
|
{
|
||||||
AvRevertMmThreadCharacteristics(HelperTask_);
|
AvRevertMmThreadCharacteristics(HelperTask_);
|
||||||
|
@ -621,9 +614,6 @@ void WASAPIAudioDevice::captureAudio_()
|
||||||
if (semaphore_ != nullptr)
|
if (semaphore_ != nullptr)
|
||||||
{
|
{
|
||||||
// Notify worker threads
|
// Notify worker threads
|
||||||
for (auto count = 0; count < numRealTimeThreads_; count++)
|
ReleaseSemaphore(semaphore_, 1, nullptr);
|
||||||
{
|
|
||||||
ReleaseSemaphore(semaphore_, 1, nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@ private:
|
||||||
HANDLE renderCaptureEvent_;
|
HANDLE renderCaptureEvent_;
|
||||||
bool isRenderCaptureRunning_;
|
bool isRenderCaptureRunning_;
|
||||||
HANDLE semaphore_;
|
HANDLE semaphore_;
|
||||||
std::atomic<int> numRealTimeThreads_;
|
|
||||||
|
|
||||||
void renderAudio_();
|
void renderAudio_();
|
||||||
void captureAudio_();
|
void captureAudio_();
|
||||||
|
|
Loading…
Reference in New Issue