示例#1
0
        public ResourceHandle SafeGetBufferHandle()
        {
            ResourceHandle resourceHandle = null;

            lock (this)
            {
                if (mFrameBuffer == null)
                {
                    return(null);
                }
                resourceHandle = mFrameBuffer.GetHandle(mNumSamples);
                if (!mFrameBuffer.mIsInitialized)
                {
                    SampleBuffer buffer = resourceHandle.Get() as SampleBuffer;
                    DecompressFrame(buffer.mDecomp, ref buffer.mDecodedSamples);
                    mFrameBuffer.mIsInitialized = true;
                    mSamples = buffer.mDecodedSamples;
                }
                foreach (Frame f in mThreadFrames)
                {
                    resourceHandle.AddDependentHandle(f.SafeGetBufferHandle());
                }
            }
            return(resourceHandle);
        }
示例#2
0
        public void insertCompressedFrame(CompressedFrame frame)
        {
            //SampleBuffer buffer = mBuffers[mProcessSampleBufferID] as SampleBuffer;
            SampleBuffer buffer = mProcessSampleBuffer;

            if (frame.mNumSamples > buffer.mSize)
            {
                frame.mNumSamples = buffer.mSize;
            }
            mCurrentFrame = new Frame(frame, mSections);

            //if (mLastFrame != null && mLastFrame.mFrameNumber == 2363)
            //{
            //   int count = 3;
            //}

            if (mCurrentFrame.DecompressFrame(buffer.mDecomp, ref buffer.mDecodedSamples) == true)
            {
                if (buffer.mDecodedSamples[0].mSectionID < mSections.Length &&
                    mSections[buffer.mDecodedSamples[0].mSectionID] != null &&
                    (mSections[buffer.mDecodedSamples[0].mSectionID].mName == "Frame"))
                {
                    mNumFullFrames++;
                    if (mNumFullFrames >= mMaxFullFrames)
                    {
                        CleanupFrameMemory();
                    }

                    if (mLastFrame != null)
                    {
                        mLastFrame.mNextFrame    = mCurrentFrame;
                        mCurrentFrame.mLastFrame = mLastFrame;

                        mLastFrame.CalculateFinalStats();
                        mLastFrame.mNextFrameStartTime = mCurrentFrame.mStartTime;
                        FrameStats();//mCurrentFrame;
                        OnNewFrame(mLastFrame);
                        mFrames.Add(mLastFrame);
                    }
                    mLastFrame = mCurrentFrame;
                    ArrayList temp = new ArrayList();
                    foreach (Frame t in mFutureFrameBuffer)
                    {
                        if (t.mFrameNumber == mLastFrame.mFrameNumber)
                        {
                            mLastFrame.mThreadFrames.Add(t);
                        }
                        else
                        {
                            temp.Add(t);
                        }
                    }
                    mFutureFrameBuffer = temp;
                    if (mFutureFrameBuffer.Count > 0)
                    {
                        "asdf".ToString();
                        //oops
                    }
                }
                else if (mLastFrame != null)//if thread data
                {
                    //mLastFrame.AddThreadFrame(mCurrentFrame);

                    if (mLastFrame.mFrameNumber == mCurrentFrame.mFrameNumber)
                    {
                        mLastFrame.AddThreadFrame(mCurrentFrame);
                    }
                    //Match up out of order data...
                    else if (mLastFrame.mFrameNumber < mCurrentFrame.mFrameNumber)
                    {
                        mFutureFrameBuffer.Add(mCurrentFrame);
                    }
                    else if (mLastFrame.mFrameNumber > mCurrentFrame.mFrameNumber)
                    {
                        ulong back = mLastFrame.mFrameNumber - mCurrentFrame.mFrameNumber;
                        Frame prev = mLastFrame.mLastFrame;
                        for (ulong i = 0; i < back; i++)
                        {
                            if (prev == null)
                            {
                                break;
                            }
                            if (prev.mThreadID == mCurrentFrame.mThreadID)
                            {
                                prev.AddThreadFrame(mCurrentFrame);
                            }
                            prev = mLastFrame.mLastFrame;
                        }
                    }
                }
            }
        }