AVFoundation: correctly detect the default audio capture device.
Use AVCaptureDevice::defaultDeviceWithMediaType instead of the first device in the list of available devices. Change-Id: I436921f99280a28d7158d345cd977a874cfb8968 Reviewed-by: Timur Pocheptsov <Timur.Pocheptsov@digia.com> Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
This commit is contained in:
@@ -69,6 +69,7 @@ private:
|
|||||||
|
|
||||||
QString m_activeInput;
|
QString m_activeInput;
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
|
QString m_defaultDevice;
|
||||||
QStringList m_devices;
|
QStringList m_devices;
|
||||||
QMap<QString, QString> m_deviceDescriptions;
|
QMap<QString, QString> m_deviceDescriptions;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -60,8 +60,11 @@ AVFAudioInputSelectorControl::AVFAudioInputSelectorControl(AVFCameraService *ser
|
|||||||
QString::fromUtf8([[device localizedName] UTF8String]));
|
QString::fromUtf8([[device localizedName] UTF8String]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_devices.size() > 0)
|
AVCaptureDevice *defaultDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
|
||||||
m_activeInput = m_devices.first();
|
if (defaultDevice) {
|
||||||
|
m_defaultDevice = QString::fromUtf8([defaultDevice.uniqueID UTF8String]);
|
||||||
|
m_activeInput = m_defaultDevice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AVFAudioInputSelectorControl::~AVFAudioInputSelectorControl()
|
AVFAudioInputSelectorControl::~AVFAudioInputSelectorControl()
|
||||||
@@ -80,7 +83,7 @@ QString AVFAudioInputSelectorControl::inputDescription(const QString &name) cons
|
|||||||
|
|
||||||
QString AVFAudioInputSelectorControl::defaultInput() const
|
QString AVFAudioInputSelectorControl::defaultInput() const
|
||||||
{
|
{
|
||||||
return m_devices.size() > 0 ? m_devices.first() : QString();
|
return m_defaultDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AVFAudioInputSelectorControl::activeInput() const
|
QString AVFAudioInputSelectorControl::activeInput() const
|
||||||
|
|||||||
Reference in New Issue
Block a user