mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-30 02:32:46 +01:00
audio_core/cubeb_sink: Ensure COM is initialized on Windows prior to calling cubeb_init
cubeb now requires that COM explicitly be initialized on the thread prior to calling cubeb_init.
This commit is contained in:
parent
42f7c11021
commit
1068c1b06f
2 changed files with 19 additions and 0 deletions
|
@ -12,6 +12,10 @@
|
||||||
#include "common/ring_buffer.h"
|
#include "common/ring_buffer.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <objbase.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace AudioCore {
|
namespace AudioCore {
|
||||||
|
|
||||||
class CubebSinkStream final : public SinkStream {
|
class CubebSinkStream final : public SinkStream {
|
||||||
|
@ -108,6 +112,11 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
CubebSink::CubebSink(std::string_view target_device_name) {
|
CubebSink::CubebSink(std::string_view target_device_name) {
|
||||||
|
// Cubeb requires COM to be initialized on the thread calling cubeb_init on Windows
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
com_init_result = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (cubeb_init(&ctx, "yuzu", nullptr) != CUBEB_OK) {
|
if (cubeb_init(&ctx, "yuzu", nullptr) != CUBEB_OK) {
|
||||||
LOG_CRITICAL(Audio_Sink, "cubeb_init failed");
|
LOG_CRITICAL(Audio_Sink, "cubeb_init failed");
|
||||||
return;
|
return;
|
||||||
|
@ -142,6 +151,12 @@ CubebSink::~CubebSink() {
|
||||||
}
|
}
|
||||||
|
|
||||||
cubeb_destroy(ctx);
|
cubeb_destroy(ctx);
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
if (SUCCEEDED(com_init_result)) {
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SinkStream& CubebSink::AcquireSinkStream(u32 sample_rate, u32 num_channels,
|
SinkStream& CubebSink::AcquireSinkStream(u32 sample_rate, u32 num_channels,
|
||||||
|
|
|
@ -25,6 +25,10 @@ private:
|
||||||
cubeb* ctx{};
|
cubeb* ctx{};
|
||||||
cubeb_devid output_device{};
|
cubeb_devid output_device{};
|
||||||
std::vector<SinkStreamPtr> sink_streams;
|
std::vector<SinkStreamPtr> sink_streams;
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
u32 com_init_result = 0;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::string> ListCubebSinkDevices();
|
std::vector<std::string> ListCubebSinkDevices();
|
||||||
|
|
Loading…
Reference in a new issue