mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:49:24 +02:00
setting defauld device code for mac to use QT with optional backup to platform code on failure
This commit is contained in:
parent
6860ac9693
commit
397586bd19
1 changed files with 37 additions and 24 deletions
|
@ -516,37 +516,50 @@ QString defaultAudioDeviceName(QAudio::Mode mode) {
|
||||||
QString deviceName;
|
QString deviceName;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
AudioDeviceID defaultDeviceID = 0;
|
QAudioDeviceInfo device;
|
||||||
uint32_t propertySize = sizeof(AudioDeviceID);
|
if (mode == QAudio::AudioInput) {
|
||||||
AudioObjectPropertyAddress propertyAddress = {
|
device = QAudioDeviceInfo::defaultInputDevice();
|
||||||
kAudioHardwarePropertyDefaultInputDevice,
|
} else {
|
||||||
kAudioObjectPropertyScopeGlobal,
|
device = QAudioDeviceInfo::defaultOutputDevice();
|
||||||
kAudioObjectPropertyElementMaster
|
|
||||||
};
|
|
||||||
|
|
||||||
if (mode == QAudio::AudioOutput) {
|
|
||||||
propertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
|
|
||||||
}
|
}
|
||||||
|
if (!device.isNull()) {
|
||||||
|
if (!device.deviceName().isEmpty()) {
|
||||||
|
deviceName = device.deviceName();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "QT's Default device is null, reverting to platoform code";
|
||||||
|
AudioDeviceID defaultDeviceID = 0;
|
||||||
|
uint32_t propertySize = sizeof(AudioDeviceID);
|
||||||
|
AudioObjectPropertyAddress propertyAddress = {
|
||||||
|
kAudioHardwarePropertyDefaultInputDevice,
|
||||||
|
kAudioObjectPropertyScopeGlobal,
|
||||||
|
kAudioObjectPropertyElementMaster
|
||||||
|
};
|
||||||
|
|
||||||
|
if (mode == QAudio::AudioOutput) {
|
||||||
|
propertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
OSStatus getPropertyError = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
OSStatus getPropertyError = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||||
&propertyAddress,
|
&propertyAddress,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
&propertySize,
|
&propertySize,
|
||||||
&defaultDeviceID);
|
&defaultDeviceID);
|
||||||
|
|
||||||
if (!getPropertyError && propertySize) {
|
|
||||||
CFStringRef devName = NULL;
|
|
||||||
propertySize = sizeof(devName);
|
|
||||||
propertyAddress.mSelector = kAudioDevicePropertyDeviceNameCFString;
|
|
||||||
getPropertyError = AudioObjectGetPropertyData(defaultDeviceID, &propertyAddress, 0,
|
|
||||||
NULL, &propertySize, &devName);
|
|
||||||
|
|
||||||
if (!getPropertyError && propertySize) {
|
if (!getPropertyError && propertySize) {
|
||||||
deviceName = CFStringGetCStringPtr(devName, kCFStringEncodingMacRoman);
|
CFStringRef devName = NULL;
|
||||||
|
propertySize = sizeof(devName);
|
||||||
|
propertyAddress.mSelector = kAudioDevicePropertyDeviceNameCFString;
|
||||||
|
getPropertyError = AudioObjectGetPropertyData(defaultDeviceID, &propertyAddress, 0,
|
||||||
|
NULL, &propertySize, &devName);
|
||||||
|
|
||||||
|
if (!getPropertyError && propertySize) {
|
||||||
|
deviceName = CFStringGetCStringPtr(devName, kCFStringEncodingMacRoman);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
//Check for Windows Vista or higher, IMMDeviceEnumerator doesn't work below that.
|
//Check for Windows Vista or higher, IMMDeviceEnumerator doesn't work below that.
|
||||||
|
|
Loading…
Reference in a new issue