diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b867c317c..748b947d10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1044,10 +1044,14 @@ if(WIN32) set(HAVE_WASAPI 1) set(BACKENDS "${BACKENDS} WASAPI,") set(ALC_OBJS ${ALC_OBJS} alc/backends/wasapi.cpp alc/backends/wasapi.h) + + if(NOT ALSOFT_UWP) + set(EXTRA_LIBS avrt ${EXTRA_LIBS}) + endif() 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) 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" 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