亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? outputq.cpp

?? 用DirectX制作高級動畫-[Advanced.Animation.with.DirectX]
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//------------------------------------------------------------------------------
// File: OutputQ.cpp
//
// Desc: DirectShow base classes - implements COutputQueue class used by an
//       output pin which may sometimes want to queue output samples on a
//       separate thread and sometimes call Receive() directly on the input
//       pin.
//
// Copyright (c) 1992-2002 Microsoft Corporation.  All rights reserved.
//------------------------------------------------------------------------------


#include <streams.h>


//
//  COutputQueue Constructor :
//
//  Determines if a thread is to be created and creates resources
//
//     pInputPin  - the downstream input pin we're queueing samples to
//
//     phr        - changed to a failure code if this function fails
//                  (otherwise unchanges)
//
//     bAuto      - Ask pInputPin if it can block in Receive by calling
//                  its ReceiveCanBlock method and create a thread if
//                  it can block, otherwise not.
//
//     bQueue     - if bAuto == FALSE then we create a thread if and only
//                  if bQueue == TRUE
//
//     lBatchSize - work in batches of lBatchSize
//
//     bBatchEact - Use exact batch sizes so don't send until the
//                  batch is full or SendAnyway() is called
//
//     lListSize  - If we create a thread make the list of samples queued
//                  to the thread have this size cache
//
//     dwPriority - If we create a thread set its priority to this
//
COutputQueue::COutputQueue(
             IPin         *pInputPin,          //  Pin to send stuff to
             HRESULT      *phr,                //  'Return code'
             BOOL          bAuto,              //  Ask pin if queue or not
             BOOL          bQueue,             //  Send through queue
             LONG          lBatchSize,         //  Batch
             BOOL          bBatchExact,        //  Batch exactly to BatchSize
             LONG          lListSize,
             DWORD         dwPriority,
             bool          bFlushingOpt        // flushing optimization
            ) : m_lBatchSize(lBatchSize),
                m_bBatchExact(bBatchExact && (lBatchSize > 1)),
                m_hThread(NULL),
                m_hSem(NULL),
                m_List(NULL),
                m_pPin(pInputPin),
                m_ppSamples(NULL),
                m_lWaiting(0),
                m_pInputPin(NULL),
                m_bSendAnyway(FALSE),
                m_nBatched(0),
                m_bFlushing(FALSE),
                m_bFlushed(TRUE),
                m_bFlushingOpt(bFlushingOpt),
                m_bTerminate(FALSE),
                m_hEventPop(NULL),
                m_hr(S_OK)
{
    ASSERT(m_lBatchSize > 0);


    if (FAILED(*phr)) {
        return;
    }

    //  Check the input pin is OK and cache its IMemInputPin interface

    *phr = pInputPin->QueryInterface(IID_IMemInputPin, (void **)&m_pInputPin);
    if (FAILED(*phr)) {
        return;
    }

    // See if we should ask the downstream pin

    if (bAuto) {
        HRESULT hr = m_pInputPin->ReceiveCanBlock();
        if (SUCCEEDED(hr)) {
            bQueue = hr == S_OK;
        }
    }

    //  Create our sample batch

    m_ppSamples = new PMEDIASAMPLE[m_lBatchSize];
    if (m_ppSamples == NULL) {
        *phr = E_OUTOFMEMORY;
        return;
    }

    //  If we're queueing allocate resources

    if (bQueue) {
        DbgLog((LOG_TRACE, 2, TEXT("Creating thread for output pin")));
        m_hSem = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);
        if (m_hSem == NULL) {
            DWORD dwError = GetLastError();
            *phr = AmHresultFromWin32(dwError);
            return;
        }
        m_List = new CSampleList(NAME("Sample Queue List"),
                                 lListSize,
                                 FALSE         // No lock
                                );
        if (m_List == NULL) {
            *phr = E_OUTOFMEMORY;
            return;
        }


        DWORD dwThreadId;
        m_hThread = CreateThread(NULL,
                                 0,
                                 InitialThreadProc,
                                 (LPVOID)this,
                                 0,
                                 &dwThreadId);
        if (m_hThread == NULL) {
            DWORD dwError = GetLastError();
            *phr = AmHresultFromWin32(dwError);
            return;
        }
        SetThreadPriority(m_hThread, dwPriority);
    } else {
        DbgLog((LOG_TRACE, 2, TEXT("Calling input pin directly - no thread")));
    }
}

