diff options
author | Deal(一线灵) <[email protected]> | 2023-05-31 15:24:11 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2023-05-31 07:24:11 +0000 |
commit | 3caadcf616074c6bedcd45e8af2854379f08e275 (patch) | |
tree | 1c82f3e74906393c1ba767c4e6c330190c308c5f /core | |
parent | cd27f8551dc593cc4fb29e1093ae45a57e6ca58e (diff) |
Improve wasapi backend UWP support (#853)
* Improve wasapi, support uwp build
* Fix compile errors
* [UWP] Support ReadALConfig from app roaming
* [UWP] Post disconnect event when default device changed
* [UWP] Fix appveyor ci
* [WIN32] Default device change notification support
* Fix warnings
* Add event to notify the app when the default device changes
- Event type: AL_EVENT_TYPE_DEFAULT_DEVICE_CHANGED_SOFT=0x19A7
- Event callback parameters:
void _onALSoftEvent(ALenum eventType,
ALuint object, // dataFlow: 0(render), 1(capture)
ALuint param, // 0
ALsizei length, // 0
const ALchar* message, // Default device changed:<deviceId>
void* userParam);
* Fix warnings
* Fire default device changed event in mixerProc thread
* Fix compile warning
* [UWP] Improve cmake
* Revert changes
* Notify default device change by system event callback
* Revert insignificant change
* Remove duplicate call
Diffstat (limited to 'core')
-rw-r--r-- | core/async_event.h | 1 | ||||
-rw-r--r-- | core/helpers.cpp | 25 | ||||
-rw-r--r-- | core/uiddefs.cpp | 2 |
3 files changed, 22 insertions, 6 deletions
diff --git a/core/async_event.h b/core/async_event.h index c049fa02..f1ca0c7b 100644 --- a/core/async_event.h +++ b/core/async_event.h @@ -15,7 +15,6 @@ enum class AsyncEnableBits : uint8_t { SourceState, BufferCompleted, Disconnected, - Count }; diff --git a/core/helpers.cpp b/core/helpers.cpp index 58cc74e5..f9de25cf 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -3,6 +3,11 @@ #include "helpers.h" +#if defined(_WIN32) +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#endif + #include <algorithm> #include <cerrno> #include <cstdarg> @@ -40,7 +45,7 @@ const PathNamePair &GetProcBinary() { static std::optional<PathNamePair> procbin; if(procbin) return *procbin; - +#if !defined(ALSOFT_UWP) auto fullpath = std::vector<WCHAR>(256); DWORD len{GetModuleFileNameW(nullptr, fullpath.data(), static_cast<DWORD>(fullpath.size()))}; while(len == fullpath.size()) @@ -58,7 +63,16 @@ const PathNamePair &GetProcBinary() fullpath.resize(len); if(fullpath.back() != 0) fullpath.push_back(0); - +#else + auto exePath = __wargv[0]; + if (!exePath) + { + ERR("Failed to get process name: error %lu\n", GetLastError()); + procbin.emplace(); + return *procbin; + } + std::vector<WCHAR> fullpath{exePath, exePath + wcslen(exePath) + 1}; +#endif std::replace(fullpath.begin(), fullpath.end(), '/', '\\'); auto sep = std::find(fullpath.rbegin()+1, fullpath.rend(), '\\'); if(sep != fullpath.rend()) @@ -84,7 +98,7 @@ void DirectorySearch(const char *path, const char *ext, std::vector<std::string> std::wstring wpath{utf8_to_wstr(pathstr.c_str())}; WIN32_FIND_DATAW fdata; - HANDLE hdl{FindFirstFileW(wpath.c_str(), &fdata)}; + HANDLE hdl{FindFirstFileExW(wpath.c_str(), FindExInfoStandard, &fdata, FindExSearchNameMatch, NULL, 0)}; if(hdl == INVALID_HANDLE_VALUE) return; const auto base = results->size(); @@ -97,7 +111,6 @@ void DirectorySearch(const char *path, const char *ext, std::vector<std::string> str += wstr_to_utf8(fdata.cFileName); } while(FindNextFileW(hdl, &fdata)); FindClose(hdl); - const al::span<std::string> newlist{results->data()+base, results->size()-base}; std::sort(newlist.begin(), newlist.end()); for(const auto &name : newlist) @@ -149,6 +162,7 @@ std::vector<std::string> SearchDataFiles(const char *ext, const char *subdir) std::replace(path.begin(), path.end(), '/', '\\'); DirectorySearch(path.c_str(), ext, &results); +#if !defined(ALSOFT_UWP) /* Search the local and global data dirs. */ static const int ids[2]{ CSIDL_APPDATA, CSIDL_COMMON_APPDATA }; for(int id : ids) @@ -165,17 +179,20 @@ std::vector<std::string> SearchDataFiles(const char *ext, const char *subdir) DirectorySearch(path.c_str(), ext, &results); } +#endif return results; } void SetRTPriority(void) { +#if !defined(ALSOFT_UWP) if(RTPrioLevel > 0) { if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)) ERR("Failed to set priority level for thread\n"); } +#endif } #else diff --git a/core/uiddefs.cpp b/core/uiddefs.cpp index 244c01a5..833150f5 100644 --- a/core/uiddefs.cpp +++ b/core/uiddefs.cpp @@ -24,7 +24,7 @@ DEFINE_GUID(IID_IAudioClient, 0x1cb9ad4c, 0xdbfa, 0x4c32, 0xb1,0x78, 0xc DEFINE_GUID(IID_IAudioRenderClient, 0xf294acfc, 0x3146, 0x4483, 0xa7,0xbf, 0xad,0xdc,0xa7,0xc2,0x60,0xe2); DEFINE_GUID(IID_IAudioCaptureClient, 0xc8adbd64, 0xe71e, 0x48a0, 0xa4,0xde, 0x18,0x5c,0x39,0x5c,0xd3,0x17); -#ifdef HAVE_WASAPI +#if defined(HAVE_WASAPI) && !defined(ALSOFT_UWP) #include <wtypes.h> #include <devpropdef.h> #include <propkeydef.h> |