summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-02-10 04:14:33 +0100
committerGitHub <noreply@github.com>2023-02-10 04:14:33 +0100
commitc0b36c2d268f9fb25e88e1356530b95fbbc7656f (patch)
tree5d0f35f4bf0978168cfb6c17c0c05673d09330e2 /src
parentMerge pull request #9749 from ameerj/pr9559-partial-revert (diff)
parentaudio: cubeb: Fix yuzu crashing when it test for latency (diff)
downloadyuzu-c0b36c2d268f9fb25e88e1356530b95fbbc7656f.tar
yuzu-c0b36c2d268f9fb25e88e1356530b95fbbc7656f.tar.gz
yuzu-c0b36c2d268f9fb25e88e1356530b95fbbc7656f.tar.bz2
yuzu-c0b36c2d268f9fb25e88e1356530b95fbbc7656f.tar.lz
yuzu-c0b36c2d268f9fb25e88e1356530b95fbbc7656f.tar.xz
yuzu-c0b36c2d268f9fb25e88e1356530b95fbbc7656f.tar.zst
yuzu-c0b36c2d268f9fb25e88e1356530b95fbbc7656f.zip
Diffstat (limited to 'src')
-rw-r--r--src/audio_core/sink/cubeb_sink.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/audio_core/sink/cubeb_sink.cpp b/src/audio_core/sink/cubeb_sink.cpp
index 32c1b1cb3..9133f5388 100644
--- a/src/audio_core/sink/cubeb_sink.cpp
+++ b/src/audio_core/sink/cubeb_sink.cpp
@@ -302,11 +302,21 @@ std::vector<std::string> ListCubebSinkDevices(bool capture) {
std::vector<std::string> device_list;
cubeb* ctx;
+#ifdef _WIN32
+ auto com_init_result = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+#endif
+
if (cubeb_init(&ctx, "yuzu Device Enumerator", nullptr) != CUBEB_OK) {
LOG_CRITICAL(Audio_Sink, "cubeb_init failed");
return {};
}
+#ifdef _WIN32
+ if (SUCCEEDED(com_init_result)) {
+ CoUninitialize();
+ }
+#endif
+
auto type{capture ? CUBEB_DEVICE_TYPE_INPUT : CUBEB_DEVICE_TYPE_OUTPUT};
cubeb_device_collection collection;
if (cubeb_enumerate_devices(ctx, type, &collection) != CUBEB_OK) {
@@ -329,12 +339,22 @@ std::vector<std::string> ListCubebSinkDevices(bool capture) {
u32 GetCubebLatency() {
cubeb* ctx;
+#ifdef _WIN32
+ auto com_init_result = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+#endif
+
if (cubeb_init(&ctx, "yuzu Latency Getter", nullptr) != CUBEB_OK) {
LOG_CRITICAL(Audio_Sink, "cubeb_init failed");
// Return a large latency so we choose SDL instead.
return 10000u;
}
+#ifdef _WIN32
+ if (SUCCEEDED(com_init_result)) {
+ CoUninitialize();
+ }
+#endif
+
cubeb_stream_params params{};
params.rate = TargetSampleRate;
params.channels = 2;