From bfa7a7f7c8c44e7f9d47d1cebbd3d82a6e468c14 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 17 Aug 2024 21:49:13 -0700 Subject: [PATCH 1/4] Disable building the OtherIO backend by default It's incomplete, and I'm not sure what I'm going to do with it yet. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b867c317c..ee0356cf0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1047,7 +1047,7 @@ if(WIN32) endif() endif() - option(ALSOFT_BACKEND_OTHERIO "Enable OtherIO backend" ON) + option(ALSOFT_BACKEND_OTHERIO "Enable OtherIO backend" OFF) option(ALSOFT_REQUIRE_OTHERIO "Require OtherIO backend" OFF) if(ALSOFT_BACKEND_OTHERIO) set(HAVE_OTHERIO 1) From c68b793e061a0e8464dbe19bff400a116286a8d8 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 18 Aug 2024 22:10:28 -0700 Subject: [PATCH 2/4] Load libjack64.dll on Win64 --- alc/backends/jack.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp index d8c567c59b..f42d2662fd 100644 --- a/alc/backends/jack.cpp +++ b/alc/backends/jack.cpp @@ -111,7 +111,9 @@ bool jack_load() #ifdef HAVE_DYNLOAD if(!jack_handle) { -#ifdef _WIN32 +#if defined(_WIN64) +#define JACKLIB "libjack64.dll" +#elif defined(_WIN32) #define JACKLIB "libjack.dll" #else #define JACKLIB "libjack.so.0" From c0e5532a3748878238f4e5931df95e4e7e258968 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 20 Aug 2024 18:06:25 -0700 Subject: [PATCH 3/4] Call AvSetMmThreadCharacteristicsW on the WASAPI mixing threads --- CMakeLists.txt | 5 +++++ alc/backends/wasapi.cpp | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee0356cf0c..5cc9680a11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1044,6 +1044,11 @@ if(WIN32) set(HAVE_WASAPI 1) set(BACKENDS "${BACKENDS} WASAPI,") set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h) + + find_library(AVRT_LIBRARY NAMES avrt DOC "The AVRT library") + if(AVRT_LIBRARY) + set(EXTRA_LIBS ${AVRT_LIBRARY} ${EXTRA_LIBS}) + endif() endif() endif() diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 0e51996b7c..bccecacfd0 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -319,6 +320,13 @@ struct DeviceListLock : public std::unique_lock { DeviceList gDeviceList; +#ifdef AVRTAPI +struct AvrtHandleCloser { + void operator()(HANDLE handle) { AvRevertMmThreadCharacteristics(handle); } +}; +using AvrtHandlePtr = std::unique_ptr,AvrtHandleCloser>; +#endif + #if defined(ALSOFT_UWP) enum EDataFlow { eRender = 0, @@ -968,6 +976,7 @@ struct WasapiProxy { static inline std::deque mMsgQueue; static inline std::mutex mMsgQueueLock; static inline std::condition_variable mMsgQueueCond; + static inline DWORD sAvIndex{}; static inline std::optional sDeviceHelper; @@ -1169,6 +1178,15 @@ FORCE_ALIGN int WasapiPlayback::mixerProc() const UINT32 buffer_len{mOrigBufferSize}; const void *resbufferptr{}; +#ifdef AVRTAPI + /* TODO: "Audio" or "Pro Audio"? The suggestion is to use "Pro Audio" for + * device periods less than 10ms, and "Audio" for greater than or equal to + * 10ms. + */ + auto taskname = (update_size < mFormat.Format.nSamplesPerSec/100) ? L"Pro Audio" : L"Audio"; + auto avhandle = AvrtHandlePtr{AvSetMmThreadCharacteristicsW(taskname, &sAvIndex)}; +#endif + mBufferFilled = 0; while(!mKillNow.load(std::memory_order_relaxed)) { @@ -1257,6 +1275,11 @@ FORCE_ALIGN int WasapiPlayback::mixerSpatialProc() std::vector resbuffers; std::vector tmpbuffers; +#ifdef AVRTAPI + auto taskname = (mOrigUpdateSize Date: Tue, 20 Aug 2024 21:04:41 -0700 Subject: [PATCH 4/4] Don't explicitly search for avrt --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cc9680a11..748b947d10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1045,9 +1045,8 @@ if(WIN32) set(BACKENDS "${BACKENDS} WASAPI,") set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h) - find_library(AVRT_LIBRARY NAMES avrt DOC "The AVRT library") - if(AVRT_LIBRARY) - set(EXTRA_LIBS ${AVRT_LIBRARY} ${EXTRA_LIBS}) + if(NOT ALSOFT_UWP) + set(EXTRA_LIBS avrt ${EXTRA_LIBS}) endif() endif() endif()