//
//  COutputQueuee Destructor :
//
//  Free all resources -
//
//      Thread,
//      Batched samples
//
COutputQueue::~COutputQueue()
{
    DbgLog((LOG_TRACE, 3, TEXT("COutputQueue::~COutputQueue")));
    /*  Free our pointer */
    if (m_pInputPin != NULL) {
        m_pInputPin->Release();
    }
    if (m_hThread != NULL) {
        {
            CAutoLock lck(this);
            m_bTerminate = TRUE;
            m_hr = S_FALSE;
            NotifyThread();
        }
        DbgWaitForSingleObject(m_hThread);
        EXECUTE_ASSERT(CloseHandle(m_hThread));

        //  The thread frees the samples when asked to terminate

        ASSERT(m_List->GetCount() == 0);
        delete m_List;
    } else {
        FreeSamples();
    }
    if (m_hSem != NULL) {
        EXECUTE_ASSERT(CloseHandle(m_hSem));
    }
    delete [] m_ppSamples;
}

//
//  Call the real thread proc as a member function
//
DWORD WINAPI COutputQueue::InitialThreadProc(LPVOID pv)
{
    HRESULT hrCoInit = CAMThread::CoInitializeHelper();
    
    COutputQueue *pSampleQueue = (COutputQueue *)pv;
    DWORD dwReturn = pSampleQueue->ThreadProc();

    if(hrCoInit == S_OK) {
        CoUninitialize();
    }
    
    return dwReturn;
}

//
//  Thread sending the samples downstream :
//
//  When there is nothing to do the thread sets m_lWaiting (while
//  holding the critical section) and then waits for m_hSem to be
//  set (not holding the critical section)
//
DWORD COutputQueue::ThreadProc()
{
    while (TRUE) {
        BOOL          bWait = FALSE;
        IMediaSample *pSample;
        LONG          lNumberToSend; // Local copy
        NewSegmentPacket* ppacket;

        //
        //  Get a batch of samples and send it if possible
        //  In any case exit the loop if there is a control action
        //  requested
        //
        {
            CAutoLock lck(this);
            while (TRUE) {

                if (m_bTerminate) {
                    FreeSamples();
                    return 0;
                }
                if (m_bFlushing) {
                    FreeSamples();
                    SetEvent(m_evFlushComplete);
                }

                //  Get a sample off the list

                pSample = m_List->RemoveHead();
		// inform derived class we took something off the queue
		if (m_hEventPop) {
                    //DbgLog((LOG_TRACE,3,TEXT("Queue: Delivered  SET EVENT")));
		    SetEvent(m_hEventPop);
		}

                if (pSample != NULL &&
                    !IsSpecialSample(pSample)) {

                    //  If its just a regular sample just add it to the batch
                    //  and exit the loop if the batch is full

                    m_ppSamples[m_nBatched++] = pSample;
                    if (m_nBatched == m_lBatchSize) {
                        break;
                    }
                } else {

                    //  If there was nothing in the queue and there's nothing
                    //  to send (either because there's nothing or the batch
                    //  isn't full) then prepare to wait

                    if (pSample == NULL &&
                        (m_bBatchExact || m_nBatched == 0)) {

                        //  Tell other thread to set the event when there's
                        //  something do to

                        ASSERT(m_lWaiting == 0);
                        m_lWaiting++;
                        bWait      = TRUE;
                    } else {

                        //  We break out of the loop on SEND_PACKET unless
                        //  there's nothing to send

                        if (pSample == SEND_PACKET && m_nBatched == 0) {
                            continue;
                        }

                        if (pSample == NEW_SEGMENT) {
                            // now we need the parameters - we are
                            // guaranteed that the next packet contains them
                            ppacket = (NewSegmentPacket *) m_List->RemoveHead();
			    // we took something off the queue
			    if (m_hEventPop) {
                    	        //DbgLog((LOG_TRACE,3,TEXT("Queue: Delivered  SET EVENT")));
		    	        SetEvent(m_hEventPop);
			    }

                            ASSERT(ppacket);
                        }
                        //  EOS_PACKET falls through here and we exit the loop
                        //  In this way it acts like SEND_PACKET
                    }
                    break;
                }
            }
            if (!bWait) {
                // We look at m_nBatched from the client side so keep
                // it up to date inside the critical section
                lNumberToSend = m_nBatched;  // Local copy
                m_nBatched = 0;
            }
        }

        //  Wait for some more data

        if (bWait) {
            DbgWaitForSingleObject(m_hSem);
            continue;
        }



        //  OK - send it if there's anything to send
        //  We DON'T check m_bBatchExact here because either we've got
        //  a full batch or we dropped through because we got
        //  SEND_PACKET or EOS_PACKET - both of which imply we should
        //  flush our batch

        if (lNumberToSend != 0) {
            long nProcessed;
            if (m_hr == S_OK) {
                ASSERT(!m_bFlushed);
                HRESULT hr = m_pInputPin->ReceiveMultiple(m_ppSamples,
                                                          lNumberToSend,
                                                          &nProcessed);
                /*  Don't overwrite a flushing state HRESULT */
                CAutoLock lck(this);
                if (m_hr == S_OK) {
                    m_hr = hr;
                }
                ASSERT(!m_bFlushed);
            }
            while (lNumberToSend != 0) {
                m_ppSamples[--lNumberToSend]->Release();
            }
            if (m_hr != S_OK) {

                //  In any case wait for more data - S_OK just
                //  means there wasn't an error

                DbgLog((LOG_ERROR, 2, TEXT("ReceiveMultiple returned %8.8X"),
                       m_hr));
            }
        }

        //  Check for end of stream

        if (pSample == EOS_PACKET) {

            //  We don't send even end of stream on if we've previously
            //  returned something other than S_OK
            //  This is because in that case the pin which returned
            //  something other than S_OK should have either sent
            //  EndOfStream() or notified the filter graph

            if (m_hr == S_OK) {
                DbgLog((LOG_TRACE, 2, TEXT("COutputQueue sending EndOfStream()")));
                HRESULT hr = m_pPin->EndOfStream();
                if (FAILED(hr)) {
                    DbgLog((LOG_ERROR, 2, TEXT("COutputQueue got code 0x%8.8X from EndOfStream()")));
                }
            }
        }

        //  Data from a new source

        if (pSample == RESET_PACKET) {
            m_hr = S_OK;
            SetEvent(m_evFlushComplete);
        }

        if (pSample == NEW_SEGMENT) {
            m_pPin->NewSegment(ppacket->tStart, ppacket->tStop, ppacket->dRate);
            delete ppacket;
        }
    }
}

