Browse Source

Initialize COM for capture cleanup and release completed leases

master
evgeny 4 days ago
parent
commit
de71617e9f
  1. 3
      tools/chatgui/CMakeLists.txt
  2. 11
      tools/chatgui/src/audio_capture.cpp
  3. 1
      tools/chatgui/src/stream_publish_engine.cpp

3
tools/chatgui/CMakeLists.txt

@ -164,6 +164,9 @@ add_library(chatgui_camera STATIC src/call_camera_capture.cpp src/call_camera_wo
target_link_libraries(chatgui_camera PUBLIC ${QT_LIBS} utun)
add_library(chatgui_audio_capture STATIC src/audio_capture.cpp)
target_link_libraries(chatgui_audio_capture PUBLIC ${QT_LIBS} utun)
if(WIN32)
target_link_libraries(chatgui_audio_capture PRIVATE ole32)
endif()
add_library(chatgui_stream_publish STATIC src/stream_publish_engine.cpp src/stream_publish_window.cpp src/call_video_engine.cpp)
target_link_libraries(chatgui_stream_publish PUBLIC chatgui_live_video chatgui_camera chatgui_audio_capture)
target_include_directories(chatgui_stream_publish PRIVATE ${CMAKE_SOURCE_DIR}/../../lib/libopus/include)

11
tools/chatgui/src/audio_capture.cpp

@ -6,6 +6,10 @@
#include <atomic>
#include <thread>
#include <vector>
#ifdef _WIN32
#include "platform_compat.h"
#include <objbase.h>
#endif
struct AudioCapture::Session {
struct Slot {
@ -156,7 +160,14 @@ void AudioCapture::closeAsync() {
DEBUG_INFO(DEBUG_CATEGORY_CALL, "capture: asynchronous close started shared=%d", session.use_count() > 1);
try {
m_closeThread = std::thread([this, session = std::move(session)]() mutable {
#ifdef _WIN32
HRESULT com = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
if (FAILED(com)) DEBUG_ERROR(DEBUG_CATEGORY_CALL, "capture: close worker COM init failed HRESULT=0x%08lx", (unsigned long)com);
#endif
session.reset();
#ifdef _WIN32
if (SUCCEEDED(com)) CoUninitialize();
#endif
DEBUG_INFO(DEBUG_CATEGORY_CALL, "capture: asynchronous close completed");
m_closeDone.store(true, std::memory_order_release);
});

1
tools/chatgui/src/stream_publish_engine.cpp

@ -738,6 +738,7 @@ void StreamPublishEngine::videoLoop(StreamPublishConfig initial) {
void StreamPublishEngine::tick() {
if (!active()) return;
if (!m->running && m_capture.closing()) return;
if (!m->running) m_microphone.release();
stream_publisher_status status;
if (!gui_stream_publish_status(m->id, status)) {
stop();

Loading…
Cancel
Save