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>
This commit is contained in:
committed by
The Qt Project
parent
b6b974361a
commit
175bdda347
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user