//  Send batched stuff anyway
void COutputQueue::SendAnyway()
{
    if (!IsQueued()) {

        //  m_bSendAnyway is a private parameter checked in ReceiveMultiple

        m_bSendAnyway = TRUE;
        LONG nProcessed;
        ReceiveMultiple(NULL, 0, &nProcessed);
        m_bSendAnyway = FALSE;

    } else {
        CAutoLock lck(this);
        QueueSample(SEND_PACKET);
        NotifyThread();
    }
}

void
COutputQueue::NewSegment(
    REFERENCE_TIME tStart,
    REFERENCE_TIME tStop,
    double dRate)
{
    if (!IsQueued()) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩精品免费观看视频| 国产精品三级av| 91在线精品一区二区三区| 精品一区二区在线视频| 男人的j进女人的j一区| 日本欧美大码aⅴ在线播放| 日韩成人免费电影| 免费xxxx性欧美18vr| 久久se这里有精品| 国产老肥熟一区二区三区| 国产综合久久久久影院| 丰满少妇在线播放bd日韩电影| 国产精品2024| 成人aa视频在线观看| 91极品视觉盛宴| 91精品国产丝袜白色高跟鞋| 日韩免费在线观看| 久久网站热最新地址| 国产欧美日韩在线看| 亚洲视频免费在线| 99久久精品久久久久久清纯| 日韩欧美激情在线| 国产成人精品免费在线| caoporn国产精品| 欧美伊人久久大香线蕉综合69 | 成人午夜av影视| 毛片不卡一区二区| 日本成人在线视频网站| 日本韩国欧美一区| 亚洲精品视频在线观看免费| 99国产精品久| 日韩一区在线播放| 99精品国产一区二区三区不卡| 久久亚洲精华国产精华液 | 欧美成人猛片aaaaaaa| 视频一区二区三区中文字幕| 欧美日韩亚洲高清一区二区| 尤物在线观看一区| 在线精品视频免费播放| 一区二区视频在线看| 在线看一区二区| 亚欧色一区w666天堂| 制服丝袜亚洲色图| 久久精品国产99国产精品| 精品日韩一区二区三区 | 一区在线观看免费| 国产精品一区二区黑丝| 国产欧美日韩麻豆91| 不卡的av电影| 亚洲黄网站在线观看| 69堂精品视频| 国产在线国偷精品产拍免费yy| xnxx国产精品| 99视频在线精品| 亚洲国产视频在线| 日韩美女天天操| 成人午夜精品一区二区三区| 国产精品传媒入口麻豆| 欧美日韩一区二区在线观看| 理论片日本一区| 午夜精品福利在线| 欧美一区二区三区视频在线| 国产精品一区二区三区网站| 自拍偷拍欧美精品| 91麻豆精品国产91久久久久 | 国产一区二区剧情av在线| 国产精品丝袜久久久久久app| 色爱区综合激月婷婷| 日本欧美一区二区三区乱码| 国产精品电影一区二区| 欧美日韩国产在线观看| 国产精品538一区二区在线| 有坂深雪av一区二区精品| 欧美大片一区二区| 色综合婷婷久久| 久久99国产精品免费网站| 国产精品久久久久影视| 91精品国产色综合久久不卡蜜臀 | 成人午夜在线免费| 亚洲va在线va天堂| 国产欧美中文在线| 666欧美在线视频| 97精品超碰一区二区三区| 免费国产亚洲视频| 亚洲激情图片一区| 国产欧美日韩三级| 精品久久免费看| 欧美日韩的一区二区| 成人免费看片app下载| 免费精品视频在线| 亚洲成人黄色影院| 亚洲日本一区二区| 国产欧美精品一区二区三区四区| 3atv在线一区二区三区| 欧美在线影院一区二区| 99这里都是精品| 国产精品自拍网站| 精品在线播放免费| 国产一区二区在线电影| 国产三级三级三级精品8ⅰ区| 国产乱码一区二区三区| 日韩一区二区不卡| 亚洲欧洲综合另类| 国产亚洲精品aa| 26uuu成人网一区二区三区| 宅男在线国产精品| 欧美三级韩国三级日本三斤| 91色.com| 色婷婷亚洲婷婷| 93久久精品日日躁夜夜躁欧美| 国产高清久久久久| 国产盗摄视频一区二区三区| 国产麻豆一精品一av一免费| 麻豆精品视频在线观看视频| 美女网站在线免费欧美精品| 午夜精品成人在线视频| 天天影视色香欲综合网老头| 五月天激情综合网| 午夜精品久久久久久久久久久 | 久久99精品久久久久久动态图| 亚洲人成网站色在线观看| 国产精品不卡一区| 奇米精品一区二区三区在线观看一| 一区二区三区中文字幕电影 | 日韩一区二区免费在线电影| 日韩一级欧美一级| 欧美成人精精品一区二区频| 日韩欧美国产一区在线观看| 精品久久久久香蕉网| 国产清纯在线一区二区www| 国产精品视频看| 亚洲激情网站免费观看| 亚洲电影视频在线| 久久精品国产第一区二区三区| 国产又黄又大久久| a4yy欧美一区二区三区| 欧美色爱综合网| 精品久久人人做人人爰| 国产精品乱码久久久久久| 一区二区三区欧美| 秋霞电影网一区二区| 国产不卡视频在线观看| 色网站国产精品| 日韩一区二区三区在线| 欧美激情一区二区三区蜜桃视频 | 精品捆绑美女sm三区| 中文字幕电影一区| 亚洲国产精品久久久男人的天堂 | 日韩女优毛片在线| 国产精品视频一二三区| 亚洲va欧美va国产va天堂影院| 九九九久久久精品| 一本大道综合伊人精品热热 | 国产日韩精品视频一区| 亚洲另类中文字| 紧缚捆绑精品一区二区| 一本久道中文字幕精品亚洲嫩| 91精品国产综合久久久久久| 国产精品视频一二三| 青娱乐精品视频| 99久久夜色精品国产网站| 欧美丰满少妇xxxxx高潮对白 | 欧美日本不卡视频| 欧美国产日产图区| 日本免费在线视频不卡一不卡二| 成人深夜福利app| 欧美日韩国产免费一区二区| 亚洲成国产人片在线观看| 国产美女在线观看一区| 欧美私模裸体表演在线观看| 国产欧美日韩三级| 精品一区二区三区视频 | 一区二区在线观看av| 国产在线看一区| 欧美乱妇15p| 亚洲精选免费视频| 成人免费视频app| 精品国产精品网麻豆系列| 亚洲妇女屁股眼交7| 99久久精品久久久久久清纯| 国产日产亚洲精品系列| 久久激五月天综合精品| 欧美日韩国产首页在线观看| 亚洲色大成网站www久久九九| 国产精品一卡二卡在线观看| 欧美丰满高潮xxxx喷水动漫| 夜夜精品视频一区二区| 波多野结衣欧美| 欧美国产日韩亚洲一区| 久久66热偷产精品| 欧美刺激午夜性久久久久久久| 亚洲国产中文字幕在线视频综合 | 狠狠色丁香久久婷婷综合丁香| 欧美精品欧美精品系列| 亚洲综合视频在线| 日本道精品一区二区三区| 亚洲视频一区二区免费在线观看| 不卡视频在线观看| 一区精品在线播放| 91首页免费视频|