Skip to content

Commit

Permalink
fix device name memory
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Aug 7, 2023
1 parent 9a14f62 commit e0ad322
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 15 additions & 5 deletions audio-monitor-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion buildspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@
}
},
"name": "audio-monitor",
"version": "0.8.2"
"version": "0.8.3"
}

0 comments on commit e0ad322

Please sign in to comment.