Esempio n. 1
0
            public override void onDrawFrame(GL10 gl)
            {
                mFrameLock.@lock();
                if (mCurrentFrame != null && !mVideoDisabled)
                {
                    GLES20.glUseProgram(mProgram);

                    if (mTextureWidth != mCurrentFrame.Width || mTextureHeight != mCurrentFrame.Height)
                    {
                        setupTextures(mCurrentFrame);
                    }
                    updateTextures(mCurrentFrame);

                    Matrix.setIdentityM(mScaleMatrix, 0);
                    float scaleX = 1.0f, scaleY = 1.0f;
                    float ratio  = (float)mCurrentFrame.Width / mCurrentFrame.Height;
                    float vratio = (float)mViewportWidth / mViewportHeight;

                    if (mVideoFitEnabled)
                    {
                        if (ratio > vratio)
                        {
                            scaleY = vratio / ratio;
                        }
                        else
                        {
                            scaleX = ratio / vratio;
                        }
                    }
                    else
                    {
                        if (ratio < vratio)
                        {
                            scaleY = vratio / ratio;
                        }
                        else
                        {
                            scaleX = ratio / vratio;
                        }
                    }

                    Matrix.scaleM(mScaleMatrix, 0, scaleX * (mCurrentFrame.MirroredX ? -1.0f : 1.0f), scaleY, 1);

                    int mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
                    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mScaleMatrix, 0);

                    GLES20.glDrawElements(GLES20.GL_TRIANGLES, mVertexIndex.Length, GLES20.GL_UNSIGNED_SHORT, mDrawListBuffer);
                }
                else
                {
                    //black frame when video is disabled
                    gl.glClearColor(0, 0, 0, 1);
                    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
                }
                mFrameLock.unlock();
            }
Esempio n. 2
0
        public override bool destroyCapturer()
        {
            m_captureLock.@lock();
            // release the object
            m_audioRecord.release();
            m_audioRecord           = null;
            m_shutdownCaptureThread = true;
            m_captureEvent.signal();

            m_captureLock.unlock();
            return(true);
        }
Esempio n. 3
0
 /// <summary>
 /// {@inheritDoc}
 /// </summary>
 public override void Drop()
 {
     _commitCloseLock.@lock();
     try
     {
         CommitLockedDrop();
     }
     finally
     {
         _commitCloseLock.unlock();
     }
 }
Esempio n. 4
0
 public override void Close()
 {
     _idContainerLock.@lock();
     try
     {
         _idContainer.close(_highId);
     }
     finally
     {
         _idContainerLock.unlock();
     }
 }
Esempio n. 5
0
 internal virtual void Create()
 {
     PopulatorLock.@lock();
     try
     {
         if (PopulationOngoing)
         {
             Populator.create();
         }
     }
     finally
     {
         PopulatorLock.unlock();
     }
 }
Esempio n. 6
0
        public override bool destroyRenderer()
        {
            m_rendererLock.@lock();
            // release the object
            m_audioTrack.release();
            m_audioTrack           = null;
            m_shutdownRenderThread = true;
            m_renderEvent.signal();
            m_rendererLock.unlock();

            unregisterHeadsetReceiver();
            m_audioManager.SpeakerphoneOn = false;
            m_audioManager.Mode           = AudioManager.MODE_NORMAL;

            return(true);
        }
