Prevent crash when there is no camera device available

If you try to use QAudioInputSelectorControl with the iOS Simulator then
it would crash as there is no camera device available. This prevents a
crash from happening in that case.

Change-Id: I3904f3d299a11a6df21e66a1138a4319cc0b8a5c
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
Andy Shaw
2014-03-19 10:41:46 +01:00
committed by The Qt Project
parent 4c0e4e1536
commit 73de758274

View File

@@ -60,7 +60,8 @@ AVFAudioInputSelectorControl::AVFAudioInputSelectorControl(AVFCameraService *ser
QString::fromUtf8([[device localizedName] UTF8String]));
}
m_activeInput = m_devices.first();
if (m_devices.size() > 0)
m_activeInput = m_devices.first();
}
AVFAudioInputSelectorControl::~AVFAudioInputSelectorControl()
@@ -79,7 +80,7 @@ QString AVFAudioInputSelectorControl::inputDescription(const QString &name) cons
QString AVFAudioInputSelectorControl::defaultInput() const
{
return m_devices.first();
return m_devices.size() > 0 ? m_devices.first() : QString();
}
QString AVFAudioInputSelectorControl::activeInput() const