output/alsa: use a new I/O thread with real-time scheduling
The normal I/O event thread can have a large latency, e.g. when libgnutls loads all TLS CA certificates for a https connect. This makes it unreliable for the ALSA I/O notifications, and causes ring buffer xruns. To avoid interfering with high latency events such as CURL's, we move the ALSA I/O events to a separate I/O thread which also obtains real-time scheduling (if possible). Closes #221
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
#include "config.h"
|
||||
#include "Thread.hxx"
|
||||
#include "thread/Name.hxx"
|
||||
#include "thread/Util.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
void
|
||||
EventThread::Start()
|
||||
@@ -41,7 +43,16 @@ EventThread::Stop() noexcept
|
||||
void
|
||||
EventThread::Run() noexcept
|
||||
{
|
||||
SetThreadName("io");
|
||||
SetThreadName(realtime ? "rtio" : "io");
|
||||
|
||||
if (realtime) {
|
||||
try {
|
||||
SetThreadRealtime();
|
||||
} catch (...) {
|
||||
LogError(std::current_exception(),
|
||||
"RTIOThread could not get realtime scheduling, continuing anyway");
|
||||
}
|
||||
}
|
||||
|
||||
event_loop.Run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user