CoreAudio: use AudioComponent instead of deprecated Carbon Component
OS X 10.11 generates a warning when the code uses the Carbon Component Manager to locate audio devices. The new AudioComponent interface has been available since 10.7. Change-Id: I46ecbcd62871ecc46ce3ebd9ea2a37a9e1342f41 Task-number: QTBUG-48828 Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
This commit is contained in:
committed by
Yoann Lopes
parent
c1cfbd98d2
commit
cf44daa754
@@ -36,7 +36,7 @@
|
|||||||
#include "coreaudioutils.h"
|
#include "coreaudioutils.h"
|
||||||
|
|
||||||
#if defined(Q_OS_OSX)
|
#if defined(Q_OS_OSX)
|
||||||
# include <CoreServices/CoreServices.h>
|
# include <AudioUnit/AudioComponent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_IOS)
|
#if defined(Q_OS_IOS)
|
||||||
@@ -480,31 +480,15 @@ bool CoreAudioInput::open()
|
|||||||
if (m_isOpen)
|
if (m_isOpen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#if defined(Q_OS_OSX)
|
|
||||||
UInt32 size = 0;
|
UInt32 size = 0;
|
||||||
|
|
||||||
ComponentDescription componentDescription;
|
|
||||||
componentDescription.componentType = kAudioUnitType_Output;
|
|
||||||
componentDescription.componentSubType = kAudioUnitSubType_HALOutput;
|
|
||||||
componentDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
|
|
||||||
componentDescription.componentFlags = 0;
|
|
||||||
componentDescription.componentFlagsMask = 0;
|
|
||||||
|
|
||||||
// Open
|
|
||||||
Component component = FindNextComponent(NULL, &componentDescription);
|
|
||||||
if (component == 0) {
|
|
||||||
qWarning() << "QAudioInput: Failed to find HAL Output component";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OpenAComponent(component, &m_audioUnit) != noErr) {
|
|
||||||
qWarning() << "QAudioInput: Unable to Open Output Component";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else //iOS
|
|
||||||
AudioComponentDescription componentDescription;
|
AudioComponentDescription componentDescription;
|
||||||
componentDescription.componentType = kAudioUnitType_Output;
|
componentDescription.componentType = kAudioUnitType_Output;
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
|
componentDescription.componentSubType = kAudioUnitSubType_HALOutput;
|
||||||
|
#else
|
||||||
componentDescription.componentSubType = kAudioUnitSubType_RemoteIO;
|
componentDescription.componentSubType = kAudioUnitSubType_RemoteIO;
|
||||||
|
#endif
|
||||||
componentDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
|
componentDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||||
componentDescription.componentFlags = 0;
|
componentDescription.componentFlags = 0;
|
||||||
componentDescription.componentFlagsMask = 0;
|
componentDescription.componentFlagsMask = 0;
|
||||||
@@ -519,7 +503,7 @@ bool CoreAudioInput::open()
|
|||||||
qWarning() << "QAudioInput: Unable to Open Output Component";
|
qWarning() << "QAudioInput: Unable to Open Output Component";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
// Set mode
|
// Set mode
|
||||||
// switch to input mode
|
// switch to input mode
|
||||||
UInt32 enable = 1;
|
UInt32 enable = 1;
|
||||||
@@ -687,12 +671,7 @@ void CoreAudioInput::close()
|
|||||||
if (m_audioUnit != 0) {
|
if (m_audioUnit != 0) {
|
||||||
AudioOutputUnitStop(m_audioUnit);
|
AudioOutputUnitStop(m_audioUnit);
|
||||||
AudioUnitUninitialize(m_audioUnit);
|
AudioUnitUninitialize(m_audioUnit);
|
||||||
#if defined(Q_OS_OSX)
|
|
||||||
CloseComponent(m_audioUnit);
|
|
||||||
#else //iOS
|
|
||||||
AudioComponentInstanceDispose(m_audioUnit);
|
AudioComponentInstanceDispose(m_audioUnit);
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete m_audioBuffer;
|
delete m_audioBuffer;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <AudioUnit/AudioUnit.h>
|
#include <AudioUnit/AudioUnit.h>
|
||||||
#include <AudioToolbox/AudioToolbox.h>
|
#include <AudioToolbox/AudioToolbox.h>
|
||||||
#if defined(Q_OS_OSX)
|
#if defined(Q_OS_OSX)
|
||||||
# include <CoreServices/CoreServices.h>
|
# include <AudioUnit/AudioComponent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_IOS)
|
#if defined(Q_OS_IOS)
|
||||||
@@ -543,30 +543,13 @@ bool CoreAudioOutput::open()
|
|||||||
if (m_isOpen)
|
if (m_isOpen)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#if defined(Q_OS_OSX)
|
|
||||||
ComponentDescription componentDescription;
|
|
||||||
componentDescription.componentType = kAudioUnitType_Output;
|
|
||||||
componentDescription.componentSubType = kAudioUnitSubType_HALOutput;
|
|
||||||
componentDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
|
|
||||||
componentDescription.componentFlags = 0;
|
|
||||||
componentDescription.componentFlagsMask = 0;
|
|
||||||
|
|
||||||
// Open
|
|
||||||
Component component = FindNextComponent(NULL, &componentDescription);
|
|
||||||
if (component == 0) {
|
|
||||||
qWarning() << "QAudioOutput: Failed to find HAL Output component";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (OpenAComponent(component, &m_audioUnit) != noErr) {
|
|
||||||
qWarning() << "QAudioOutput: Unable to Open Output Component";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#else //iOS
|
|
||||||
|
|
||||||
AudioComponentDescription componentDescription;
|
AudioComponentDescription componentDescription;
|
||||||
componentDescription.componentType = kAudioUnitType_Output;
|
componentDescription.componentType = kAudioUnitType_Output;
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
|
componentDescription.componentSubType = kAudioUnitSubType_HALOutput;
|
||||||
|
#else
|
||||||
componentDescription.componentSubType = kAudioUnitSubType_RemoteIO;
|
componentDescription.componentSubType = kAudioUnitSubType_RemoteIO;
|
||||||
|
#endif
|
||||||
componentDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
|
componentDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||||
componentDescription.componentFlags = 0;
|
componentDescription.componentFlags = 0;
|
||||||
componentDescription.componentFlagsMask = 0;
|
componentDescription.componentFlagsMask = 0;
|
||||||
@@ -581,7 +564,6 @@ bool CoreAudioOutput::open()
|
|||||||
qWarning() << "QAudioOutput: Unable to Open Output Component";
|
qWarning() << "QAudioOutput: Unable to Open Output Component";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// register callback
|
// register callback
|
||||||
AURenderCallbackStruct callback;
|
AURenderCallbackStruct callback;
|
||||||
@@ -673,11 +655,7 @@ void CoreAudioOutput::close()
|
|||||||
if (m_audioUnit != 0) {
|
if (m_audioUnit != 0) {
|
||||||
AudioOutputUnitStop(m_audioUnit);
|
AudioOutputUnitStop(m_audioUnit);
|
||||||
AudioUnitUninitialize(m_audioUnit);
|
AudioUnitUninitialize(m_audioUnit);
|
||||||
#if defined(Q_OS_OSX)
|
|
||||||
CloseComponent(m_audioUnit);
|
|
||||||
#else //iOS
|
|
||||||
AudioComponentInstanceDispose(m_audioUnit);
|
AudioComponentInstanceDispose(m_audioUnit);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete m_audioBuffer;
|
delete m_audioBuffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user