Skip to content

Commit

Permalink
Slight refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Metious committed Nov 10, 2024
1 parent 80ae484 commit bc0f61a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Nautilus/Utility/AudioUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static partial class AudioUtils
/// For music, PDA voices and any 2D sounds that can have more than one instance at a time.
/// </summary>
public const MODE StandardSoundModes_Stream = StandardSoundModes_2D | MODE.CREATESTREAM;

private static FMOD.System FMOD_System => RuntimeManager.CoreSystem;

/// <summary>
Expand Down Expand Up @@ -84,14 +84,8 @@ public static IEnumerable<Sound> CreateSounds(IEnumerable<string> soundPaths, MO
public static bool TryPlaySound(Sound sound, string busPath, out Channel channel)
{
channel = default;
Bus bus = RuntimeManager.GetBus(busPath);
if (bus.getChannelGroup(out ChannelGroup channelGroup) != RESULT.OK || !channelGroup.hasHandle())
{
bus.lockChannelGroup();
}
return bus.getChannelGroup(out channelGroup) == RESULT.OK &&
channelGroup.getPaused(out bool paused) == RESULT.OK &&
FMOD_System.playSound(sound, channelGroup, paused, out channel) == RESULT.OK;
var bus = RuntimeManager.GetBus(busPath);
return TryPlaySound(sound, bus, out channel);
}

/// <summary>
Expand All @@ -108,9 +102,17 @@ public static bool TryPlaySound(Sound sound, Bus bus, out Channel channel)
{
bus.lockChannelGroup();
}
return bus.getChannelGroup(out channelGroup) == RESULT.OK &&

var success = bus.getChannelGroup(out channelGroup) == RESULT.OK &&
channelGroup.getPaused(out bool paused) == RESULT.OK &&
FMOD_System.playSound(sound, channelGroup, paused, out channel) == RESULT.OK;

if (!success)
{
return false;
}

return true;
}

/// <summary>
Expand Down

0 comments on commit bc0f61a

Please sign in to comment.