diff --git a/Capy64/Core/Audio.cs b/Capy64/Core/Audio.cs index 1fd4bee..0df6fc3 100644 --- a/Capy64/Core/Audio.cs +++ b/Capy64/Core/Audio.cs @@ -51,17 +51,22 @@ public class Audio : IDisposable HQChannel.BufferNeeded += HQChannel_BufferNeeded; } - private void HQChannel_BufferNeeded(object sender, EventArgs e) + private static void EnqueueAudioNeedEvent(int i, int pending) { - var pending = HQChannel.PendingBufferCount; Capy64.Instance.LuaRuntime.QueueEvent("audio_need", LK => { - LK.PushInteger(-1); + LK.PushInteger(i); LK.PushInteger(pending); return 2; }); } + private void HQChannel_BufferNeeded(object sender, EventArgs e) + { + var pending = HQChannel.PendingBufferCount; + EnqueueAudioNeedEvent(-1, pending); + } + private void Audio_BufferNeeded(object sender, EventArgs e) { for (int i = 0; i < ChannelsCount; i++) @@ -70,15 +75,9 @@ public class Audio : IDisposable { freeChannels[i] = true; var pending = Channels[i].PendingBufferCount; - Capy64.Instance.LuaRuntime.QueueEvent("audio_need", LK => - { - LK.PushInteger(i); - LK.PushInteger(pending); - return 2; - }); + EnqueueAudioNeedEvent(i, pending); } } - } public int GetChannelId(int inp)