package mapped;

import java.util.PriorityQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import net.runelite.api.widgets.JavaScriptCallback;
import net.runelite.mapping.ObfuscatedGetter;
import net.runelite.mapping.ObfuscatedName;
import net.runelite.mapping.ObfuscatedSignature;

@ObfuscatedName("mo")
class class323 implements Callable {
   @ObfuscatedName("vh")
   @ObfuscatedGetter(
      intValue = 274614777
   )
   static int field3490;
   // $FF: synthetic field
   @ObfuscatedSignature(
      descriptor = "Lmn;"
   )
   final MidiPcmStream this$0;
   // $FF: synthetic field
   final AtomicBoolean val$cancelled;

   @ObfuscatedSignature(
      descriptor = "(Lmn;Ljava/util/concurrent/atomic/AtomicBoolean;)V"
   )
   class323(MidiPcmStream var1, AtomicBoolean var2) {
      this.this$0 = var1;
      this.val$cancelled = var2;
   }

   public Object call() {
      PriorityQueue var1 = this.this$0.field3452;

      while(true) {
         class320 var2 = null;
         synchronized(var1) {
            if(var1.isEmpty() || this.val$cancelled.get()) {
               Object var10000 = null;
               return var10000;
            }

            var2 = (class320)var1.remove();
         }

         var2.field3474.method1095();
      }
   }

   @ObfuscatedName("ah")
   @ObfuscatedSignature(
      descriptor = "(Ldo;III)V",
      garbageValue = "1805349306"
   )
   static void method6209(ScriptEvent var0, int var1, int var2) {
      Object[] var3 = var0.getArguments();
      if(!Client.$assertionsDisabled && (var3 == null || var3.length <= 0)) {
         throw new AssertionError();
      } else {
         if(var3[0] instanceof JavaScriptCallback) {
            try {
               ((JavaScriptCallback)var3[0]).run(var0);
            } catch (Exception var9) {
               SpriteMask.client.getLogger().error("Error in JavaScriptCallback", var9);
            }
         } else {
            try {
               Client.rootScriptEvent = var0;
               Client.copy$runScript(var0, var1, var2, 1668364198);
            } finally {
               Client.currentScript = null;
            }
         }

      }
   }
}
