6#include "private/qaudiodevice_p.h"
17#import <AVFoundation/AVFoundation.h>
22#if defined(Q_OS_MACOS)
28template<
typename... Args>
32 dev->isDefault = isDefault;
36#if defined(Q_OS_MACOS)
41 : kAudioHardwarePropertyDefaultInputDevice;
42 const AudioObjectPropertyAddress propertyAddress = {
44 kAudioObjectPropertyScopeGlobal,
45 kAudioObjectPropertyElementMain,
48 if (
auto audioDevice = getAudioObject<AudioDeviceID>(kAudioObjectSystemObject, propertyAddress,
58 const AudioObjectPropertyAddress propertyAddress =
61 if (
auto name = getAudioObject<CFStringRef>(
device, propertyAddress,
"Device UID")) {
74 AudioDeviceID defaultDevice = defaultAudioDevice(
mode);
75 if (defaultDevice != 0)
78 const AudioObjectPropertyAddress audioDevicesPropertyAddress = {
79 kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal,
80 kAudioObjectPropertyElementMain
83 if (
auto audioDevices = getAudioData<AudioDeviceID>(
84 kAudioObjectSystemObject, audioDevicesPropertyAddress,
"Audio Devices")) {
85 const AudioObjectPropertyAddress audioDeviceStreamFormatPropertyAddress =
88 for (
const auto &
device : *audioDevices) {
89 if (
device == defaultDevice)
92 if (getAudioObject<AudioStreamBasicDescription>(
device,
93 audioDeviceStreamFormatPropertyAddress,
103static OSStatus audioDeviceChangeListener(AudioObjectID
id, UInt32,
104 const AudioObjectPropertyAddress *
address,
void *
ptr)
112 <<
"audioDeviceChangeListener: id:" <<
id <<
"address: " <<
address->mSelector
116 case kAudioHardwarePropertyDefaultInputDevice:
119 case kAudioHardwarePropertyDefaultOutputDevice:
131static constexpr AudioObjectPropertyAddress listenerAddresses[] = {
132 { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal,
133 kAudioObjectPropertyElementMain },
134 { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal,
135 kAudioObjectPropertyElementMain },
136 { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal,
137 kAudioObjectPropertyElementMain }
142 for (
const auto &
address : listenerAddresses) {
143 const auto err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &
address,
144 audioDeviceChangeListener, &instance);
155 for (
const auto &
address : listenerAddresses) {
156 const auto err = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &
address,
157 audioDeviceChangeListener, &instance);
160 qWarning() <<
"Fail to remove listener. mSelector:" <<
address.mSelector
166#elif defined(Q_OS_IOS)
175 AVCaptureDevice *defaultDevice =
176 [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
179 AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession =
180 [AVCaptureDeviceDiscoverySession
181 discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInMicrophone ]
182 mediaType:AVMediaTypeAudio
183 position:AVCaptureDevicePositionUnspecified];
185 NSArray *captureDevices = [captureDeviceDiscoverySession
devices];
186 for (AVCaptureDevice *
device in captureDevices) {
187 const bool isDefault =
188 defaultDevice && [defaultDevice.uniqueID isEqualToString:
device.uniqueID];
190 QString::fromNSString(
device.uniqueID).toUtf8(),
220 setAudioListeners(*
this);
226 removeAudioListeners(*
this);
242 if (m_cachedAudioInputs != inputs) {
243 m_cachedAudioInputs = inputs;
251 if (m_cachedAudioOutputs != outputs) {
252 m_cachedAudioOutputs = outputs;
IOBluetoothDevice * device
The QAudioDevice class provides an information about audio devices and their functionality.
Mode
Describes the mode of this device.
QObject * parent() const
Returns a pointer to the parent object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Combined button and popup list for selecting options.
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
static AudioObjectPropertyAddress makePropertyAddress(AudioObjectPropertySelector selector, QAudioDevice::Mode mode, AudioObjectPropertyElement element=kAudioObjectPropertyElementMain)
static ControlElement< T > * ptr(QWidget *widget)
GLuint GLuint64EXT address
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QFileSelector selector
[1]