6#include <QtMultimedia/private/qmultimedia_ranges_p.h>
8#include <QtCore/qapplicationstatic.h>
9#include <QtCore/qcoreapplication.h>
10#include <QtCore/qloggingcategory.h>
11#include <QtCore/qthread.h>
13#import <AVFoundation/AVAudioSession.h>
17Q_STATIC_LOGGING_CATEGORY(qLcAudioSession,
"qt.multimedia.darwin.audiosession");
25struct InterruptionInfo
31InterruptionInfo parseInterruption(NSNotification *notification)
33 NSDictionary *userInfo = notification.userInfo;
34 NSNumber *typeValue = userInfo[AVAudioSessionInterruptionTypeKey];
35 const auto type =
static_cast<AVAudioSessionInterruptionType>(typeValue.unsignedIntegerValue);
37 if (type == AVAudioSessionInterruptionTypeBegan) {
38 qCDebug(qLcAudioSession) <<
"interruption notification: began";
39 return {
true,
false };
44 NSNumber *optionValue = userInfo[AVAudioSessionInterruptionOptionKey];
45 const bool shouldResume = optionValue != nil
46 && (optionValue.unsignedIntegerValue & AVAudioSessionInterruptionOptionShouldResume);
47 qCDebug(qLcAudioSession) <<
"interruption notification: ended, shouldResume:" << shouldResume;
48 return {
false, shouldResume };
56mergedCategory(
const std::vector<std::pair<TokenId, SessionRequirement>> &requirements)
58 const bool needsRecord = ranges::any_of(requirements, [](
const auto &entry) {
59 return entry.second.needsRecord;
61 return needsRecord ? AVAudioSessionCategoryPlayAndRecord : AVAudioSessionCategoryPlayback;
64AVAudioSessionCategoryOptions
65mergedOptions(
const std::vector<std::pair<TokenId, SessionRequirement>> &requirements)
67 AVAudioSessionCategoryOptions options = 0;
68 for (
const auto &entry : requirements)
69 options |= entry.second.options;
221 if (
this != &
other) {
246#include "moc_qavaudiosessionmanager_p.cpp"
Combined button and popup list for selecting options.