Skip to content

Commit

Permalink
Merge pull request #6091 from peppy/fallback-mixer
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo authored Dec 25, 2023
2 parents 70eb6c5 + 2524eb4 commit ba2f83f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions osu.Framework/Audio/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 7 additions & 7 deletions osu.Framework/Audio/Mixing/AudioMixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ public abstract class AudioMixer : AudioComponent, IAudioMixer
{
public readonly string Identifier;

private readonly AudioMixer? globalMixer;
private readonly AudioMixer? fallbackMixer;

/// <summary>
/// Creates a new <see cref="AudioMixer"/>.
/// </summary>
/// <param name="globalMixer">The global <see cref="AudioMixer"/>, which <see cref="IAudioChannel"/>s are moved to if removed from this one.
/// A <c>null</c> value indicates this is the global <see cref="AudioMixer"/>.</param>
/// <param name="fallbackMixer">A fallback <see cref="AudioMixer"/>, which <see cref="IAudioChannel"/>s are moved to if removed from this one.
/// A <c>null</c> value indicates this is the fallback <see cref="AudioMixer"/>.</param>
/// <param name="identifier">An identifier displayed on the audio mixer visualiser.</param>
protected AudioMixer(AudioMixer? globalMixer, string identifier)
protected AudioMixer(AudioMixer? fallbackMixer, string identifier)
{
this.globalMixer = globalMixer;
this.fallbackMixer = fallbackMixer;
Identifier = identifier;
}

Expand Down Expand Up @@ -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(() =>
Expand All @@ -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);
});
}

Expand Down
7 changes: 4 additions & 3 deletions osu.Framework/Audio/Mixing/Bass/BassAudioMixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ internal class BassAudioMixer : AudioMixer, IBassAudio
/// <summary>
/// Creates a new <see cref="BassAudioMixer"/>.
/// </summary>
/// <param name="globalMixer"><inheritdoc /></param>
/// <param name="fallbackMixer"><inheritdoc /></param>
/// <param name="identifier">An identifier displayed on the audio mixer visualiser.</param>
public BassAudioMixer(AudioMixer? globalMixer, string identifier)
: base(globalMixer, identifier)
public BassAudioMixer(AudioMixer? fallbackMixer, string identifier)
: base(fallbackMixer, identifier)
{
EnqueueAction(createMixer);
}
Expand Down Expand Up @@ -278,6 +278,7 @@ private void createMixer()
return;

Handle = BassMix.CreateMixerStream(frequency, 2, BassFlags.MixerNonStop);

if (Handle == 0)
return;

Expand Down

0 comments on commit ba2f83f

Please sign in to comment.