void CCoreAudioHardware::ResetAudioDevices() { // Reset any devices with an AC3 stream back to a Linear PCM // so that they can become a default output device UInt32 size; AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL); AudioDeviceID *devices = (AudioDeviceID*)malloc(size); if (!devices) { CLog::Log(LOGERROR, "CCoreAudioHardware::ResetAudioDevices: ResetAudioDevices - out of memory?"); return; } int numDevices = size / sizeof(AudioDeviceID); AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, devices); for (int i = 0; i < numDevices; i++) { AudioStreamID *streams; streams = StreamsList(devices[i]); for (int j = 0; streams[j] != kAudioHardwareBadStreamError; j++) ResetStream(streams[j]); free(streams); } free(devices); }
void CCoreAudioHardware::ResetAudioDevices() { // Reset any devices with an AC3 stream back to a Linear PCM // so that they can become a default output device AudioObjectPropertyAddress propertyAddress; propertyAddress.mScope = kAudioObjectPropertyScopeGlobal; propertyAddress.mElement = kAudioObjectPropertyElementMaster; propertyAddress.mSelector = kAudioHardwarePropertyDevices; UInt32 size; OSStatus ret = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size); if (ret != noErr) { CLog::Log(LOGERROR, "CCoreAudioHardware::ResetAudioDevices: ResetAudioDevices - unknown size"); return; } AudioDeviceID *devices = (AudioDeviceID*)malloc(size); if (!devices) { CLog::Log(LOGERROR, "CCoreAudioHardware::ResetAudioDevices: ResetAudioDevices - out of memory?"); return; } int numDevices = size / sizeof(AudioDeviceID); ret = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, NULL, &size, devices); if (ret != noErr) { CLog::Log(LOGERROR, "CCoreAudioHardware::ResetAudioDevices: ResetAudioDevices - cannot get device list"); return; } for (int i = 0; i < numDevices; i++) { AudioStreamID *streams = StreamsList(devices[i]); if (streams) { for (int j = 0; streams[j] != kAudioHardwareBadStreamError; j++) ResetStream(streams[j]); free(streams); } } free(devices); }