From 2524eb48a401689c2146e41a7a52a5d5b9602e9a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 25 Dec 2023 15:27:41 +0900 Subject: [PATCH] Rename concept of "global" mixer with "fallback" --- osu.Framework/Audio/AudioManager.cs | 4 ++-- osu.Framework/Audio/Mixing/AudioMixer.cs | 14 +++++++------- osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs | 7 ++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/osu.Framework/Audio/AudioManager.cs b/osu.Framework/Audio/AudioManager.cs index 2bcb262051..2e4cfe5e21 100644 --- a/osu.Framework/Audio/AudioManager.cs +++ b/osu.Framework/Audio/AudioManager.cs @@ -234,9 +234,9 @@ private void onDevicesChanged() public AudioMixer CreateAudioMixer(string identifier = default) => createAudioMixer(SampleMixer, !string.IsNullOrEmpty(identifier) ? identifier : $"user #{Interlocked.Increment(ref userMixerID)}"); - private AudioMixer createAudioMixer(AudioMixer globalMixer, string identifier) + private AudioMixer createAudioMixer(AudioMixer fallbackMixer, string identifier) { - var mixer = new BassAudioMixer(globalMixer, identifier); + var mixer = new BassAudioMixer(fallbackMixer, identifier); AddItem(mixer); return mixer; } diff --git a/osu.Framework/Audio/Mixing/AudioMixer.cs b/osu.Framework/Audio/Mixing/AudioMixer.cs index 581aef8f44..0e260af752 100644 --- a/osu.Framework/Audio/Mixing/AudioMixer.cs +++ b/osu.Framework/Audio/Mixing/AudioMixer.cs @@ -14,17 +14,17 @@ public abstract class AudioMixer : AudioComponent, IAudioMixer { public readonly string Identifier; - private readonly AudioMixer? globalMixer; + private readonly AudioMixer? fallbackMixer; /// /// Creates a new . /// - /// The global , which s are moved to if removed from this one. - /// A null value indicates this is the global . + /// A fallback , which s are moved to if removed from this one. + /// A null value indicates this is the fallback . /// An identifier displayed on the audio mixer visualiser. - protected AudioMixer(AudioMixer? globalMixer, string identifier) + protected AudioMixer(AudioMixer? fallbackMixer, string identifier) { - this.globalMixer = globalMixer; + this.fallbackMixer = fallbackMixer; Identifier = identifier; } @@ -56,7 +56,7 @@ public void Add(IAudioChannel channel) protected void Remove(IAudioChannel channel, bool returnToDefault) { // If this is the default mixer, prevent removal. - if (returnToDefault && globalMixer == null) + if (returnToDefault && fallbackMixer == null) return; channel.EnqueueAction(() => @@ -69,7 +69,7 @@ protected void Remove(IAudioChannel channel, bool returnToDefault) // Add the channel back to the default mixer so audio can always be played. if (returnToDefault) - globalMixer.AsNonNull().Add(channel); + fallbackMixer.AsNonNull().Add(channel); }); } diff --git a/osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs b/osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs index 37ed04d6d9..c0d2443f6b 100644 --- a/osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs +++ b/osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs @@ -42,10 +42,10 @@ internal class BassAudioMixer : AudioMixer, IBassAudio /// /// Creates a new . /// - /// + /// /// An identifier displayed on the audio mixer visualiser. - public BassAudioMixer(AudioMixer? globalMixer, string identifier) - : base(globalMixer, identifier) + public BassAudioMixer(AudioMixer? fallbackMixer, string identifier) + : base(fallbackMixer, identifier) { EnqueueAction(createMixer); } @@ -278,6 +278,7 @@ private void createMixer() return; Handle = BassMix.CreateMixerStream(frequency, 2, BassFlags.MixerNonStop); + if (Handle == 0) return;