aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_audiounit.cpp
diff options
context:
space:
mode:
authorAlex Chronopoulos <[email protected]>2019-01-07 18:41:06 +0200
committerMatthew Gregan <[email protected]>2019-01-07 15:12:40 -0500
commitd9a32d7e54a27644226ae75a5f1f7538449b35bc (patch)
treeff9f0600bdfad995fe13d965fdb0f7aea4acb9c2 /src/cubeb_audiounit.cpp
parent8c3a32e9f48e9b968a2ae042f101d60f2ba9dd9c (diff)
downloadcubeb-d9a32d7e54a27644226ae75a5f1f7538449b35bc.tar.gz
cubeb-d9a32d7e54a27644226ae75a5f1f7538449b35bc.zip
audiounit: stop leaking after calling audiounit_create_device_from_hwdev. Fixes #482
Diffstat (limited to 'src/cubeb_audiounit.cpp')
-rw-r--r--src/cubeb_audiounit.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/cubeb_audiounit.cpp b/src/cubeb_audiounit.cpp
index e164039..6bf0e3d 100644
--- a/src/cubeb_audiounit.cpp
+++ b/src/cubeb_audiounit.cpp
@@ -1834,6 +1834,7 @@ static void audiounit_get_available_samplerate(AudioObjectID devid, AudioObjectP
uint32_t * min, uint32_t * max, uint32_t * def);
static int
audiounit_create_device_from_hwdev(cubeb_device_info * dev_info, AudioObjectID devid, cubeb_device_type type);
+static void audiounit_device_destroy(cubeb_device_info * device);
static void
audiounit_workaround_for_airpod(cubeb_stream * stm)
@@ -1879,6 +1880,8 @@ audiounit_workaround_for_airpod(cubeb_stream * stm)
LOG("Non fatal error, AudioObjectSetPropertyData/kAudioDevicePropertyNominalSampleRate, rv=%d", rv);
}
}
+ audiounit_device_destroy(&input_device_info);
+ audiounit_device_destroy(&output_device_info);
}
/*
@@ -3378,14 +3381,20 @@ audiounit_enumerate_devices(cubeb * /* context */, cubeb_device_type type,
return CUBEB_OK;
}
+static void
+audiounit_device_destroy(cubeb_device_info * device)
+{
+ delete [] device->device_id;
+ delete [] device->friendly_name;
+ delete [] device->vendor_name;
+}
+
static int
audiounit_device_collection_destroy(cubeb * /* context */,
cubeb_device_collection * collection)
{
for (size_t i = 0; i < collection->count; i++) {
- delete [] collection->device[i].device_id;
- delete [] collection->device[i].friendly_name;
- delete [] collection->device[i].vendor_name;
+ audiounit_device_destroy(&collection->device[i]);
}
delete [] collection->device;