Package quicktime.sound

Source Code of quicktime.sound.SoundRunner$MRJIdler

/*     */ package quicktime.sound;
/*     */
/*     */ import java.io.PrintStream;
/*     */ import java.security.AccessController;
/*     */ import java.security.PrivilegedAction;
/*     */ import quicktime.QTCallbackManagement;
/*     */ import quicktime.QTRuntimeException;
/*     */ import quicktime.QTSession;
/*     */
/*     */ final class SoundRunner
/*     */ {
/*   7 */   private static int activeCallbacks = 0;
/*     */   private static Thread idleThread;
/*     */   private static int whichThread;
/*     */   private Thread runnerThread;
/*     */   private SoundMethodClosure mMethodClosure;
/*     */   private SPB soundParamBlock;
/*     */   private SICompletion completion;
/*     */   private SndChannel sndChan;
/*     */   private SoundCallBack callback;
/*  31 */   private boolean notified = false;
/*  32 */   private boolean completionDone = false;
/*     */
/*     */   SoundRunner(SPB paramSPB, SICompletion paramSICompletion)
/*     */   {
/*  13 */     this.soundParamBlock = paramSPB;
/*  14 */     this.completion = paramSICompletion;
/*     */   }
/*     */
/*     */   SoundRunner(SoundCallBack paramSoundCallBack) {
/*  18 */     this.callback = paramSoundCallBack;
/*     */   }
/*     */
/*     */   final void setSndChannel(SndChannel paramSndChannel)
/*     */   {
/*  35 */     this.sndChan = paramSndChannel;
/*     */   }
/*     */
/*     */   private void siCompletion(int paramInt) {
/*  39 */     doNotify();
/*     */   }
/*     */
/*     */   private void sndCallBack(int paramInt1, int paramInt2) {
/*  43 */     doNotify();
/*     */   }
/*     */
/*     */   private synchronized void doWait() {
/*     */     try {
/*  48 */       if (this.notified)
/*  49 */         return;
/*  50 */       wait();
/*  51 */       this.notified = true;
/*     */     } catch (InterruptedException localInterruptedException) {
/*  53 */       this.notified = false;
/*     */     }
/*     */   }
/*     */
/*     */   private synchronized void doNotify() {
/*  58 */     this.notified = true;
/*  59 */     notifyAll();
/*     */   }
/*     */
/*     */   final void cleanup() {
/*  63 */     this.completionDone = true;
/*  64 */     if (QTSession.isCurrentOS(1)) {
/*  65 */       activeCallbacks -= 1;
/*  66 */       if (activeCallbacks < 1) {
/*  67 */         idleThread = null;
/*  68 */         activeCallbacks = 0;
/*     */       }
/*     */     }
/*  71 */     if (!this.notified) {
/*  72 */       doNotify();
/*     */     }
/*  74 */     this.runnerThread = null;
/*     */   }
/*     */
/*     */   final int getClosure() {
/*  78 */     setUpThread();
/*     */
/*  82 */     if (this.mMethodClosure != null) {
/*  83 */       return this.mMethodClosure.getClosure();
/*     */     }
/*  85 */     throw new QTRuntimeException("No Method Closure object created");
/*     */   }
/*     */
/*     */   private void setUpThread() {
/*  89 */     if (this.runnerThread != null) {
/*  90 */       return;
/*     */     }
/*     */
/* 103 */     this.mMethodClosure = (this.soundParamBlock != null ? new SoundMethodClosure(this, "siCompletion", "(I)V", 192) : new SoundMethodClosure(this, "sndCallBack", "(II)V", 960));
/*     */
/* 112 */     if (QTSession.getJavaVersion() == 65537) {
/* 113 */       this.runnerThread = (this.soundParamBlock != null ? new Thread(new CompletionRunner(), "Sound Completion Thread:" + Integer.toString(++whichThread)) : new Thread(new SndCallbackRunner(), "SndChannel CallBack Thread:" + Integer.toString(++whichThread)));
/*     */     }
/*     */     else
/*     */     {
/* 134 */       this.runnerThread = ((Thread)new Object()
/*     */       {
/*     */         Object doPrivelegedAction()
/*     */         {
/* 122 */           return AccessController.doPrivileged(new PrivilegedAction()
/*     */           {
/*     */             public Object run() {
/* 125 */               return SoundRunner.this.soundParamBlock != null ? new Thread(new SoundRunner.CompletionRunner(SoundRunner.this), "Sound Completion Thread:" + Integer.toString(SoundRunner.access$204())) : new Thread(new SoundRunner.SndCallbackRunner(SoundRunner.this), "SndChannel CallBack Thread:" + Integer.toString(SoundRunner.access$204()));
/*     */             }
/*     */
/*     */           });
/*     */         }
/*     */
/*     */       }
/*     */
/* 134 */       .doPrivelegedAction());
/*     */     }
/* 136 */     this.runnerThread.setPriority(10);
/* 137 */     this.notified = false;
/* 138 */     this.completionDone = false;
/* 139 */     this.runnerThread.start();
/*     */   }
/*     */
/*     */   static class MRJIdler
/*     */     implements Runnable
/*     */   {
/*     */     public void run()
/*     */     {
/*     */       try
/*     */       {
/* 222 */         while (SoundRunner.activeCallbacks >= 1)
/*     */         {
/* 224 */           Thread.sleep(10L);
/*     */         }
/*     */       } catch (InterruptedException localInterruptedException) {  }
/*     */
/* 227 */       SoundRunner.access$1002(null);
/*     */     }
/*     */   }
/*     */
/*     */   class SoundMethodClosure
/*     */   {
/*     */     Object mContext;
/*     */     String mMethodname;
/*     */
/*     */     SoundMethodClosure(Object paramString1, String paramString2, String paramInt, int arg5)
/*     */     {
/* 178 */       this.mContext = paramString1;
/* 179 */       this.mMethodname = paramString2;
/*     */
/* 181 */       AccessController.doPrivileged(new PrivilegedAction() { private final SoundRunner val$this$0;
/*     */         private final String val$methodName;
/*     */         private final String val$methodSignature;
/*     */
/* 183 */         public Object run() { QTCallbackManagement.registerForCallback(SoundRunner.SoundMethodClosure.this.mContext, this.val$methodName, this.val$methodSignature);
/* 184 */           return null; }
/*     */       });
/*     */     }
/*     */
/*     */     void dispose()
/*     */     {
/* 190 */       AccessController.doPrivileged(new PrivilegedAction() {
/*     */         public Object run() {
/* 192 */           QTCallbackManagement.unregisterForCallback(SoundRunner.SoundMethodClosure.this.mContext);
/* 193 */           return null;
/*     */         } } );
/*     */     }
/*     */
/*     */     int getClosure() {
/* 198 */       System.out.println("getClosure - context: " + this.mContext.getClass().getName());
/* 199 */       System.out.println("getClosure - context: " + this.mMethodname);
/* 200 */       return this.mContext.hashCode();
/*     */     }
/*     */   }
/*     */
/*     */   class SndCallbackRunner
/*     */     implements Runnable
/*     */   {
/*     */     SndCallbackRunner()
/*     */     {
/*     */     }
/*     */
/*     */     public void run()
/*     */     {
/*     */       while (true)
/*     */       {
/* 160 */         SoundRunner.this.doWait();
/* 161 */         if ((!SoundRunner.this.notified) || (SoundRunner.this.completionDone)) {
/*     */           break;
/*     */         }
/* 164 */         SoundRunner.this.callback.execute(SoundRunner.this.sndChan);
/*     */
/* 166 */         SoundRunner.this.notified = false;
/*     */       }
/*     */
/* 169 */       SoundRunner.this.cleanup();
/*     */     }
/*     */   }
/*     */
/*     */   class CompletionRunner
/*     */     implements Runnable
/*     */   {
/*     */     CompletionRunner()
/*     */     {
/*     */     }
/*     */
/*     */     public void run()
/*     */     {
/*     */       while (true)
/*     */       {
/* 146 */         SoundRunner.this.doWait();
/* 147 */         if ((!SoundRunner.this.notified) || (SoundRunner.this.completionDone))
/*     */           break;
/* 149 */         SoundRunner.this.completion.execute(SoundRunner.this.soundParamBlock);
/* 150 */         SoundRunner.this.notified = false;
/*     */       }
/*     */
/* 153 */       SoundRunner.this.cleanup();
/*     */     }
/*     */   }
/*     */ }

/* Location:           Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name:     quicktime.sound.SoundRunner
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of quicktime.sound.SoundRunner$MRJIdler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.