From aea60e8f31f3af430d280739f37f8a33f88d9cb3 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Fri, 18 Jul 2008 15:49:31 -0700 Subject: [PATCH] quartz: Fix handling of zero byte samples and end of streams --- dlls/quartz/avisplit.c | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-) diff --git a/dlls/quartz/avisplit.c b/dlls/quartz/avisplit.c index 2bbd8f1..a1e32e9 100644 --- a/dlls/quartz/avisplit.c +++ b/dlls/quartz/avisplit.c @@ -147,7 +147,6 @@ static HRESULT AVISplitter_next_request(AVISplitterImpl *This, DWORD streamnumbe PullPin *pin = This->Parser.pInputPin; IMediaSample *sample = NULL; HRESULT hr; - BOOL endofstream = FALSE; TRACE("(%p, %u)->()\n", This, streamnumber); @@ -198,7 +197,7 @@ static HRESULT AVISplitter_next_request(AVISplitterImpl *This, DWORD streamnumbe TRACE("offset(%u) size(%u)\n", (DWORD)BYTES_FROM_MEDIATIME(rtSampleStart), (DWORD)BYTES_FROM_MEDIATIME(rtSampleStop - rtSampleStart)); /* End of file */ - if (stream->index_next >= stream->entries) + if (stream->index >= stream->entries) { ERR("END OF STREAM ON %u\n", streamnumber); IMediaSample_Release(sample); @@ -239,14 +238,14 @@ static HRESULT AVISplitter_next_request(AVISplitterImpl *This, DWORD streamnumbe && StreamFromFOURCC(This->oldindex->aIndex[stream->pos_next].dwChunkId) != streamnumber); /* End of file */ - if (stream->pos_next * sizeof(This->oldindex->aIndex[0]) >= This->oldindex->cb) + if (stream->index) { IMediaSample_Release(sample); stream->pos_next = 0; ++stream->index_next; ERR("END OF STREAM ON %u\n", streamnumber); hr = AVISplitter_SendEndOfFile(This, streamnumber); - endofstream = TRUE; + return S_FALSE; } } else /* TODO: Generate an index automagically */ @@ -255,12 +254,21 @@ static HRESULT AVISplitter_next_request(AVISplitterImpl *This, DWORD streamnumbe assert(0); } - hr = IMediaSample_SetTime(sample, &rtSampleStart, &rtSampleStop); + if (rtSampleStart != rtSampleStop) + { + hr = IMediaSample_SetTime(sample, &rtSampleStart, &rtSampleStop); - hr = IAsyncReader_Request(pin->pReader, sample, streamnumber); + hr = IAsyncReader_Request(pin->pReader, sample, streamnumber); - if (FAILED(hr)) - assert(IMediaSample_Release(sample) == 0); + if (FAILED(hr)) + assert(IMediaSample_Release(sample) == 0); + } + else + { + stream->sample = sample; + IMediaSample_SetActualDataLength(sample, 0); + SetEvent(stream->packet_queued); + } } else { @@ -272,9 +280,6 @@ static HRESULT AVISplitter_next_request(AVISplitterImpl *This, DWORD streamnumbe } TRACE("--> %08x\n", hr); - if (endofstream && hr == S_OK) - return S_FALSE; - return hr; } @@ -360,7 +365,10 @@ static HRESULT AVISplitter_Sample(LPVOID iface, IMediaSample * pSample, DWORD_PT HRESULT hr = S_OK; if (!IMediaSample_GetActualDataLength(pSample)) + { + ERR("Received empty sample\n"); return S_OK; + } /* Send the sample to whatever thread is appropiate * That thread should also not have a sample queued at the moment -- 1.5.4.1