|
@@ -506,7 +506,8 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {
|
|
|
|
|
|
UInt32 size = 0;
|
|
UInt32 size = 0;
|
|
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, nullptr, &size);
|
|
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, nullptr, &size);
|
|
- AudioDeviceID *audioDevices = (AudioDeviceID *)malloc(size);
|
|
|
|
|
|
+ AudioDeviceID *audioDevices = (AudioDeviceID *)memalloc(size);
|
|
|
|
+ ERR_FAIL_NULL_V_MSG(audioDevices, list, "Out of memory.");
|
|
AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, nullptr, &size, audioDevices);
|
|
AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, nullptr, &size, audioDevices);
|
|
|
|
|
|
UInt32 deviceCount = size / sizeof(AudioDeviceID);
|
|
UInt32 deviceCount = size / sizeof(AudioDeviceID);
|
|
@@ -515,14 +516,15 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {
|
|
prop.mSelector = kAudioDevicePropertyStreamConfiguration;
|
|
prop.mSelector = kAudioDevicePropertyStreamConfiguration;
|
|
|
|
|
|
AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size);
|
|
AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size);
|
|
- AudioBufferList *bufferList = (AudioBufferList *)malloc(size);
|
|
|
|
|
|
+ AudioBufferList *bufferList = (AudioBufferList *)memalloc(size);
|
|
|
|
+ ERR_FAIL_NULL_V_MSG(bufferList, list, "Out of memory.");
|
|
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList);
|
|
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList);
|
|
|
|
|
|
UInt32 channelCount = 0;
|
|
UInt32 channelCount = 0;
|
|
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++)
|
|
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++)
|
|
channelCount += bufferList->mBuffers[j].mNumberChannels;
|
|
channelCount += bufferList->mBuffers[j].mNumberChannels;
|
|
|
|
|
|
- free(bufferList);
|
|
|
|
|
|
+ memfree(bufferList);
|
|
|
|
|
|
if (channelCount >= 1) {
|
|
if (channelCount >= 1) {
|
|
CFStringRef cfname;
|
|
CFStringRef cfname;
|
|
@@ -534,17 +536,18 @@ Array AudioDriverCoreAudio::_get_device_list(bool capture) {
|
|
|
|
|
|
CFIndex length = CFStringGetLength(cfname);
|
|
CFIndex length = CFStringGetLength(cfname);
|
|
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
|
|
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
|
|
- char *buffer = (char *)malloc(maxSize);
|
|
|
|
|
|
+ char *buffer = (char *)memalloc(maxSize);
|
|
|
|
+ ERR_FAIL_NULL_V_MSG(buffer, list, "Out of memory.");
|
|
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
|
|
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
|
|
// Append the ID to the name in case we have devices with duplicate name
|
|
// Append the ID to the name in case we have devices with duplicate name
|
|
list.push_back(String(buffer) + " (" + itos(audioDevices[i]) + ")");
|
|
list.push_back(String(buffer) + " (" + itos(audioDevices[i]) + ")");
|
|
}
|
|
}
|
|
|
|
|
|
- free(buffer);
|
|
|
|
|
|
+ memfree(buffer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- free(audioDevices);
|
|
|
|
|
|
+ memfree(audioDevices);
|
|
|
|
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
@@ -561,7 +564,8 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
|
|
|
|
|
|
UInt32 size = 0;
|
|
UInt32 size = 0;
|
|
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, nullptr, &size);
|
|
AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &prop, 0, nullptr, &size);
|
|
- AudioDeviceID *audioDevices = (AudioDeviceID *)malloc(size);
|
|
|
|
|
|
+ AudioDeviceID *audioDevices = (AudioDeviceID *)memalloc(size);
|
|
|
|
+ ERR_FAIL_NULL_MSG(audioDevices, "Out of memory.");
|
|
AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, nullptr, &size, audioDevices);
|
|
AudioObjectGetPropertyData(kAudioObjectSystemObject, &prop, 0, nullptr, &size, audioDevices);
|
|
|
|
|
|
UInt32 deviceCount = size / sizeof(AudioDeviceID);
|
|
UInt32 deviceCount = size / sizeof(AudioDeviceID);
|
|
@@ -570,14 +574,15 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
|
|
prop.mSelector = kAudioDevicePropertyStreamConfiguration;
|
|
prop.mSelector = kAudioDevicePropertyStreamConfiguration;
|
|
|
|
|
|
AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size);
|
|
AudioObjectGetPropertyDataSize(audioDevices[i], &prop, 0, nullptr, &size);
|
|
- AudioBufferList *bufferList = (AudioBufferList *)malloc(size);
|
|
|
|
|
|
+ AudioBufferList *bufferList = (AudioBufferList *)memalloc(size);
|
|
|
|
+ ERR_FAIL_NULL_MSG(bufferList, "Out of memory.");
|
|
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList);
|
|
AudioObjectGetPropertyData(audioDevices[i], &prop, 0, nullptr, &size, bufferList);
|
|
|
|
|
|
UInt32 channelCount = 0;
|
|
UInt32 channelCount = 0;
|
|
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++)
|
|
for (UInt32 j = 0; j < bufferList->mNumberBuffers; j++)
|
|
channelCount += bufferList->mBuffers[j].mNumberChannels;
|
|
channelCount += bufferList->mBuffers[j].mNumberChannels;
|
|
|
|
|
|
- free(bufferList);
|
|
|
|
|
|
+ memfree(bufferList);
|
|
|
|
|
|
if (channelCount >= 1) {
|
|
if (channelCount >= 1) {
|
|
CFStringRef cfname;
|
|
CFStringRef cfname;
|
|
@@ -589,7 +594,8 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
|
|
|
|
|
|
CFIndex length = CFStringGetLength(cfname);
|
|
CFIndex length = CFStringGetLength(cfname);
|
|
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
|
|
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8) + 1;
|
|
- char *buffer = (char *)malloc(maxSize);
|
|
|
|
|
|
+ char *buffer = (char *)memalloc(maxSize);
|
|
|
|
+ ERR_FAIL_NULL_MSG(buffer, "Out of memory.");
|
|
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
|
|
if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) {
|
|
String name = String(buffer) + " (" + itos(audioDevices[i]) + ")";
|
|
String name = String(buffer) + " (" + itos(audioDevices[i]) + ")";
|
|
if (name == device) {
|
|
if (name == device) {
|
|
@@ -598,11 +604,11 @@ void AudioDriverCoreAudio::_set_device(const String &device, bool capture) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- free(buffer);
|
|
|
|
|
|
+ memfree(buffer);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- free(audioDevices);
|
|
|
|
|
|
+ memfree(audioDevices);
|
|
}
|
|
}
|
|
|
|
|
|
if (!found) {
|
|
if (!found) {
|