quartz: Set the sample time based on the number of bytes read before sending it downstream.

This commit is contained in:
Chris Robinson 2007-03-31 19:31:27 -07:00 committed by Alexandre Julliard
parent b3c4d6eee6
commit 9d1f49cd9f
2 changed files with 14 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;
}
@ -1225,6 +1227,14 @@ static void CALLBACK PullPin_Thread_Process(ULONG_PTR iface)
if (SUCCEEDED(hr))
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