Remove dependency on a library for a single function
This commit is contained in:
parent
c71d2739b1
commit
753f57c71b
7 changed files with 31 additions and 5 deletions
|
|
@ -71,7 +71,6 @@ if(WIN32)
|
||||||
wsock32
|
wsock32
|
||||||
ws2_32
|
ws2_32
|
||||||
iphlpapi
|
iphlpapi
|
||||||
windowsapp
|
|
||||||
d3d11 dxgi
|
d3d11 dxgi
|
||||||
setupapi
|
setupapi
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
proc::proc = std::move(*proc_opt);
|
proc::proc = std::move(*proc_opt);
|
||||||
|
|
||||||
|
auto deinit_guard = platf::init();
|
||||||
reed_solomon_init();
|
reed_solomon_init();
|
||||||
|
|
||||||
task_pool.start(1);
|
task_pool.start(1);
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,11 @@ struct gamepad_state_t {
|
||||||
std::int16_t rsY;
|
std::int16_t rsY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class deinit_t {
|
||||||
|
public:
|
||||||
|
virtual ~deinit_t() = default;
|
||||||
|
};
|
||||||
|
|
||||||
struct img_t {
|
struct img_t {
|
||||||
public:
|
public:
|
||||||
std::uint8_t *data {};
|
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);
|
int alloc_gamepad(input_t &input, int nr);
|
||||||
void free_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
|
#endif //SUNSHINE_COMMON_H
|
||||||
|
|
|
||||||
|
|
@ -501,4 +501,6 @@ void freeInput(void *p) {
|
||||||
auto *input = (input_raw_t*)p;
|
auto *input = (input_raw_t*)p;
|
||||||
delete input;
|
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 wave_format_t = util::safe_ptr<WAVEFORMATEX, co_task_free<WAVEFORMATEX>>;
|
||||||
using handle_t = util::safe_ptr_v2<void, BOOL, CloseHandle>;
|
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 {
|
class mic_wasapi_t : public mic_t {
|
||||||
public:
|
public:
|
||||||
capture_e sample(std::vector<std::int16_t> &sample_in) override {
|
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) {
|
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>();
|
auto mic = std::make_unique<audio::mic_wasapi_t>();
|
||||||
|
|
||||||
if(mic->init(sample_rate)) {
|
if(mic->init(sample_rate)) {
|
||||||
|
|
@ -326,4 +336,8 @@ std::unique_ptr<mic_t> microphone(std::uint32_t sample_rate) {
|
||||||
|
|
||||||
return mic;
|
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
|
target_link_libraries(audio-info
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
ksuser
|
ksuser
|
||||||
windowsapp
|
|
||||||
${PLATFORM_LIBRARIES})
|
${PLATFORM_LIBRARIES})
|
||||||
target_compile_options(audio-info PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
|
target_compile_options(audio-info PRIVATE ${SUNSHINE_COMPILE_OPTIONS})
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,12 @@ void print_help() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_SPEED_OVER_MEMORY);
|
||||||
|
|
||||||
|
auto fg = util::fail_guard([]() {
|
||||||
|
CoUninitialize();
|
||||||
|
});
|
||||||
|
|
||||||
if(argc > 1) {
|
if(argc > 1) {
|
||||||
device_state_filter = 0;
|
device_state_filter = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -205,8 +211,6 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
|
|
||||||
|
|
||||||
HRESULT status;
|
HRESULT status;
|
||||||
|
|
||||||
audio::device_enum_t::pointer device_enum_p{};
|
audio::device_enum_t::pointer device_enum_p{};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue