mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
Merge pull request #9758 from german77/multi_audio
audio: cubeb: Fix yuzu crashing when it test for latency
This commit is contained in:
commit
c0b36c2d26
|
@ -302,11 +302,21 @@ std::vector<std::string> ListCubebSinkDevices(bool capture) {
|
||||||
std::vector<std::string> device_list;
|
std::vector<std::string> device_list;
|
||||||
cubeb* ctx;
|
cubeb* ctx;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
auto com_init_result = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (cubeb_init(&ctx, "yuzu Device Enumerator", nullptr) != CUBEB_OK) {
|
if (cubeb_init(&ctx, "yuzu Device Enumerator", nullptr) != CUBEB_OK) {
|
||||||
LOG_CRITICAL(Audio_Sink, "cubeb_init failed");
|
LOG_CRITICAL(Audio_Sink, "cubeb_init failed");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (SUCCEEDED(com_init_result)) {
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
auto type{capture ? CUBEB_DEVICE_TYPE_INPUT : CUBEB_DEVICE_TYPE_OUTPUT};
|
auto type{capture ? CUBEB_DEVICE_TYPE_INPUT : CUBEB_DEVICE_TYPE_OUTPUT};
|
||||||
cubeb_device_collection collection;
|
cubeb_device_collection collection;
|
||||||
if (cubeb_enumerate_devices(ctx, type, &collection) != CUBEB_OK) {
|
if (cubeb_enumerate_devices(ctx, type, &collection) != CUBEB_OK) {
|
||||||
|
@ -329,12 +339,22 @@ std::vector<std::string> ListCubebSinkDevices(bool capture) {
|
||||||
u32 GetCubebLatency() {
|
u32 GetCubebLatency() {
|
||||||
cubeb* ctx;
|
cubeb* ctx;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
auto com_init_result = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (cubeb_init(&ctx, "yuzu Latency Getter", nullptr) != CUBEB_OK) {
|
if (cubeb_init(&ctx, "yuzu Latency Getter", nullptr) != CUBEB_OK) {
|
||||||
LOG_CRITICAL(Audio_Sink, "cubeb_init failed");
|
LOG_CRITICAL(Audio_Sink, "cubeb_init failed");
|
||||||
// Return a large latency so we choose SDL instead.
|
// Return a large latency so we choose SDL instead.
|
||||||
return 10000u;
|
return 10000u;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (SUCCEEDED(com_init_result)) {
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
cubeb_stream_params params{};
|
cubeb_stream_params params{};
|
||||||
params.rate = TargetSampleRate;
|
params.rate = TargetSampleRate;
|
||||||
params.channels = 2;
|
params.channels = 2;
|
||||||
|
|
Loading…
Reference in a new issue