@geastack/host 0.1.20 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/host/audio_worklet.cpp +19 -0
- package/package.json +1 -1
package/host/audio_worklet.cpp
CHANGED
|
@@ -20,6 +20,15 @@
|
|
|
20
20
|
#else
|
|
21
21
|
#include <thread>
|
|
22
22
|
#endif
|
|
23
|
+
#if defined(_WIN32) && !defined(ESP_PLATFORM)
|
|
24
|
+
#ifndef NOMINMAX
|
|
25
|
+
#define NOMINMAX
|
|
26
|
+
#endif
|
|
27
|
+
#ifndef WIN32_LEAN_AND_MEAN
|
|
28
|
+
#define WIN32_LEAN_AND_MEAN
|
|
29
|
+
#endif
|
|
30
|
+
#include <windows.h>
|
|
31
|
+
#endif
|
|
23
32
|
|
|
24
33
|
namespace gea::host::audio_worklet {
|
|
25
34
|
namespace {
|
|
@@ -337,6 +346,16 @@ struct ContextState : std::enable_shared_from_this<ContextState> {
|
|
|
337
346
|
// This entry owns its periodic render loop; runPending services only its
|
|
338
347
|
// bounded messages between process calls, never on the UI or mixer task.
|
|
339
348
|
realm->start([self] {
|
|
349
|
+
#if defined(_WIN32) && !defined(ESP_PLATFORM)
|
|
350
|
+
// The render loop is the graph's audio clock, which ESP runs at its top
|
|
351
|
+
// task priority (above). Windows would leave it at normal priority, and
|
|
352
|
+
// it does not favour a thread waking from its 1 ms sleep over ready
|
|
353
|
+
// threads of equal priority: on a busy host every wake queued behind
|
|
354
|
+
// them, the loop fell seconds behind its quanta and capture overran.
|
|
355
|
+
// Time-critical is the level Windows audio engines give render threads;
|
|
356
|
+
// the bounded batch and the sleep below still yield every iteration.
|
|
357
|
+
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
|
|
358
|
+
#endif
|
|
340
359
|
active = self.get();
|
|
341
360
|
{ std::lock_guard lock(self->readyMutex); self->ready = true; }
|
|
342
361
|
self->readySignal.notify_all();
|