Fixed memory leaks in rdpsnd mac
@@ -136,6 +136,7 @@ static void rdpsnd_mac_release(rdpsndMacPlugin *mac)
static BOOL rdpsnd_mac_open(rdpsndDevicePlugin *device, const AUDIO_FORMAT *format, UINT32 latency)
{
+ @autoreleasepool {
AudioDeviceID outputDeviceID;
UInt32 propertySize;
OSStatus err;
@@ -203,9 +204,11 @@ static BOOL rdpsnd_mac_open(rdpsndDevicePlugin *device, const AUDIO_FORMAT *form
mac->isOpen = TRUE;
return TRUE;
}
+}
static void rdpsnd_mac_close(rdpsndDevicePlugin *device)
{
+ @autoreleasepool {
rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
if (mac->isPlaying)
@@ -222,6 +225,7 @@ static void rdpsnd_mac_close(rdpsndDevicePlugin *device)
rdpsnd_mac_release(mac);
}
+}
static void rdpsnd_mac_free(rdpsndDevicePlugin *device)
{
@@ -251,6 +255,7 @@ static BOOL rdpsnd_mac_format_supported(rdpsndDevicePlugin *device, const AUDIO_
static BOOL rdpsnd_mac_set_volume(rdpsndDevicePlugin *device, UINT32 value)
{
+ @autoreleasepool {
Float32 fVolume;
UINT16 volumeLeft;
UINT16 volumeRight;
@@ -267,9 +272,11 @@ static BOOL rdpsnd_mac_set_volume(rdpsndDevicePlugin *device, UINT32 value)
return TRUE;
}
+}
static void rdpsnd_mac_start(rdpsndDevicePlugin *device)
{
+ @autoreleasepool {
rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
if (!mac->isPlaying)
@@ -293,9 +300,11 @@ static void rdpsnd_mac_start(rdpsndDevicePlugin *device)
mac->diff = 100; /* Initial latency, corrected after first sample is played. */
}
}
+}
static UINT rdpsnd_mac_play(rdpsndDevicePlugin *device, const BYTE *data, size_t size)
{
+ @autoreleasepool {
rdpsndMacPlugin *mac = (rdpsndMacPlugin *)device;
AVAudioPCMBuffer *buffer;
AVAudioFormat *format;
@@ -314,15 +323,18 @@ static UINT rdpsnd_mac_play(rdpsndDevicePlugin *device, const BYTE *data, size_t
sampleRate:mac->format.nSamplesPerSec
channels:mac->format.nChannels
interleaved:NO];
+
if (!format)
{
WLog_WARN(TAG, "AVAudioFormat::init() failed");
return 0;
}
+
buffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:format frameCapacity:count];
+ [format release];
+
if (!buffer)
{
- [format release];
WLog_WARN(TAG, "AVAudioPCMBuffer::init() failed");
return 0;
}
@@ -352,8 +364,11 @@ static UINT rdpsnd_mac_play(rdpsndDevicePlugin *device, const BYTE *data, size_t
mac->diff = stop - start;
}];
+ [buffer release];
+
return mac->diff > UINT_MAX ? UINT_MAX : mac->diff;
}
+}
/**
* Function description
