Revert "avoid pessimizing audio slave lock contention"

This reverts commit 3508e71753.
This commit is contained in:
Zach Pomerantz 2016-12-08 14:10:00 -05:00
parent 3508e71753
commit eafbeb6d44

View file

@ -27,7 +27,7 @@ void AudioMixerSlaveThread::run() {
bool stopping = _stop; bool stopping = _stop;
notify(stopping); notify(stopping);
if (stopping) { if (stopping) {
break; return;
} }
} }
} }
@ -80,13 +80,14 @@ void AudioMixerSlavePool::mix(ConstIter begin, ConstIter end, unsigned int frame
_queue.emplace(node); _queue.emplace(node);
}); });
// mix
_numStarted = _numFinished = 0;
_slaveCondition.notify_all();
// wait
{ {
Lock lock(_mutex); Lock lock(_mutex);
// mix
_numStarted = _numFinished = 0;
_slaveCondition.notify_all();
// wait
_poolCondition.wait(lock, [&] { _poolCondition.wait(lock, [&] {
assert(_numFinished <= _numThreads); assert(_numFinished <= _numThreads);
return _numFinished == _numThreads; return _numFinished == _numThreads;
@ -153,12 +154,12 @@ void AudioMixerSlavePool::resize(int numThreads) {
} }
// ...cycle them until they do stop... // ...cycle them until they do stop...
_numStopped = 0; {
while (_numStopped != (_numThreads - numThreads)) { Lock lock(_mutex);
_numStarted = _numFinished = _numStopped; _numStopped = 0;
_slaveCondition.notify_all(); while (_numStopped != (_numThreads - numThreads)) {
{ _numStarted = _numFinished = _numStopped;
Lock lock(_mutex); _slaveCondition.notify_all();
_poolCondition.wait(lock, [&] { _poolCondition.wait(lock, [&] {
assert(_numFinished <= _numThreads); assert(_numFinished <= _numThreads);
return _numFinished == _numThreads; return _numFinished == _numThreads;