quartz: Set the sample time based on the number of bytes read before sending it downstream.
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c
index 6e5db5e..726776b 100644
--- a/dlls/quartz/filesource.c
+++ b/dlls/quartz/filesource.c
@@ -1045,6 +1045,7 @@
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 @@
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 @@
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 58e5bee..84a2c30 100644
--- a/dlls/quartz/pin.c
+++ b/dlls/quartz/pin.c
@@ -1198,6 +1198,7 @@
* 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 @@
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 @@
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);