* Timed waits -- avoid unfortunate worst cases
This commit is contained in:
@@ -966,6 +966,8 @@ RubberBandStretcher::Impl::process(const float *const *input, size_t samples, bo
|
|||||||
m_spaceAvailable.lock();
|
m_spaceAvailable.lock();
|
||||||
if (!allConsumed) {
|
if (!allConsumed) {
|
||||||
m_spaceAvailable.wait(500);
|
m_spaceAvailable.wait(500);
|
||||||
|
} else {
|
||||||
|
m_spaceAvailable.unlock();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ RubberBandStretcher::Impl::ProcessThread::run()
|
|||||||
|
|
||||||
m_s->m_dataAvailable.lock();
|
m_s->m_dataAvailable.lock();
|
||||||
if (!m_s->testInbufReadSpace(m_channel)) {
|
if (!m_s->testInbufReadSpace(m_channel)) {
|
||||||
m_s->m_dataAvailable.wait();
|
m_s->m_dataAvailable.wait(500);
|
||||||
} else {
|
} else {
|
||||||
m_s->m_dataAvailable.unlock();
|
m_s->m_dataAvailable.unlock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,15 @@
|
|||||||
|
|
||||||
#include "sysutils.h"
|
#include "sysutils.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#ifdef _WIN32
|
||||||
#include <string.h>
|
#else /* !_WIN32 */
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#else /* !__APPLE__, !_WIN32 */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#endif /* !__APPLE__, !_WIN32 */
|
||||||
|
#endif /* !_WIN32 */
|
||||||
|
|
||||||
namespace RubberBand {
|
namespace RubberBand {
|
||||||
|
|
||||||
@@ -31,6 +34,11 @@ system_is_multiprocessor()
|
|||||||
if (tested) return mp;
|
if (tested) return mp;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
//...
|
||||||
|
|
||||||
|
#else /* !_WIN32 */
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
||||||
size_t sz = sizeof(count);
|
size_t sz = sizeof(count);
|
||||||
@@ -40,7 +48,9 @@ system_is_multiprocessor()
|
|||||||
mp = (count > 1);
|
mp = (count > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else /* !__APPLE__, !_WIN32 */
|
||||||
|
|
||||||
|
//...
|
||||||
|
|
||||||
FILE *cpuinfo = fopen("/proc/cpuinfo", "r");
|
FILE *cpuinfo = fopen("/proc/cpuinfo", "r");
|
||||||
if (!cpuinfo) return false;
|
if (!cpuinfo) return false;
|
||||||
@@ -53,9 +63,11 @@ system_is_multiprocessor()
|
|||||||
}
|
}
|
||||||
if (count > 1) break;
|
if (count > 1) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(cpuinfo);
|
fclose(cpuinfo);
|
||||||
|
|
||||||
#endif
|
#endif /* !__APPLE__, !_WIN32 */
|
||||||
|
#endif /* !_WIN32 */
|
||||||
|
|
||||||
mp = (count > 1);
|
mp = (count > 1);
|
||||||
tested = true;
|
tested = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user