quartz: Make the sample proc responsible for retrieving the sample.
Henri Verbeet
hverbeet at codeweavers.com
Mon Mar 23 03:42:27 CDT 2009
This is needed by the next patch, but it probably makes the code easier to
follow anyway.
---
dlls/quartz/avisplit.c | 36 +++++++++++++++++++++---------------
dlls/quartz/mpegsplit.c | 18 +++++++++++++++++-
dlls/quartz/parser.h | 2 +-
dlls/quartz/pin.c | 35 +----------------------------------
dlls/quartz/pin.h | 5 +----
dlls/quartz/waveparser.c | 19 ++++++++++++++++++-
6 files changed, 59 insertions(+), 56 deletions(-)
diff --git a/dlls/quartz/avisplit.c b/dlls/quartz/avisplit.c
index faa844b..25bcbfb 100644
--- a/dlls/quartz/avisplit.c
+++ b/dlls/quartz/avisplit.c
@@ -366,15 +366,32 @@ static DWORD WINAPI AVISplitter_thread_reader(LPVOID data)
return hr;
}
-static HRESULT AVISplitter_Sample(LPVOID iface, IMediaSample * pSample, DWORD_PTR cookie)
+static HRESULT AVISplitter_Sample(LPVOID iface)
{
AVISplitterImpl *This = iface;
- StreamData *stream = This->streams + cookie;
- HRESULT hr = S_OK;
+ IMediaSample *pSample;
+ StreamData *stream;
+ DWORD_PTR cookie;
+ HRESULT hr;
+
+ hr = IAsyncReader_WaitForNext(This->Parser.pInputPin->pReader, 10000, &pSample, &cookie);
+ if (FAILED(hr))
+ {
+ ERR("Processing error: %x\n", hr);
+ if (hr == VFW_E_TIMEOUT)
+ {
+ assert(!pSample);
+ return S_OK;
+ }
+ return hr;
+ }
+
+ stream = This->streams + cookie;
if (!IMediaSample_GetActualDataLength(pSample))
{
ERR("Received empty sample\n");
+ IMediaSample_Release(pSample);
return S_OK;
}
@@ -387,8 +404,6 @@ static HRESULT AVISplitter_Sample(LPVOID iface, IMediaSample * pSample, DWORD_PT
assert(!stream->sample);
assert(WaitForSingleObject(stream->packet_queued, 0) == WAIT_TIMEOUT);
- IMediaSample_AddRef(pSample);
-
stream->sample = pSample;
SetEvent(stream->packet_queued);
@@ -433,16 +448,7 @@ static HRESULT AVISplitter_first_request(LPVOID iface)
* would have no guarantees that it's successful at all
*/
- if (have_sample)
- {
- DWORD_PTR dwUser = ~0;
- hr = IAsyncReader_WaitForNext(This->Parser.pInputPin->pReader, 10000, &sample, &dwUser);
- assert(hr == S_OK);
- assert(sample);
-
- AVISplitter_Sample(iface, sample, dwUser);
- IMediaSample_Release(sample);
- }
+ if (have_sample) AVISplitter_Sample(iface);
hr = AVISplitter_next_request(This, x);
TRACE("-->%08x\n", hr);
diff --git a/dlls/quartz/mpegsplit.c b/dlls/quartz/mpegsplit.c
index 373e537..a97a8c9 100644
--- a/dlls/quartz/mpegsplit.c
+++ b/dlls/quartz/mpegsplit.c
@@ -241,15 +241,29 @@ static HRESULT FillBuffer(MPEGSplitterImpl *This, IMediaSample *pCurrentSample)
}
-static HRESULT MPEGSplitter_process_sample(LPVOID iface, IMediaSample * pSample, DWORD_PTR cookie)
+static HRESULT MPEGSplitter_process_sample(LPVOID iface)
{
MPEGSplitterImpl *This = iface;
BYTE *pbSrcStream;
DWORD cbSrcStream = 0;
REFERENCE_TIME tStart, tStop, tAviStart = This->position;
Parser_OutputPin * pOutputPin;
+ IMediaSample *pSample;
+ DWORD_PTR cookie;
HRESULT hr;
+ hr = IAsyncReader_WaitForNext(This->Parser.pInputPin->pReader, 10000, &pSample, &cookie);
+ if (FAILED(hr))
+ {
+ ERR("Processing error: %x\n", hr);
+ if (hr == VFW_E_TIMEOUT)
+ {
+ assert(!pSample);
+ return S_OK;
+ }
+ return hr;
+ }
+
pOutputPin = (Parser_OutputPin*)This->Parser.ppPins[1];
hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
@@ -263,6 +277,7 @@ static HRESULT MPEGSplitter_process_sample(LPVOID iface, IMediaSample * pSample,
if (cbSrcStream == 0)
{
FIXME(".. Why do I need you?\n");
+ IMediaSample_Release(pSample);
return S_OK;
}
@@ -271,6 +286,7 @@ static HRESULT MPEGSplitter_process_sample(LPVOID iface, IMediaSample * pSample,
/* Now, try to find a new header */
hr = FillBuffer(This, pSample);
+ IMediaSample_Release(pSample);
if (hr != S_OK)
{
WARN("Failed with hres: %08x!\n", hr);
diff --git a/dlls/quartz/parser.h b/dlls/quartz/parser.h
index b542388..747c713 100644
--- a/dlls/quartz/parser.h
+++ b/dlls/quartz/parser.h
@@ -20,7 +20,7 @@
typedef struct ParserImpl ParserImpl;
-typedef HRESULT (*PFN_PROCESS_SAMPLE) (LPVOID iface, IMediaSample * pSample, DWORD_PTR cookie);
+typedef HRESULT (*PFN_PROCESS_SAMPLE) (LPVOID iface);
typedef HRESULT (*PFN_QUERY_ACCEPT) (LPVOID iface, const AM_MEDIA_TYPE * pmt);
typedef HRESULT (*PFN_PRE_CONNECT) (IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *prop);
typedef HRESULT (*PFN_CLEANUP) (LPVOID iface);
diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c
index 2e24d52..cfc204b 100644
--- a/dlls/quartz/pin.c
+++ b/dlls/quartz/pin.c
@@ -1279,7 +1279,6 @@ static void PullPin_Flush(PullPin *This)
static void PullPin_Thread_Process(PullPin *This)
{
HRESULT hr;
- IMediaSample * pSample = NULL;
ALLOCATOR_PROPERTIES allocProps;
hr = IMemAllocator_GetProperties(This->pAlloc, &allocProps);
@@ -1310,43 +1309,11 @@ static void PullPin_Thread_Process(PullPin *This)
if (SUCCEEDED(hr))
do
{
- DWORD_PTR dwUser;
-
TRACE("Process sample\n");
- pSample = NULL;
- hr = IAsyncReader_WaitForNext(This->pReader, 10000, &pSample, &dwUser);
-
- /* Return an empty sample on error to the implementation in case it does custom parsing, so it knows it's gone */
- if (SUCCEEDED(hr))
- {
- hr = This->fnSampleProc(This->pin.pUserData, pSample, dwUser);
- }
- else
- {
- /* FIXME: This is not well handled yet! */
- ERR("Processing error: %x\n", hr);
- if (hr == VFW_E_TIMEOUT)
- {
- assert(!pSample);
- hr = S_OK;
- continue;
- }
- }
-
- if (pSample)
- {
- IMediaSample_Release(pSample);
- pSample = NULL;
- }
+ hr = This->fnSampleProc(This->pin.pUserData);
} while (This->rtCurrent < This->rtStop && hr == S_OK && !This->stop_playback);
- /* Sample was rejected, and we are asked to terminate */
- if (pSample)
- {
- IMediaSample_Release(pSample);
- }
-
/* Can't reset state to Sleepy here because that might race, instead PauseProcessing will do that for us
* Flush remaining samples
*/
diff --git a/dlls/quartz/pin.h b/dlls/quartz/pin.h
index 2cbaddb..4852a87 100644
--- a/dlls/quartz/pin.h
+++ b/dlls/quartz/pin.h
@@ -20,12 +20,9 @@
/* This function will process incoming samples to the pin.
* Any return value valid in IMemInputPin::Receive is allowed here
- *
- * Cookie is the cookie that was set when requesting the buffer, if you don't
- * implement custom requesting, you can safely ignore this
*/
typedef HRESULT (* SAMPLEPROC_PUSH)(LPVOID userdata, IMediaSample * pSample);
-typedef HRESULT (* SAMPLEPROC_PULL)(LPVOID userdata, IMediaSample * pSample, DWORD_PTR cookie);
+typedef HRESULT (* SAMPLEPROC_PULL)(LPVOID userdata);
/* This function will determine whether a type is supported or not.
* It is allowed to return any error value (within reason), as opposed
diff --git a/dlls/quartz/waveparser.c b/dlls/quartz/waveparser.c
index cbdfceb..1cb3e03 100644
--- a/dlls/quartz/waveparser.c
+++ b/dlls/quartz/waveparser.c
@@ -71,7 +71,7 @@ static LONGLONG duration_to_bytepos(WAVEParserImpl *This, LONGLONG duration)
return MEDIATIME_FROM_BYTES(bytepos);
}
-static HRESULT WAVEParser_Sample(LPVOID iface, IMediaSample * pSample, DWORD_PTR cookie)
+static HRESULT WAVEParser_Sample(LPVOID iface)
{
WAVEParserImpl *This = iface;
LPBYTE pbSrcStream = NULL;
@@ -81,6 +81,20 @@ static HRESULT WAVEParser_Sample(LPVOID iface, IMediaSample * pSample, DWORD_PTR
IMediaSample *newsample = NULL;
Parser_OutputPin *pOutputPin;
PullPin *pin = This->Parser.pInputPin;
+ IMediaSample *pSample;
+ DWORD_PTR cookie;
+
+ hr = IAsyncReader_WaitForNext(pin->pReader, 10000, &pSample, &cookie);
+ if (FAILED(hr))
+ {
+ ERR("Processing error: %x\n", hr);
+ if (hr == VFW_E_TIMEOUT)
+ {
+ assert(!pSample);
+ return S_OK;
+ }
+ return hr;
+ }
IMediaSample_GetPointer(pSample, &pbSrcStream);
hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
@@ -91,6 +105,7 @@ static HRESULT WAVEParser_Sample(LPVOID iface, IMediaSample * pSample, DWORD_PTR
if (cbSrcStream == 0)
{
TRACE(".. Why do I need you?\n");
+ IMediaSample_Release(pSample);
return S_OK;
}
@@ -140,6 +155,8 @@ static HRESULT WAVEParser_Sample(LPVOID iface, IMediaSample * pSample, DWORD_PTR
This->Parser.pInputPin->rtCurrent = tStart;
}
+ IMediaSample_Release(pSample);
+
if (tStop >= This->EndOfFile || (bytepos_to_duration(This, tStop) >= This->Parser.mediaSeeking.llStop) || hr == VFW_E_NOT_CONNECTED)
{
unsigned int i;
--
1.6.0.6
--------------000109030701000307080107--
More information about the wine-patches
mailing list