Files
2026-08-27 11:23:13 -06:00

63 lines
1.7 KiB
C#

// Decompiled with JetBrains decompiler
// Type: AudioDispatch
// Assembly: Raton, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 36C4E416-7F8D-4D23-930F-B5CCB0D810E7
// Assembly location: C:\Users\user\Desktop\v3.8.0 Deluxe Plugins (v4.0.0) cracked\Raton.exe
using System;
using System.Collections.Concurrent;
using System.Threading;
#nullable disable
public static class AudioDispatch
{
private static readonly ConcurrentQueue<(string uid, byte[] data, int length)> queue = new ConcurrentQueue<(string, byte[], int)>();
private static readonly AutoResetEvent signal = new AutoResetEvent(false);
private static readonly Thread audioThread = new Thread(new ThreadStart(AudioDispatch.Loop))
{
IsBackground = true,
Name = nameof (AudioDispatch)
};
static AudioDispatch() => AudioDispatch.audioThread.Start();
public static void Enqueue(string uid, byte[] data, int length)
{
if (data == null || length <= 0 || length > data.Length)
return;
byte[] dst = new byte[length];
Buffer.BlockCopy((Array) data, 0, (Array) dst, 0, length);
AudioDispatch.queue.Enqueue((uid, dst, length));
AudioDispatch.signal.Set();
}
private static void Loop()
{
label_0:
try
{
AudioDispatch.signal.WaitOne();
while (true)
{
(string uid, byte[] data, int length) result;
if (AudioDispatch.queue.TryDequeue(out result))
{
try
{
AudioPlayer.Play(result.uid, result.data, result.length);
}
catch (Exception ex)
{
}
}
else
goto label_0;
}
}
catch (Exception ex)
{
Console.WriteLine("Error");
}
}
}