Skip to content

Commit

Permalink
Merge pull request #6457 from frenzibyte/ios-fix-mixing
Browse files Browse the repository at this point in the history
Fix iOS audio session allowing other audio to mix
  • Loading branch information
peppy authored Dec 16, 2024
2 parents d0b288d + 3458f7e commit aa8e72e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit aa8e72e

Please sign in to comment.