summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Nichols <andy.nichols@digia.com>2014-03-06 12:33:41 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-07 14:58:25 +0100
commit175bdda34701fb3ee9688b40a974a402975b910f (patch)
tree986991f58729fc43f8ce0585666666ae7633d5cb
parentb6b974361ab000be0585998dabfe8019ad6b39c1 (diff)
downloadqtmultimedia-175bdda34701fb3ee9688b40a974a402975b910f.tar.gz
qtmultimedia-175bdda34701fb3ee9688b40a974a402975b910f.tar.bz2
qtmultimedia-175bdda34701fb3ee9688b40a974a402975b910f.zip
CoreAudio: Set default audio category to Playback on iOS
This fixes the issue that when we use QSoundEffect we dont need to get permission to use the microphone. This was because we were defaulting to PlayAndRecord. Now we only switch to the PlayAndRecord category when we try and use an input device. [ChangeLog][QtMultimedia][iOS] Using QSoundEffect (or SoundEffect in QML) no longer requires permission to use the microphone. Change-Id: I94535215497a718005c280bfd84b428b4bf1b16a Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
-rw-r--r--src/plugins/coreaudio/coreaudiodeviceinfo.mm11
-rw-r--r--src/plugins/coreaudio/coreaudioinput.mm4
-rw-r--r--src/plugins/coreaudio/coreaudiosessionmanager.mm3
3 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/coreaudio/coreaudiodeviceinfo.mm b/src/plugins/coreaudio/coreaudiodeviceinfo.mm
index bb1f046a..74a692c1 100644
--- a/src/plugins/coreaudio/coreaudiodeviceinfo.mm
+++ b/src/plugins/coreaudio/coreaudiodeviceinfo.mm
@@ -61,6 +61,11 @@ CoreAudioDeviceInfo::CoreAudioDeviceInfo(const QByteArray &device, QAudio::Mode
m_deviceId = AudioDeviceID(deviceID);
#else //iOS
m_device = device;
+ if (mode == QAudio::AudioInput) {
+ if (CoreAudioSessionManager::instance().category() != CoreAudioSessionManager::PlayAndRecord) {
+ CoreAudioSessionManager::instance().setCategory(CoreAudioSessionManager::PlayAndRecord);
+ }
+ }
#endif
}
@@ -379,6 +384,12 @@ QList<QByteArray> CoreAudioDeviceInfo::availableDevices(QAudio::Mode mode)
}
}
#else //iOS
+ if (mode == QAudio::AudioInput) {
+ if (CoreAudioSessionManager::instance().category() != CoreAudioSessionManager::PlayAndRecord) {
+ CoreAudioSessionManager::instance().setCategory(CoreAudioSessionManager::PlayAndRecord);
+ }
+ }
+
CoreAudioSessionManager::instance().setActive(true);
if (mode == QAudio::AudioOutput)
diff --git a/src/plugins/coreaudio/coreaudioinput.mm b/src/plugins/coreaudio/coreaudioinput.mm
index c41e1a51..a0b9e9d2 100644
--- a/src/plugins/coreaudio/coreaudioinput.mm
+++ b/src/plugins/coreaudio/coreaudioinput.mm
@@ -47,6 +47,10 @@
# include <CoreServices/CoreServices.h>
#endif
+#if defined(Q_OS_IOS)
+# include "coreaudiosessionmanager.h"
+#endif
+
#include <QtMultimedia/private/qaudiohelpers_p.h>
#include <QtCore/QDebug>
diff --git a/src/plugins/coreaudio/coreaudiosessionmanager.mm b/src/plugins/coreaudio/coreaudiosessionmanager.mm
index 4b3bdb7d..0e795e78 100644
--- a/src/plugins/coreaudio/coreaudiosessionmanager.mm
+++ b/src/plugins/coreaudio/coreaudiosessionmanager.mm
@@ -216,7 +216,8 @@ CoreAudioSessionManager::CoreAudioSessionManager() :
{
m_sessionObserver = [[CoreAudioSessionObserver alloc] initWithAudioSessionManager:this];
setActive(true);
- setCategory(CoreAudioSessionManager::PlayAndRecord, CoreAudioSessionManager::MixWithOthers);
+ //set default category to just Playback and only switch if we need more permissions
+ setCategory(CoreAudioSessionManager::Playback, CoreAudioSessionManager::MixWithOthers);
}
CoreAudioSessionManager::~CoreAudioSessionManager()