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 = {
selector, kAudioObjectPropertyScopeGlobal,
43 kAudioObjectPropertyElementMaster };
45 if (
auto audioDevice = getAudioObject<AudioDeviceID>(kAudioObjectSystemObject, propertyAddress,
55 const AudioObjectPropertyAddress propertyAddress =
58 if (
auto name = getAudioObject<CFStringRef>(
device, propertyAddress,
"Device UID")) {
71 AudioDeviceID defaultDevice = defaultAudioDevice(
mode);
72 if (defaultDevice != 0)
75 const AudioObjectPropertyAddress audioDevicesPropertyAddress = {
76 kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal,
77 kAudioObjectPropertyElementMaster
80 if (
auto audioDevices = getAudioData<AudioDeviceID>(
81 kAudioObjectSystemObject, audioDevicesPropertyAddress,
"Audio Devices")) {
82 const AudioObjectPropertyAddress audioDeviceStreamFormatPropertyAddress =
85 for (
const auto &
device : *audioDevices) {
86 if (
device == defaultDevice)
89 if (getAudioObject<AudioStreamBasicDescription>(
device,
90 audioDeviceStreamFormatPropertyAddress,
100static OSStatus audioDeviceChangeListener(AudioObjectID
id, UInt32,
101 const AudioObjectPropertyAddress *
address,
void *
ptr)
109 <<
"audioDeviceChangeListener: id:" <<
id <<
"address: " <<
address->mSelector
113 case kAudioHardwarePropertyDefaultInputDevice:
116 case kAudioHardwarePropertyDefaultOutputDevice:
128static constexpr AudioObjectPropertyAddress listenerAddresses[] = {
129 { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal,
130 kAudioObjectPropertyElementMaster },
131 { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal,
132 kAudioObjectPropertyElementMaster },
133 { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal,
134 kAudioObjectPropertyElementMaster }
139 for (
const auto &
address : listenerAddresses) {
140 const auto err = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &
address,
141 audioDeviceChangeListener, &instance);
152 for (
const auto &
address : listenerAddresses) {
153 const auto err = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &
address,
154 audioDeviceChangeListener, &instance);
157 qWarning() <<
"Fail to remove listener. mSelector:" <<
address.mSelector
163#elif defined(Q_OS_IOS)
172 AVCaptureDevice *defaultDevice =
173 [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
176 AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession =
177 [AVCaptureDeviceDiscoverySession
178 discoverySessionWithDeviceTypes:@[ AVCaptureDeviceTypeBuiltInMicrophone ]
179 mediaType:AVMediaTypeAudio
180 position:AVCaptureDevicePositionUnspecified];
182 NSArray *captureDevices = [captureDeviceDiscoverySession
devices];
183 for (AVCaptureDevice *
device in captureDevices) {
184 const bool isDefault =
185 defaultDevice && [defaultDevice.uniqueID isEqualToString:
device.uniqueID];
187 QString::fromNSString(
device.uniqueID).toUtf8(),
217 setAudioListeners(*
this);
223 removeAudioListeners(*
this);
239 if (m_cachedAudioInputs != inputs) {
240 m_cachedAudioInputs = inputs;
248 if (m_cachedAudioOutputs != outputs) {
249 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.
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
static AudioObjectPropertyAddress makePropertyAddress(AudioObjectPropertySelector selector, QAudioDevice::Mode mode, AudioObjectPropertyElement element=kAudioObjectPropertyElementMaster)
static ControlElement< T > * ptr(QWidget *widget)
GLuint GLuint64EXT address
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QFileInfo info(fileName)
[8]
QFileSelector selector
[1]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent