From e0ad3226d9ca01ad3a01976fa01cbdda053afde3 Mon Sep 17 00:00:00 2001 From: Exeldro Date: Mon, 7 Aug 2023 10:56:31 +0200 Subject: [PATCH] fix device name memory --- CMakeLists.txt | 2 +- audio-monitor-filter.c | 20 +++++++++++++++----- buildspec.json | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79b226e..774d569 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ else() cmake_minimum_required(VERSION 3.18) endif() -project(audio-monitor VERSION 0.8.2) +project(audio-monitor VERSION 0.8.3) set(PROJECT_FULL_NAME "Audio Monitor") # Set new UUIDs when you start to create a new plugin. diff --git a/audio-monitor-filter.c b/audio-monitor-filter.c index 1cf01f9..61fbee3 100644 --- a/audio-monitor-filter.c +++ b/audio-monitor-filter.c @@ -28,14 +28,14 @@ static const char *audio_monitor_get_name(void *unused) struct updateFilterNameData { const char *device_id; - const char *device_name; + char *device_name; }; bool updateFilterName(void *data, const char *name, const char *id) { struct updateFilterNameData *d = data; if (strcmp(id, d->device_id) == 0) { - d->device_name = name; + d->device_name = bstrdup(name); return false; } return true; @@ -266,11 +266,21 @@ static void audio_monitor_update(void *data, obs_data_t *settings) d.device_name = NULL; obs_enum_audio_monitoring_devices(updateFilterName, &d); if (d.device_name) { - obs_data_set_string(settings, "deviceName", - d.device_name); + const char *dn = obs_data_get_string( + settings, "deviceName"); + if (strcmp(dn, d.device_name) != 0) { + obs_data_set_string(settings, + "deviceName", + d.device_name); + } + bfree(d.device_name); } } else { - obs_data_set_string(settings, "deviceName", device_id); + const char *dn = + obs_data_get_string(settings, "deviceName"); + if (strcmp(dn, device_id) != 0) + obs_data_set_string(settings, "deviceName", + device_id); } struct audio_monitor *old = audio_monitor->monitor; audio_monitor->monitor = NULL; diff --git a/buildspec.json b/buildspec.json index b455aa4..3d71e76 100644 --- a/buildspec.json +++ b/buildspec.json @@ -79,5 +79,5 @@ } }, "name": "audio-monitor", - "version": "0.8.2" + "version": "0.8.3" }