50 return VFW_E_ALREADY_CONNECTED;
53 HRESULT
hr = pUnk->QueryInterface(IID_IAsyncReader, (
void**)&m_pReader);
58 AM_MEDIA_TYPE * pmt =
NULL;
72 AM_MEDIA_TYPE * pmt =
NULL;
80 LONGLONG llTotal, llAvail;
81 hr = m_pReader->Length(&llTotal, &llAvail);
87 AM_MEDIA_TYPE * pmt =
NULL;
96 m_tDuration = llTotal *
UNITS;
97 m_tStop = m_tDuration;
104 AM_MEDIA_TYPE * pmt =
NULL;
128 m_pReader->Release();
147 IMemAllocator * pAlloc,
148 __inout_opt ALLOCATOR_PROPERTIES * pProps)
150 ALLOCATOR_PROPERTIES *pRequest;
151 ALLOCATOR_PROPERTIES Request;
152 if (pProps ==
NULL) {
153 Request.cBuffers = 3;
154 Request.cbBuffer = 64*1024;
156 Request.cbPrefix = 0;
161 HRESULT
hr = m_pReader->RequestAllocator(
173 return StartThread();
190 ThreadMsg AtStart = m_State;
192 if (AtStart == TM_Start) {
202 if (AtStart == TM_Start) {
212 *ptDuration = m_tDuration;
218 CPullPin::StartThread()
227 if (!ThreadExists()) {
242 hr = (HRESULT) CallWorker(m_State);
247 CPullPin::PauseThread()
251 if (!ThreadExists()) {
257 HRESULT
hr = m_pReader->BeginFlush();
263 hr = CallWorker(TM_Pause);
265 m_pReader->EndFlush();
270 CPullPin::StopThread()
274 if (!ThreadExists()) {
280 HRESULT
hr = m_pReader->BeginFlush();
286 hr = CallWorker(TM_Exit);
288 m_pReader->EndFlush();
303 CPullPin::ThreadProc(
void)
306 DWORD cmd = GetRequest();
329 m_pReader->BeginFlush();
331 m_pReader->EndFlush();
336 CPullPin::QueueSample(
337 __inout REFERENCE_TIME& tCurrent,
338 REFERENCE_TIME tAlignStop,
342 IMediaSample* pSample;
349 LONGLONG tStopThis = tCurrent + (pSample->GetSize() *
UNITS);
350 if (tStopThis > tAlignStop) {
351 tStopThis = tAlignStop;
353 pSample->SetTime(&tCurrent, &tStopThis);
354 tCurrent = tStopThis;
356 pSample->SetDiscontinuity(bDiscontinuity);
358 hr = m_pReader->Request(
371 CPullPin::CollectAndDeliver(
372 REFERENCE_TIME tStart,
373 REFERENCE_TIME tStop)
375 IMediaSample* pSample =
NULL;
377 HRESULT
hr = m_pReader->WaitForNext(
386 hr = DeliverSample(pSample, tStart, tStop);
397 CPullPin::DeliverSample(
398 IMediaSample* pSample,
399 REFERENCE_TIME tStart,
404 REFERENCE_TIME t1, t2;
405 if (S_OK == pSample->GetTime(&t1, &t2)) {
413 HRESULT
hr = pSample->SetTime(&t1, &t2);
421 AM_MEDIA_TYPE * pmt =
NULL;
422 pSample->GetMediaType( &pmt );
433 CPullPin::Process(
void)
436 if (m_tStop <= m_tStart) {
441 BOOL bDiscontinuity = TRUE;
446 ALLOCATOR_PROPERTIES Actual;
447 HRESULT
hr =
m_pAlloc->GetProperties(&Actual);
451 REFERENCE_TIME tCurrent = tStart;
453 REFERENCE_TIME tStop = m_tStop;
454 if (tStop > m_tDuration) {
469 while (tCurrent < tAlignStop) {
473 if (CheckRequest(&dwRequest)) {
478 if (Actual.cBuffers > 1) {
480 hr = QueueSample(tCurrent, tAlignStop, TRUE);
481 bDiscontinuity = FALSE;
491 while (tCurrent < tAlignStop) {
493 hr = QueueSample(tCurrent, tAlignStop, bDiscontinuity);
494 bDiscontinuity = FALSE;
500 hr = CollectAndDeliver(tStart, tStop);
509 if (Actual.cBuffers > 1) {
510 hr = CollectAndDeliver(tStart, tStop);
519 while (tCurrent < tAlignStop) {
523 if (CheckRequest(&dwRequest)) {
527 IMediaSample* pSample;
535 LONGLONG tStopThis = tCurrent + (pSample->GetSize() *
UNITS);
536 if (tStopThis > tAlignStop) {
537 tStopThis = tAlignStop;
539 pSample->SetTime(&tCurrent, &tStopThis);
540 tCurrent = tStopThis;
542 if (bDiscontinuity) {
543 pSample->SetDiscontinuity(TRUE);
544 bDiscontinuity = FALSE;
547 hr = m_pReader->SyncReadAligned(pSample);
555 hr = DeliverSample(pSample, tStart, tStop);
571 CPullPin::CleanupCancelled(
void)
574 IMediaSample * pSample;
577 HRESULT
hr = m_pReader->WaitForNext(