Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iOS audio session allowing other audio to mix #6457

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions osu.Framework.iOS/GameApplicationDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public override bool FinishedLaunching(UIApplication application, NSDictionary l
SDL_SetiOSEventPump(true);

var audioSession = AVAudioSession.SharedInstance();

// Set the default audio session to one that obeys the mute switch and does not mix with other audio,
// and insert an observer to disregard the mute switch when the user presses volume up/down.
audioSession.SetCategory(AVAudioSessionCategory.SoloAmbient);
audioSession.AddObserver(output_volume_observer, output_volume, NSKeyValueObservingOptions.New, 0);

host = new IOSGameHost();
Expand Down
4 changes: 2 additions & 2 deletions osu.Framework/Audio/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ protected virtual bool InitBass(int device)
// without this, if bass falls back to directsound legacy mode the audio playback offset will be way off.
Bass.Configure(ManagedBass.Configuration.TruePlayPosition, 0);

// For iOS devices, set the default audio policy to one that obeys the mute switch.
Bass.Configure(ManagedBass.Configuration.IOSMixAudio, 5);
// Set BASS_IOS_SESSION_DISABLE here to leave session configuration in our hands (see iOS project).
Bass.Configure(ManagedBass.Configuration.IOSSession, 16);

// Always provide a default device. This should be a no-op, but we have asserts for this behaviour.
Bass.Configure(ManagedBass.Configuration.IncludeDefaultDevice, true);
Expand Down
Loading