mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-01-30 12:32:43 +00:00
Remove dependency on a library for a single function
This commit is contained in:
parent
c71d2739b1
commit
753f57c71b
@ -71,7 +71,6 @@ if(WIN32)
|
||||
wsock32
|
||||
ws2_32
|
||||
iphlpapi
|
||||
windowsapp
|
||||
d3d11 dxgi
|
||||
setupapi
|
||||
)
|
||||
|
@ -126,6 +126,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
proc::proc = std::move(*proc_opt);
|
||||
|
||||
auto deinit_guard = platf::init();
|
||||
reed_solomon_init();
|
||||
|
||||
task_pool.start(1);
|
||||
|
@ -37,6 +37,11 @@ struct gamepad_state_t {
|
||||
std::int16_t rsY;
|
||||
};
|
||||
|
||||
class deinit_t {
|
||||
public:
|
||||
virtual ~deinit_t() = default;
|
||||
};
|
||||
|
||||
struct img_t {
|
||||
public:
|
||||
std::uint8_t *data {};
|
||||
@ -93,6 +98,8 @@ void gamepad(input_t &input, int nr, const gamepad_state_t &gamepad_state);
|
||||
|
||||
int alloc_gamepad(input_t &input, int nr);
|
||||
void free_gamepad(input_t &input, int nr);
|
||||
|
||||
[[nodiscard]] std::unique_ptr<deinit_t> init();
|
||||
}
|
||||
|
||||
#endif //SUNSHINE_COMMON_H
|
||||
|
@ -501,4 +501,6 @@ void freeInput(void *p) {
|
||||
auto *input = (input_raw_t*)p;
|
||||
delete input;
|
||||
}
|
||||
|
||||
std::unique_ptr<deinit_t> init() { return nullptr; }
|
||||
}
|
||||
|
@ -38,6 +38,17 @@ using audio_capture_t = util::safe_ptr<IAudioCaptureClient, Release<IAudioCaptur
|
||||
using wave_format_t = util::safe_ptr<WAVEFORMATEX, co_task_free<WAVEFORMATEX>>;
|
||||
using handle_t = util::safe_ptr_v2<void, BOOL, CloseHandle>;
|
||||
|
||||
class co_init_t : public deinit_t {
|
||||
public:
|
||||
co_init_t() {
|
||||
CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY);
|
||||
}
|
||||
|
||||
~co_init_t() override {
|
||||
CoUninitialize();
|
||||
}
|
||||
};
|
||||
|
||||
class mic_wasapi_t : public mic_t {
|
||||
public:
|
||||
capture_e sample(std::vector<std::int16_t> &sample_in) override {
|
||||
@ -317,7 +328,6 @@ public:
|
||||
};
|
||||
|
||||
std::unique_ptr<mic_t> microphone(std::uint32_t sample_rate) {
|
||||
Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
|
||||
auto mic = std::make_unique<audio::mic_wasapi_t>();
|
||||
|
||||
if(mic->init(sample_rate)) {
|
||||
@ -326,4 +336,8 @@ std::unique_ptr<mic_t> microphone(std::uint32_t sample_rate) {
|
||||
|
||||
return mic;
|
||||
}
|
||||
|
||||
std::unique_ptr<deinit_t> init() {
|
||||
return std::make_unique<platf::audio::co_init_t>();
|
||||
}
|
||||
}
|
@ -17,6 +17,5 @@ set_target_properties(audio-info PROPERTIES CXX_STANDARD 17)
|
||||
target_link_libraries(audio-info
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
ksuser
|
||||
windowsapp
|
||||
${PLATFORM_LIBRARIES})
|
||||
target_compile_options(audio-info PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
|
||||
|
@ -172,6 +172,12 @@ void print_help() {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY);
|
||||
|
||||
auto fg = util::fail_guard([]() {
|
||||
CoUninitialize();
|
||||
});
|
||||
|
||||
if(argc > 1) {
|
||||
device_state_filter = 0;
|
||||
}
|
||||
@ -205,8 +211,6 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
|
||||
|
||||
HRESULT status;
|
||||
|
||||
audio::device_enum_t::pointer device_enum_p{};
|
||||
|
Loading…
x
Reference in New Issue
Block a user