Esempio n. 7
0
 public override void Close()
 {
     _lockClientCleanupLock.@lock();
     try
     {
         if (_locks != null)
         {
             _locks.close();
             _locks  = null;
             _active = false;
         }
     }
     finally
     {
         _lockClientCleanupLock.unlock();
     }
 }
        /// <summary>
        /// Add one cookie into cookie store.
        /// </summary>
        public virtual void Add(URI uri, HttpCookie cookie)
        {
            // pre-condition : argument can't be null
            if (cookie == null)
            {
                throw new NullPointerException("cookie is null");
            }


            @lock.@lock();
            try
            {
                // remove the ole cookie if there has had one
                CookieJar.Remove(cookie);

                // add new cookie if it has a non-zero max-age
                if (cookie.MaxAge != 0)
                {
                    CookieJar.Add(cookie);
                    // and add it to domain index
                    if (cookie.Domain != null)
                    {
                        AddIndex(DomainIndex, cookie.Domain, cookie);
                    }
                    if (uri != null)
                    {
                        // add it to uri index, too
                        AddIndex(UriIndex, GetEffectiveURI(uri), cookie);
                    }
                }
            }
            finally
            {
                @lock.Unlock();
            }
        }
        /// <summary>
        /// Signals a waiting put. Called only from take/poll.
        /// </summary>
        private void SignalNotFull()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.locks.ReentrantLock putLock = this.putLock;
            ReentrantLock putLock = this.PutLock;

            putLock.@lock();
            try
            {
                NotFull.Signal();
            }
            finally
            {
                putLock.Unlock();
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Signals a waiting take. Called only from put/offer (which do not
        /// otherwise ordinarily lock takeLock.)
        /// </summary>
        private void SignalNotEmpty()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.locks.ReentrantLock takeLock = this.takeLock;
            ReentrantLock takeLock = this.TakeLock;

            takeLock.@lock();
            try
            {
                NotEmpty.Signal();
            }
            finally
            {
                takeLock.Unlock();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Resets the barrier to its initial state.  If any parties are
        /// currently waiting at the barrier, they will return with a
        /// <seealso cref="BrokenBarrierException"/>. Note that resets <em>after</em>
        /// a breakage has occurred for other reasons can be complicated to
        /// carry out; threads need to re-synchronize in some other way,
        /// and choose one to perform the reset.  It may be preferable to
        /// instead create a new barrier for subsequent use.
        /// </summary>
        public virtual void Reset()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.locks.ReentrantLock lock = this.lock;
            ReentrantLock @lock = this.@lock;

            @lock.@lock();
            try
            {
                BreakBarrier();                 // break the current generation
                NextGeneration();               // start a new generation
            }
            finally
            {
                @lock.Unlock();
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Locks to prevent both puts and takes.
 /// </summary>
 internal virtual void FullyLock()
 {
     PutLock.@lock();
     TakeLock.@lock();
 }
Esempio n. 13
0
        /// <summary>
        /// Main barrier code, covering the various policies.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private int dowait(boolean timed, long nanos) throws InterruptedException, BrokenBarrierException, TimeoutException
        private int Dowait(bool timed, long nanos)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.locks.ReentrantLock lock = this.lock;
            ReentrantLock @lock = this.@lock;

            @lock.@lock();
            try
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Generation g = generation;
                Generation g = Generation;

                if (g.Broken)
                {
                    throw new BrokenBarrierException();
                }

                if (Thread.Interrupted())
                {
                    BreakBarrier();
                    throw new InterruptedException();
                }

                int index = --Count;
                if (index == 0)                 // tripped
                {
                    bool ranAction = false;
                    try
                    {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Runnable command = barrierCommand;
                        Runnable command = BarrierCommand;
                        if (command != null)
                        {
                            command.Run();
                        }
                        ranAction = true;
                        NextGeneration();
                        return(0);
                    }
                    finally
                    {
                        if (!ranAction)
                        {
                            BreakBarrier();
                        }
                    }
                }

                // loop until tripped, broken, interrupted, or timed out
                for (;;)
                {
                    try
                    {
                        if (!timed)
                        {
                            Trip.@await();
                        }
                        else if (nanos > 0L)
                        {
                            nanos = Trip.AwaitNanos(nanos);
                        }
                    }
                    catch (InterruptedException ie)
                    {
                        if (g == Generation && !g.Broken)
                        {
                            BreakBarrier();
                            throw ie;
                        }
                        else
                        {
                            // We're about to finish waiting even if we had not
                            // been interrupted, so this interrupt is deemed to
                            // "belong" to subsequent execution.
                            Thread.CurrentThread.Interrupt();
                        }
                    }

                    if (g.Broken)
                    {
                        throw new BrokenBarrierException();
                    }

                    if (g != Generation)
                    {
                        return(index);
                    }

                    if (timed && nanos <= 0L)
                    {
                        BreakBarrier();
                        throw new TimeoutException();
                    }
                }
            }
            finally
            {
                @lock.Unlock();
            }
        }
Esempio n. 14
0
 internal virtual void getFsLock()
 {
     @lock.@lock();
 }
        public override int startCapture()
        {
            if (isCaptureStarted)
            {
                return(-1);
            }

            // Set the preferred capturing size
            configureCaptureSize(PREFERRED_CAPTURE_WIDTH, PREFERRED_CAPTURE_HEIGHT);

            // Set the capture parameters
            Camera.Parameters parameters = mCamera.Parameters;
            parameters.setPreviewSize(mCaptureWidth, mCaptureHeight);
            parameters.PreviewFormat    = PIXEL_FORMAT;
            parameters.PreviewFrameRate = mCaptureFPS;
            try
            {
                mCamera.Parameters = parameters;
            }
            catch (Exception e)
            {
                Log.e(LOGTAG, "setParameters failed", e);
                return(-1);
            }

            // Create capture buffers
            PixelFormat pixelFormat = new PixelFormat();

            PixelFormat.getPixelFormatInfo(PIXEL_FORMAT, pixelFormat);
            int bufSize = mCaptureWidth * mCaptureHeight * pixelFormat.bitsPerPixel / 8;

            sbyte[] buffer = null;
            for (int i = 0; i < mNumCaptureBuffers; i++)
            {
                buffer = new sbyte[bufSize];
                mCamera.addCallbackBuffer(buffer);
            }

            try
            {
                mSurfaceTexture        = new SurfaceTexture(42);
                mCamera.PreviewTexture = mSurfaceTexture;
            }
            catch (Exception e)
            {
                // TODO Auto-generated catch block
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
            }

            // Start preview
            mCamera.PreviewCallbackWithBuffer = this;
            mCamera.startPreview();

            mPreviewBufferLock.@lock();
            mExpectedFrameSize = bufSize;
            isCaptureRunning   = true;
            mPreviewBufferLock.unlock();

            isCaptureStarted = true;

            return(0);
        }