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>
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
}
}
}
#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)
# include <CoreServices/CoreServices.h>
#endif
+#if defined(Q_OS_IOS)
+# include "coreaudiosessionmanager.h"
+#endif
+
#include <QtMultimedia/private/qaudiohelpers_p.h>
#include <QtCore/QDebug>
{
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()