亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
日韩中文字幕91| 欧美日韩国产一区二区三区地区| 欧亚洲嫩模精品一区三区| 欧美成人a视频| 一区二区三区高清在线| 国产成人99久久亚洲综合精品| 欧美少妇bbb| 亚洲欧美日韩国产综合| 国产成人精品一区二| 91精品黄色片免费大全| 一区二区三区91| 99国产精品久久久| 欧美激情一二三区| 国产一区二区久久| 精品国产1区2区3区| 日韩av中文在线观看| 欧美日精品一区视频| 亚洲美女屁股眼交| 91女神在线视频| 国产精品午夜免费| 丁香婷婷深情五月亚洲| 国产亚洲午夜高清国产拍精品| 美脚の诱脚舐め脚责91| 91精品久久久久久久91蜜桃 | 久久在线观看免费| 免费视频最近日韩| 欧美一区二区啪啪| 喷水一区二区三区| 欧美一区二区三区日韩| 日韩av中文字幕一区二区| 91麻豆精品久久久久蜜臀| 手机精品视频在线观看| 欧美一区二区视频网站| 秋霞电影网一区二区| 欧美一区二区三区啪啪| 蜜臀久久99精品久久久久久9| 91精品国产综合久久婷婷香蕉 | 884aa四虎影成人精品一区| 午夜精品久久久久影视| 7777精品伊人久久久大香线蕉经典版下载 | 欧美久久高跟鞋激| 日韩av成人高清| 欧美精品一区二区三| 国产高清在线观看免费不卡| 中文字幕第一页久久| 成人黄色综合网站| 一区二区三区精品| 91精品婷婷国产综合久久竹菊| 久久精品久久综合| 日本一区二区三级电影在线观看| 成人h动漫精品一区二区| 一区二区三区鲁丝不卡| 欧美一区二区在线看| 高清不卡一区二区| 亚洲高清久久久| 亚洲精品在线免费播放| 91丝袜美女网| 美女网站在线免费欧美精品| 国产精品视频看| 欧美日韩一区二区欧美激情| 色天天综合色天天久久| 午夜久久久久久| 国产欧美一区二区在线| 色素色在线综合| 韩国午夜理伦三级不卡影院| ...中文天堂在线一区| 欧美疯狂做受xxxx富婆| 成人妖精视频yjsp地址| 性感美女久久精品| 国产精品视频yy9299一区| 欧美日韩午夜在线| 成人免费精品视频| 日本人妖一区二区| 成人欧美一区二区三区小说| 日韩一区二区精品在线观看| 91在线视频免费91| 精品一区二区三区欧美| 亚洲综合久久久| 国产午夜精品一区二区三区嫩草| 欧美日韩在线播放三区| 国产成人鲁色资源国产91色综 | 欧美夫妻性生活| 99国产精品国产精品毛片| 麻豆一区二区三| 亚洲国产aⅴ成人精品无吗| 中文字幕免费不卡| 日韩精品一区二区三区四区视频 | 日韩欧美专区在线| 欧美做爰猛烈大尺度电影无法无天| 国产乱子伦一区二区三区国色天香| 一区二区久久久久| 国产精品福利av| 久久久国产午夜精品| 日韩一区二区高清| 欧美三级一区二区| 欧美中文字幕一区二区三区亚洲 | 亚洲日本在线天堂| 欧美国产日韩一二三区| 26uuu欧美| 日韩免费看的电影| 欧美一区二区精美| 欧美二区三区91| 欧美日韩日日夜夜| 欧美性猛交xxxx乱大交退制版| 99精品欧美一区二区三区小说 | 欧美国产一区视频在线观看| 精品日产卡一卡二卡麻豆| 国产午夜精品福利| 精品欧美乱码久久久久久1区2区| 91麻豆精品国产自产在线观看一区 | 激情欧美一区二区| 日韩中文字幕亚洲一区二区va在线| 亚洲一区二区高清| 亚洲线精品一区二区三区八戒| 一区二区三区四区蜜桃| 亚洲同性同志一二三专区| 亚洲色图制服诱惑| 亚洲黄色免费电影| 亚洲五码中文字幕| 视频一区二区国产| 久久精品国产精品亚洲红杏| 精品一区二区精品| 国产激情91久久精品导航 | 欧美日韩一区小说| 欧美人成免费网站| 日韩三级免费观看| 久久久国际精品| 中文字幕一区二区三区精华液| 亚洲欧洲一区二区在线播放| 亚洲精品成人a在线观看| 亚洲国产视频在线| 久久电影网站中文字幕| 国产乱码精品一品二品| 成人精品视频.| 欧美日韩精品免费观看视频| 日韩精品一区二区三区蜜臀| 亚洲国产精品国自产拍av| 亚洲欧美激情小说另类| 视频一区视频二区在线观看| 韩国午夜理伦三级不卡影院| 99久久精品情趣| 国产日韩欧美电影| 一区二区免费在线播放| 久久精品国产久精国产| 99国产一区二区三精品乱码| 欧美日韩三级一区二区| 国产情人综合久久777777| 一区二区三区在线免费播放| 精品在线你懂的| 一本色道**综合亚洲精品蜜桃冫| 日韩一区二区三| 亚洲色图一区二区三区| 精品一区二区在线免费观看| 9色porny自拍视频一区二区| 欧美一级理论片| 综合av第一页| 国产一二三精品| 欧美理论在线播放| 国产精品久久精品日日| 久久精品国产一区二区三 | 一区二区三区四区在线免费观看 | 日韩专区在线视频| www.亚洲色图| 精品欧美黑人一区二区三区| 一级日本不卡的影视| 国产成都精品91一区二区三| 在线观看91av| 亚洲男同性视频| 国产剧情一区二区| 91精品国产欧美一区二区18| 亚洲精品高清视频在线观看| 国产suv精品一区二区883| 日韩小视频在线观看专区| 亚洲欧美偷拍另类a∨色屁股| 国产麻豆视频一区二区| 日韩欧美一二三四区| 亚洲成人资源网| 日本丶国产丶欧美色综合| 国产欧美日韩视频在线观看| 久久69国产一区二区蜜臀| 欧美日韩国产高清一区二区三区 | 毛片基地黄久久久久久天堂| 欧美优质美女网站| 亚洲激情五月婷婷| av在线不卡网| 国产精品进线69影院| 高清不卡一二三区| 国产午夜精品一区二区三区嫩草| 韩国av一区二区三区四区| 欧美一区二区三区色| 日日夜夜一区二区| 欧美视频一区二| 亚洲成人免费在线观看| 91成人在线精品| 亚洲最色的网站| 欧美日韩中字一区| 午夜欧美电影在线观看| 欧美日韩电影一区| 日韩av电影天堂| 欧美va在线播放|