From 9d1f49cd9f9f0bdf49fb886eb614847e31ffac09 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 31 Mar 2007 19:31:27 -0700 Subject: [PATCH] quartz: Set the sample time based on the number of bytes read before sending it downstream. --- dlls/quartz/filesource.c | 3 ++- dlls/quartz/pin.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 6e5db5efb4d..726776bfbef 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -1045,6 +1045,7 @@ static HRESULT WINAPI FileAsyncReader_Request(IAsyncReader * iface, IMediaSample static HRESULT WINAPI FileAsyncReader_WaitForNext(IAsyncReader * iface, DWORD dwTimeout, IMediaSample ** ppSample, DWORD_PTR * pdwUser) { HRESULT hr = S_OK; + DWORD dwBytes = 0; DATAREQUEST * pDataRq = NULL; FileAsyncReader *This = impl_from_IAsyncReader(iface); @@ -1083,7 +1084,6 @@ static HRESULT WINAPI FileAsyncReader_WaitForNext(IAsyncReader * iface, DWORD dw if (SUCCEEDED(hr)) { - DWORD dwBytes; /* get any errors */ if (!GetOverlappedResult(This->hFile, &pDataRq->ovl, &dwBytes, FALSE)) hr = HRESULT_FROM_WIN32(GetLastError()); @@ -1091,6 +1091,7 @@ static HRESULT WINAPI FileAsyncReader_WaitForNext(IAsyncReader * iface, DWORD dw if (SUCCEEDED(hr)) { + IMediaSample_SetActualDataLength(pDataRq->pSample, dwBytes); *ppSample = pDataRq->pSample; *pdwUser = pDataRq->dwUserData; } diff --git a/dlls/quartz/pin.c b/dlls/quartz/pin.c index 58e5beeec89..84a2c30507e 100644 --- a/dlls/quartz/pin.c +++ b/dlls/quartz/pin.c @@ -1198,6 +1198,7 @@ static void CALLBACK PullPin_Thread_Process(ULONG_PTR iface) * so that one sample is processed while one sample is fetched. However, * it is harder to debug so for the moment it will stay as it is */ IMediaSample * pSample = NULL; + REFERENCE_TIME rtSampleStart; REFERENCE_TIME rtSampleStop; DWORD_PTR dwUser; @@ -1209,10 +1210,11 @@ static void CALLBACK PullPin_Thread_Process(ULONG_PTR iface) if (SUCCEEDED(hr)) { - rtSampleStop = This->rtCurrent + MEDIATIME_FROM_BYTES(IMediaSample_GetSize(pSample)); + rtSampleStart = This->rtCurrent; + rtSampleStop = rtSampleStart + MEDIATIME_FROM_BYTES(IMediaSample_GetSize(pSample)); if (rtSampleStop > This->rtStop) rtSampleStop = MEDIATIME_FROM_BYTES(ALIGNUP(BYTES_FROM_MEDIATIME(This->rtStop), allocProps.cbAlign)); - hr = IMediaSample_SetTime(pSample, &This->rtCurrent, &rtSampleStop); + hr = IMediaSample_SetTime(pSample, &rtSampleStart, &rtSampleStop); This->rtCurrent = rtSampleStop; } @@ -1226,6 +1228,14 @@ static void CALLBACK PullPin_Thread_Process(ULONG_PTR iface) hr = IPin_QueryPinInfo((IPin*)&This->pin, &pinInfo); if (SUCCEEDED(hr)) + { + rtSampleStop = rtSampleStart + MEDIATIME_FROM_BYTES(IMediaSample_GetActualDataLength(pSample)); + if (rtSampleStop > This->rtStop) + rtSampleStop = MEDIATIME_FROM_BYTES(ALIGNUP(BYTES_FROM_MEDIATIME(This->rtStop), allocProps.cbAlign)); + hr = IMediaSample_SetTime(pSample, &rtSampleStart, &rtSampleStop); + } + + if (SUCCEEDED(hr)) hr = This->fnSampleProc(This->pin.pUserData, pSample); else ERR("Processing error: %x\n", hr); -- 2.11.4.GIT