mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 08:44:04 +02:00
Merge pull request #92 from kawa-yoiko/tiny-leaks
Fix a few tiny memory leaks
This commit is contained in:
+13
@@ -2170,6 +2170,7 @@ struct ma_context
|
|||||||
{
|
{
|
||||||
ma_handle hCoreFoundation;
|
ma_handle hCoreFoundation;
|
||||||
ma_proc CFStringGetCString;
|
ma_proc CFStringGetCString;
|
||||||
|
ma_proc CFRelease;
|
||||||
|
|
||||||
ma_handle hCoreAudio;
|
ma_handle hCoreAudio;
|
||||||
ma_proc AudioObjectGetPropertyData;
|
ma_proc AudioObjectGetPropertyData;
|
||||||
@@ -17247,6 +17248,7 @@ Core Audio Backend
|
|||||||
|
|
||||||
/* CoreFoundation */
|
/* CoreFoundation */
|
||||||
typedef Boolean (* ma_CFStringGetCString_proc)(CFStringRef theString, char* buffer, CFIndex bufferSize, CFStringEncoding encoding);
|
typedef Boolean (* ma_CFStringGetCString_proc)(CFStringRef theString, char* buffer, CFIndex bufferSize, CFStringEncoding encoding);
|
||||||
|
typedef void (* ma_CFRelease_proc)(CFTypeRef cf);
|
||||||
|
|
||||||
/* CoreAudio */
|
/* CoreAudio */
|
||||||
#if defined(MA_APPLE_DESKTOP)
|
#if defined(MA_APPLE_DESKTOP)
|
||||||
@@ -17675,6 +17677,7 @@ ma_result ma_get_AudioObject_uid(ma_context* pContext, AudioObjectID objectID, s
|
|||||||
return MA_ERROR;
|
return MA_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
((ma_CFRelease_proc)pContext->coreaudio.CFRelease)(uid);
|
||||||
return MA_SUCCESS;
|
return MA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17701,6 +17704,7 @@ ma_result ma_get_AudioObject_name(ma_context* pContext, AudioObjectID objectID,
|
|||||||
return MA_ERROR;
|
return MA_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
((ma_CFRelease_proc)pContext->coreaudio.CFRelease)(deviceName);
|
||||||
return MA_SUCCESS;
|
return MA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18126,6 +18130,7 @@ ma_result ma_find_AudioObjectID(ma_context* pContext, ma_device_type deviceType,
|
|||||||
if (ma_does_AudioObject_support_playback(pContext, deviceObjectID)) {
|
if (ma_does_AudioObject_support_playback(pContext, deviceObjectID)) {
|
||||||
if (strcmp(uid, pDeviceID->coreaudio) == 0) {
|
if (strcmp(uid, pDeviceID->coreaudio) == 0) {
|
||||||
*pDeviceObjectID = deviceObjectID;
|
*pDeviceObjectID = deviceObjectID;
|
||||||
|
ma_free(pDeviceObjectIDs);
|
||||||
return MA_SUCCESS;
|
return MA_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18133,11 +18138,14 @@ ma_result ma_find_AudioObjectID(ma_context* pContext, ma_device_type deviceType,
|
|||||||
if (ma_does_AudioObject_support_capture(pContext, deviceObjectID)) {
|
if (ma_does_AudioObject_support_capture(pContext, deviceObjectID)) {
|
||||||
if (strcmp(uid, pDeviceID->coreaudio) == 0) {
|
if (strcmp(uid, pDeviceID->coreaudio) == 0) {
|
||||||
*pDeviceObjectID = deviceObjectID;
|
*pDeviceObjectID = deviceObjectID;
|
||||||
|
ma_free(pDeviceObjectIDs);
|
||||||
return MA_SUCCESS;
|
return MA_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ma_free(pDeviceObjectIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we get here it means we couldn't find the device. */
|
/* If we get here it means we couldn't find the device. */
|
||||||
@@ -18218,6 +18226,7 @@ ma_result ma_find_best_format__coreaudio(ma_context* pContext, AudioObjectID dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hasSupportedFormat) {
|
if (!hasSupportedFormat) {
|
||||||
|
ma_free(pDeviceFormatDescriptions);
|
||||||
return MA_FORMAT_NOT_SUPPORTED;
|
return MA_FORMAT_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18339,6 +18348,8 @@ ma_result ma_find_best_format__coreaudio(ma_context* pContext, AudioObjectID dev
|
|||||||
}
|
}
|
||||||
|
|
||||||
*pFormat = bestDeviceFormatSoFar;
|
*pFormat = bestDeviceFormatSoFar;
|
||||||
|
|
||||||
|
ma_free(pDeviceFormatDescriptions);
|
||||||
return MA_SUCCESS;
|
return MA_SUCCESS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -19678,6 +19689,7 @@ ma_result ma_context_init__coreaudio(const ma_context_config* pConfig, ma_contex
|
|||||||
}
|
}
|
||||||
|
|
||||||
pContext->coreaudio.CFStringGetCString = ma_dlsym(pContext, pContext->coreaudio.hCoreFoundation, "CFStringGetCString");
|
pContext->coreaudio.CFStringGetCString = ma_dlsym(pContext, pContext->coreaudio.hCoreFoundation, "CFStringGetCString");
|
||||||
|
pContext->coreaudio.CFRelease = ma_dlsym(pContext, pContext->coreaudio.hCoreFoundation, "CFRelease");
|
||||||
|
|
||||||
|
|
||||||
pContext->coreaudio.hCoreAudio = ma_dlopen(pContext, "CoreAudio.framework/CoreAudio");
|
pContext->coreaudio.hCoreAudio = ma_dlopen(pContext, "CoreAudio.framework/CoreAudio");
|
||||||
@@ -19728,6 +19740,7 @@ ma_result ma_context_init__coreaudio(const ma_context_config* pConfig, ma_contex
|
|||||||
pContext->coreaudio.AudioUnitRender = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitRender");
|
pContext->coreaudio.AudioUnitRender = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitRender");
|
||||||
#else
|
#else
|
||||||
pContext->coreaudio.CFStringGetCString = (ma_proc)CFStringGetCString;
|
pContext->coreaudio.CFStringGetCString = (ma_proc)CFStringGetCString;
|
||||||
|
pContext->coreaudio.CFRelease = (ma_proc)CFRelease;
|
||||||
|
|
||||||
#if defined(MA_APPLE_DESKTOP)
|
#if defined(MA_APPLE_DESKTOP)
|
||||||
pContext->coreaudio.AudioObjectGetPropertyData = (ma_proc)AudioObjectGetPropertyData;
|
pContext->coreaudio.AudioObjectGetPropertyData = (ma_proc)AudioObjectGetPropertyData;
|
||||||
|
|||||||
Reference in New Issue
Block a user