private bool handlePlaybackInterrupt(InterruptedException interruption, SeekExecutor seekExecutor)
        {
            java.lang.Thread.interrupted();

            if (checkStopped())
            {
                markerTracker.trigger(STOPPED);
                return(false);
            }
            else if (checkPendingSeek(seekExecutor))
            {
                // Double-check, might have received a stop request while seeking
                if (checkStopped())
                {
                    markerTracker.trigger(STOPPED);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else if (interruption != null)
            {
                System.Threading.Thread.CurrentThread.Interrupt();
                throw new FriendlyException("The track was unexpectedly terminated.", SUSPICIOUS, interruption);
            }
            else
            {
                return(true);
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @After public void tearDown()
        public virtual void TearDown()
        {
            InterruptedException exception = _pools.shutDownAll();

            if (exception != null)
            {
                throw new Exception("Test was interrupted?", exception);
            }
        }
Exemple #3
0
            public void stopRecording()
            {
                Microphone.access_100(this.this_0).stop();
                object obj;

                System.Exception     ex2;
                InterruptedException ex4;

                try
                {
                    System.Threading.Monitor.Enter(obj = this.@lock);
                    try
                    {
                        while (!this.done)
                        {
                            Object.instancehelper_wait(this.@lock);
                        }
                        System.Threading.Monitor.Exit(obj);
                    }
                    catch (System.Exception ex)
                    {
                        ex2 = ex;
                        goto IL_54;
                    }
                    goto IL_57;
                }
                catch (InterruptedException ex3)
                {
                    ex4 = ex3;
                    goto IL_59;
                }
IL_54:
                InterruptedException ex8;

                try
                {
                    System.Threading.Monitor.Exit(obj);
                    throw ex2;
                }
                catch (InterruptedException ex7)
                {
                    ex8 = ex7;
                }
                InterruptedException ex9 = ex8;

                goto IL_7E;
IL_57:
                return;

IL_59:
                ex9 = ex4;
IL_7E:
                InterruptedException ex10 = ex9;

                Throwable.instancehelper_printStackTrace(ex10);
            }
Exemple #4
0
 internal void ShutDown()
 {
     _executor.shutdown();
     try
     {
         _executor.awaitTermination(30, TimeUnit.SECONDS);
     }
     catch (InterruptedException e)
     {
         _shutdownInterrupted = e;
     }
 }
 private InterruptedException ShutdownPool(ExecutorService pool, InterruptedException exception)
 {
     if (pool != null)
     {
         pool.shutdown();
         try
         {
             pool.awaitTermination(30, TimeUnit.SECONDS);
         }
         catch (InterruptedException e)
         {
             return(Exceptions.chain(exception, e));
         }
     }
     return(exception);
 }
        /// <summary>
        /// Execute the read and seek loop for the track. </summary>
        /// <param name="readExecutor"> Callback for reading the track </param>
        /// <param name="seekExecutor"> Callback for performing a seek on the track, may be null on a non-seekable track </param>
        public virtual void executeProcessingLoop(ReadExecutor readExecutor, SeekExecutor seekExecutor)
        {
            bool proceed = true;

            checkPendingSeek(seekExecutor);

            while (proceed)
            {
                state.set(AudioTrackState.PLAYING);
                proceed = false;

                try
                {
                    // An interrupt may have been placed while we were handling the previous one.
                    if (java.lang.Thread.interrupted() && !handlePlaybackInterrupt(null, seekExecutor))
                    {
                        break;
                    }

                    InterruptibleForSeek = true;
                    readExecutor.performRead();
                    InterruptibleForSeek = false;

                    // Must not finish before terminator frame has been consumed the user may still want to perform seeks until then
                    waitOnEnd();
                }
                catch (System.Exception e)
                {
                    InterruptibleForSeek = false;
                    InterruptedException interruption = findInterrupt(e);

                    if (interruption != null)
                    {
                        proceed = handlePlaybackInterrupt(interruption, seekExecutor);
                    }
                    else
                    {
                        throw ExceptionTools.wrapUnfriendlyExceptions("Something went wrong when decoding the track.", FAULT, e);
                    }
                }
            }
        }
        private InterruptedException findInterrupt(System.Exception throwable)
        {
            InterruptedException exception = ExceptionTools.findDeepException <InterruptedException>(throwable, typeof(InterruptedException));

            if (exception == null)
            {
                InterruptedIOException ioException = ExceptionTools.findDeepException <InterruptedIOException>(throwable, typeof(InterruptedIOException));

                if (ioException != null && (ioException.Message == null || !ioException.Message.Contains("timed out")))
                {
                    exception = new InterruptedException(ioException.Message);
                }
            }

            if (exception == null && java.lang.Thread.interrupted())
            {
                return(new InterruptedException());
            }

            return(exception);
        }
        public override void Shutdown()
        {
            _started = false;

            // First shut down the scheduler, so no new tasks are queued up in the pools.
            InterruptedException exception = ShutDownScheduler();

            // Then shut down the thread pools. This involves cancelling jobs which hasn't been cancelled already,
            // so we avoid having to wait the full maximum wait time on the executor service shut-downs.
            exception = Exceptions.chain(exception, _pools.shutDownAll());

            // Finally, we shut the work-stealing executors down.
            foreach (ExecutorService workStealingExecutor in _workStealingExecutors.Values)
            {
                exception = ShutdownPool(workStealingExecutor, exception);
            }
            _workStealingExecutors.Clear();

            if (exception != null)
            {
                throw new Exception("Unable to shut down job scheduler properly.", exception);
            }
        }
        public void execute(TrackStateListener listener)
        {
            InterruptedException interrupt = null;

            if (java.lang.Thread.interrupted())
            {
                log.LogDebug("Cleared a stray interrupt.");
            }

            if (playingThread.compareAndSet(null, System.Threading.Thread.CurrentThread))
            {
                log.LogDebug("Starting to play track {} locally with listener {}", audioTrack.Info.identifier, listener);

                state.set(AudioTrackState.LOADING);

                try
                {
                    audioTrack.process(this);

                    log.LogDebug("Playing track {} finished or was stopped.", audioTrack.Identifier);
                }
                catch (System.Exception e)
                {
                    // Temporarily clear the interrupted status so it would not disrupt listener methods.
                    interrupt = findInterrupt(e);

                    if (interrupt != null && checkStopped())
                    {
                        log.LogDebug("Track {} was interrupted outside of execution loop.", audioTrack.Identifier);
                    }
                    else
                    {
                        frameBuffer.setTerminateOnEmpty();

                        FriendlyException exception = ExceptionTools.wrapUnfriendlyExceptions("Something broke when playing the track.", FAULT, e);
                        ExceptionTools.log(log, exception, "playback of " + audioTrack.Identifier);

                        trackException = exception;
                        listener.onTrackException(audioTrack, exception);

                        ExceptionTools.rethrowErrors(e);
                    }
                }
                finally
                {
                    lock (actionSynchronizer)
                    {
                        interrupt = interrupt != null ? interrupt : findInterrupt(null);

                        playingThread.compareAndSet(System.Threading.Thread.CurrentThread, null);

                        markerTracker.trigger(ENDED);
                        state.set(AudioTrackState.FINISHED);
                    }

                    if (interrupt != null)
                    {
                        System.Threading.Thread.CurrentThread.Interrupt();
                    }
                }
            }
            else
            {
                log.LogWarning("Tried to start an already playing track {}", audioTrack.Identifier);
            }
        }
Exemple #10
0
        public virtual void AES256IGEDecrypt(byte[] src, byte[] dest, int len, byte[] iv, byte[] key)
        {
            int           expressionStack_AF_0;
            AESFastEngine engine = new AESFastEngine();

            engine.init(false, new KeyParameter(key));
            int num = len / 0x10;

            byte[] buffer  = iv;
            byte[] buffer2 = iv;
            int    num2    = 0x10;
            int    num3    = 0;
            int    num4    = 0;

Label_0029:
            if (num4 >= num)
            {
                return;
            }
            int inOff = num4 * 0x10;
            int num6  = 0;

            while (true)
            {
                if (num6 >= 0x10)
                {
                    break;
                }
                dest[inOff + num6] = (byte)((sbyte)(src[inOff + num6] ^ buffer[num2 + num6]));
                num6++;
            }
            engine.processBlock(dest, inOff, dest, inOff);
            num6 = 0;
            while (true)
            {
                if (num6 >= 0x10)
                {
                    break;
                }
                dest[inOff + num6] = (byte)((sbyte)(dest[inOff + num6] ^ buffer2[num3 + num6]));
                num6++;
            }
            buffer2 = src;
            num3    = inOff;
            buffer  = dest;
            num2    = inOff;
            if (0x1f != -1)
            {
                int expressionStack_AE_1 = num4;
                int expressionStack_AE_0 = 0x1f;
                expressionStack_AF_0 = expressionStack_AE_1 % expressionStack_AE_0;
                goto Label_00AF;
            }
            else
            {
                int expressionStack_A9_1 = num4;
            }
            expressionStack_AF_0 = 0;
Label_00AF:
            if (expressionStack_AF_0 == 0x20)
            {
                try
                {
                    Thread.sleep(10L);
                }
                catch (InterruptedException exception1)
                {
                    InterruptedException exception2 = ByteCodeHelper.MapException <InterruptedException>(exception1, 1);
                    Throwable.instancehelper_printStackTrace(exception2);
                }
            }
            num4++;
            goto Label_0029;
        }
Exemple #11
0
 private Exception HandleInterrupted(InterruptedException e)
 {
     Thread.interrupted();
     return(new Exception("Got interrupted while awaiting workers (" + _names + ") to complete", e));
 }
Exemple #12
0
 public virtual void interruptedWhileShuttingDownThreadPool(InterruptedException e)
 {
     logError("034", "Interrupted while shutting down thread pool", e);
 }
Exemple #13
0
 public void OnInterrupted(InterruptedException e) => Log.Warn("ANRWatchdog", $"Interrupted: {e.Message}");
Exemple #14
0
 public virtual void interruptedWhileShuttingDownjobExecutor(InterruptedException e)
 {
     logWarn("010", "Interrupted while shutting down the job executor", e);
 }