/*****************************************************************************
* auhal.c: AUHAL and Coreaudio output plugin
*****************************************************************************
- * Copyright (C) 2005 - 2013 VLC authors and VideoLAN
+ * Copyright (C) 2005 - 2014 VLC authors and VideoLAN
* $Id$
*
* Authors: Derk-Jan Hartman <hartman at videolan dot org>
* as a former airplay device might be already gone, but the device number might be still valid. Core Audio
* even says that this device would be alive. Don't ask why, its Core Audio. */
CFIndex count = CFArrayGetCount(p_sys->device_list);
- if (CFArrayContainsValue(p_sys->device_list, CFRangeMake(0, count), CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &p_sys->i_selected_dev))) {
+ CFNumberRef deviceNumber = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &p_sys->i_selected_dev);
+ if (CFArrayContainsValue(p_sys->device_list, CFRangeMake(0, count), deviceNumber)) {
/* Check if the desired device is alive and usable */
i_param_size = sizeof(b_alive);
} else {
msg_Warn(p_aout, "device id %i not found in the current devices list, fallback to default device", p_sys->i_selected_dev);
}
+ CFRelease(deviceNumber);
}
p_sys->b_selected_dev_is_default = false;
if (layout->mNumberChannelDescriptions == 0) {
msg_Err(p_aout, "insufficient number of output channels");
+ free(layout);
return false;
}
err = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &audioDevicesAddress, 0, NULL, &propertySize);
if (err != noErr) {
msg_Err(p_aout, "Could not get number of devices: [%4.4s]", (char *)&err);
+ CFRelease(currentListOfDevices);
return;
}
if (numberOfDevices < 1) {
msg_Err(p_aout, "No audio output devices found.");
+ CFRelease(currentListOfDevices);
return;
}
msg_Dbg(p_aout, "found %i audio device(s)", numberOfDevices);
/* Allocate DeviceID array */
deviceIDs = (AudioDeviceID *)calloc(numberOfDevices, sizeof(AudioDeviceID));
- if (deviceIDs == NULL)
+ if (deviceIDs == NULL) {
+ CFRelease(currentListOfDevices);
return;
+ }
/* Populate DeviceID array */
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &audioDevicesAddress, 0, NULL, &propertySize, deviceIDs);
if (err != noErr) {
msg_Err(p_aout, "could not get the device IDs [%4.4s]", (char *)&err);
+ CFRelease(currentListOfDevices);
+ free(deviceIDs);
return;
}
CFStringRef device_name_ref;
char *psz_name;
CFIndex length;
- bool b_digital = false;
UInt32 i_id = deviceIDs[i];
/* Retrieve the length of the device name */
}
ReportDevice(p_aout, i_id, psz_name);
- CFArrayAppendValue(currentListOfDevices, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &i_id));
+ CFNumberRef deviceNumber = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &i_id);
+ CFArrayAppendValue(currentListOfDevices, deviceNumber);
+ CFRelease(deviceNumber);
if (AudioDeviceSupportsDigital(p_aout, deviceIDs[i])) {
- b_digital = true;
msg_Dbg(p_aout, "'%s' supports digital output", psz_name);
char *psz_encoded_name = nil;
asprintf(&psz_encoded_name, _("%s (Encoded Output)"), psz_name);
i_id = i_id | AOUT_VAR_SPDIF_FLAG;
ReportDevice(p_aout, i_id, psz_encoded_name);
- CFArrayAppendValue(currentListOfDevices, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &i_id));
+ deviceNumber = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &i_id);
+ CFArrayAppendValue(currentListOfDevices, deviceNumber);
+ CFRelease(deviceNumber);
free(psz_encoded_name);
}
}
}
}
- CFRelease(p_sys->device_list);
+ if (p_sys->device_list)
+ CFRelease(p_sys->device_list);
p_sys->device_list = CFArrayCreateCopy(kCFAllocatorDefault, currentListOfDevices);
CFRelease(currentListOfDevices);
vlc_mutex_unlock(&p_sys->var_lock);
RebuildDeviceList(p_aout);
vlc_mutex_lock(&p_sys->var_lock);
- if(!CFArrayContainsValue(p_sys->device_list, CFRangeMake(0, CFArrayGetCount(p_sys->device_list)),CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &p_sys->i_selected_dev)))
+ CFNumberRef selectedDevice = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &p_sys->i_selected_dev);
+ if(!CFArrayContainsValue(p_sys->device_list, CFRangeMake(0, CFArrayGetCount(p_sys->device_list)), selectedDevice))
aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+ CFRelease(selectedDevice);
vlc_mutex_unlock(&p_sys->var_lock);
return noErr;
if (err != noErr) {
msg_Err(p_aout, "could not get list of streams [%4.4s]", (char *)&err);
vlc_mutex_unlock(&p_sys->var_lock);
+ free(p_streams);
return VLC_EGENERIC;
}
vlc_mutex_unlock(&p_sys->var_lock);
err = AudioObjectGetPropertyData(i_dev_id, &streamsAddress, 0, NULL, &i_param_size, p_streams);
if (err != noErr) {
msg_Err(p_aout, "could not get list of streams [%4.4s]", (char *)&err);
+ free(p_streams);
return VLC_EGENERIC;
}
err = AudioObjectGetPropertyData(i_dev_id, &streamsAddress, 0, NULL, &i_param_size, p_streams);
if (err != noErr) {
msg_Err(p_aout, "could not get list of streams [%4.4s]", (char *)&err);
+ free(p_streams);
return false;
}