-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SoundManager: Set up AVAudioSession on iOS
- Loading branch information
Showing
4 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
namespace mixxx { | ||
|
||
void initializeAVAudioSession(); | ||
|
||
}; // namespace mixxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <QDebug> | ||
#include <QtGlobal> | ||
|
||
#import <AVFAudio/AVFAudio.h> | ||
|
||
namespace mixxx { | ||
|
||
void initializeAVAudioSession() { | ||
AVAudioSession* session = AVAudioSession.sharedInstance; | ||
AVAudioSessionCategory category = AVAudioSessionCategoryPlayback; | ||
AVAudioSessionMode mode = AVAudioSessionModeDefault; | ||
AVAudioSessionCategoryOptions options = | ||
AVAudioSessionCategoryOptionMixWithOthers | | ||
AVAudioSessionCategoryOptionAllowAirPlay | | ||
AVAudioSessionCategoryOptionAllowBluetoothA2DP; | ||
|
||
NSError* error = nil; | ||
[session setCategory:category mode:mode options:options error:&error]; | ||
if (error != nil) { | ||
qWarning() << "Could not initialize AVAudioSession:" | ||
<< error.localizedDescription; | ||
} | ||
|
||
[session setActive:true error:&error]; | ||
if (error != nil) { | ||
qWarning() << "Could not activate AVAudioSession:" | ||
<< error.localizedDescription; | ||
} | ||
} | ||
|
||
}; // namespace mixxx |