mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] fix same memory leak issue
This commit is contained in:
@@ -548,7 +548,7 @@ int Render::AudioDeviceInit() {
|
|||||||
|
|
||||||
int Render::AudioDeviceDestroy() {
|
int Render::AudioDeviceDestroy() {
|
||||||
SDL_PauseAudioDevice(output_dev_, 1);
|
SDL_PauseAudioDevice(output_dev_, 1);
|
||||||
// SDL_CloseAudioDevice(output_dev_);
|
SDL_CloseAudioDevice(output_dev_);
|
||||||
// SDL_CloseAudioDevice(input_dev_);
|
// SDL_CloseAudioDevice(input_dev_);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1084,11 +1084,16 @@ void Render::Cleanup() {
|
|||||||
mouse_controller_ = nullptr;
|
mouse_controller_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyboard_capturer_) {
|
||||||
|
delete keyboard_capturer_;
|
||||||
|
keyboard_capturer_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
CleanupFactories();
|
CleanupFactories();
|
||||||
CleanupPeers();
|
CleanupPeers();
|
||||||
AudioDeviceDestroy();
|
AudioDeviceDestroy();
|
||||||
DestroyMainWindow();
|
|
||||||
DestroyMainWindowContext();
|
DestroyMainWindowContext();
|
||||||
|
DestroyMainWindow();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ constexpr pa_sample_format_t kFormat = PA_SAMPLE_S16LE;
|
|||||||
constexpr int kChannels = 1;
|
constexpr int kChannels = 1;
|
||||||
constexpr size_t kFrameSizeBytes = 480 * sizeof(int16_t);
|
constexpr size_t kFrameSizeBytes = 480 * sizeof(int16_t);
|
||||||
|
|
||||||
SpeakerCapturerLinux::SpeakerCapturerLinux() {}
|
SpeakerCapturerLinux::SpeakerCapturerLinux()
|
||||||
|
: inited_(false), paused_(false), stop_flag_(false) {}
|
||||||
SpeakerCapturerLinux::~SpeakerCapturerLinux() {
|
SpeakerCapturerLinux::~SpeakerCapturerLinux() {
|
||||||
Stop();
|
Stop();
|
||||||
Destroy();
|
Destroy();
|
||||||
@@ -42,36 +43,39 @@ std::string SpeakerCapturerLinux::GetDefaultMonitorSourceName() {
|
|||||||
pa_mainloop_api* api = pa_mainloop_get_api(mainloop);
|
pa_mainloop_api* api = pa_mainloop_get_api(mainloop);
|
||||||
pa_context* context = pa_context_new(api, "GetMonitor");
|
pa_context* context = pa_context_new(api, "GetMonitor");
|
||||||
|
|
||||||
|
struct CallbackState {
|
||||||
|
std::string* name;
|
||||||
|
std::mutex* mtx;
|
||||||
|
std::condition_variable* cv;
|
||||||
|
bool* ready;
|
||||||
|
} state{&monitor_name, &mtx, &cv, &ready};
|
||||||
|
|
||||||
pa_context_set_state_callback(
|
pa_context_set_state_callback(
|
||||||
context,
|
context,
|
||||||
[](pa_context* c, void* userdata) {
|
[](pa_context* c, void* userdata) {
|
||||||
auto* state =
|
auto* state = static_cast<CallbackState*>(userdata);
|
||||||
static_cast<std::tuple<std::string*, std::mutex*,
|
|
||||||
std::condition_variable*, bool*>*>(userdata);
|
|
||||||
if (pa_context_get_state(c) == PA_CONTEXT_READY) {
|
if (pa_context_get_state(c) == PA_CONTEXT_READY) {
|
||||||
pa_operation* o = pa_context_get_server_info(
|
pa_operation* operation = pa_context_get_server_info(
|
||||||
c,
|
c,
|
||||||
[](pa_context*, const pa_server_info* info, void* userdata) {
|
[](pa_context*, const pa_server_info* info, void* userdata) {
|
||||||
auto* state =
|
auto* state = static_cast<CallbackState*>(userdata);
|
||||||
static_cast<std::tuple<std::string*, std::mutex*,
|
|
||||||
std::condition_variable*, bool*>*>(
|
|
||||||
userdata);
|
|
||||||
if (info && info->default_sink_name) {
|
if (info && info->default_sink_name) {
|
||||||
*(std::get<0>(*state)) =
|
*(state->name) =
|
||||||
std::string(info->default_sink_name) + ".monitor";
|
std::string(info->default_sink_name) + ".monitor";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(*std::get<1>(*state));
|
std::lock_guard<std::mutex> lock(*(state->mtx));
|
||||||
*std::get<3>(*state) = true;
|
*(state->ready) = true;
|
||||||
}
|
}
|
||||||
std::get<2>(*state)->notify_one();
|
state->cv->notify_one();
|
||||||
},
|
},
|
||||||
userdata);
|
userdata);
|
||||||
if (o) pa_operation_unref(o);
|
if (operation) {
|
||||||
|
pa_operation_unref(operation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new std::tuple<std::string*, std::mutex*, std::condition_variable*,
|
&state);
|
||||||
bool*>(&monitor_name, &mtx, &cv, &ready));
|
|
||||||
|
|
||||||
pa_context_connect(context, nullptr, PA_CONTEXT_NOFLAGS, nullptr);
|
pa_context_connect(context, nullptr, PA_CONTEXT_NOFLAGS, nullptr);
|
||||||
|
|
||||||
|
|||||||
2
thirdparty/minirtc
vendored
2
thirdparty/minirtc
vendored
Submodule thirdparty/minirtc updated: c9f8859605...74c8e1062a
Reference in New Issue
Block a user