2005-02-10 18:13:18 +01:00
|
|
|
/*
|
|
|
|
* WAVE Parser Filter
|
|
|
|
*
|
|
|
|
* Copyright 2005 Christian Costa
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-02-10 18:13:18 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "quartz_private.h"
|
|
|
|
#include "control_private.h"
|
|
|
|
#include "pin.h"
|
|
|
|
|
|
|
|
#include "uuids.h"
|
|
|
|
#include "aviriff.h"
|
|
|
|
#include "vfwmsgs.h"
|
|
|
|
#include "mmsystem.h"
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "parser.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
|
|
|
|
|
|
|
|
static const WCHAR wcsOutputPinName[] = {'o','u','t','p','u','t',' ','p','i','n',0};
|
|
|
|
|
|
|
|
typedef struct WAVEParserImpl
|
|
|
|
{
|
|
|
|
ParserImpl Parser;
|
|
|
|
LONGLONG StartOfFile; /* in media time */
|
|
|
|
LONGLONG EndOfFile;
|
2008-03-19 00:05:00 +01:00
|
|
|
DWORD dwSampleSize;
|
2008-04-13 01:52:26 +02:00
|
|
|
DWORD nSamplesPerSec;
|
2008-03-19 00:05:00 +01:00
|
|
|
DWORD dwLength;
|
2005-02-10 18:13:18 +01:00
|
|
|
} WAVEParserImpl;
|
|
|
|
|
2008-04-13 01:52:26 +02:00
|
|
|
static LONGLONG bytepos_to_duration(WAVEParserImpl *This, LONGLONG bytepos)
|
|
|
|
{
|
|
|
|
LONGLONG duration = BYTES_FROM_MEDIATIME(bytepos - This->StartOfFile);
|
|
|
|
duration *= 10000000;
|
|
|
|
duration /= (This->dwSampleSize * This->nSamplesPerSec);
|
|
|
|
|
|
|
|
return duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONGLONG duration_to_bytepos(WAVEParserImpl *This, LONGLONG duration)
|
|
|
|
{
|
|
|
|
LONGLONG bytepos;
|
|
|
|
|
|
|
|
bytepos = (This->dwSampleSize * This->nSamplesPerSec);
|
|
|
|
bytepos *= duration;
|
|
|
|
bytepos /= 10000000;
|
|
|
|
bytepos += BYTES_FROM_MEDIATIME(This->StartOfFile);
|
|
|
|
bytepos -= bytepos % This->dwSampleSize;
|
|
|
|
|
|
|
|
return MEDIATIME_FROM_BYTES(bytepos);
|
|
|
|
}
|
|
|
|
|
2008-04-19 04:30:25 +02:00
|
|
|
static HRESULT WAVEParser_Sample(LPVOID iface, IMediaSample * pSample, DWORD_PTR cookie)
|
2005-02-10 18:13:18 +01:00
|
|
|
{
|
|
|
|
WAVEParserImpl *This = (WAVEParserImpl *)iface;
|
|
|
|
LPBYTE pbSrcStream = NULL;
|
2008-04-22 22:57:11 +02:00
|
|
|
ULONG cbSrcStream = 0;
|
2005-02-10 18:13:18 +01:00
|
|
|
REFERENCE_TIME tStart, tStop;
|
|
|
|
HRESULT hr;
|
2008-04-22 22:57:11 +02:00
|
|
|
IMediaSample *newsample = NULL;
|
|
|
|
Parser_OutputPin *pOutputPin;
|
|
|
|
PullPin *pin = This->Parser.pInputPin;
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
IMediaSample_GetPointer(pSample, &pbSrcStream);
|
2005-02-10 18:13:18 +01:00
|
|
|
hr = IMediaSample_GetTime(pSample, &tStart, &tStop);
|
|
|
|
|
|
|
|
cbSrcStream = IMediaSample_GetActualDataLength(pSample);
|
|
|
|
|
2008-05-06 20:01:59 +02:00
|
|
|
/* Flush occurring */
|
2008-04-22 22:57:11 +02:00
|
|
|
if (cbSrcStream == 0)
|
|
|
|
{
|
|
|
|
TRACE(".. Why do I need you?\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
2005-02-10 18:13:18 +01:00
|
|
|
|
|
|
|
pOutputPin = (Parser_OutputPin *)This->Parser.ppPins[1];
|
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
hr = IMemAllocator_GetBuffer(pin->pAlloc, &newsample, NULL, NULL, 0);
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2005-02-10 18:13:18 +01:00
|
|
|
{
|
2008-04-22 22:57:11 +02:00
|
|
|
LONGLONG rtSampleStart = pin->rtNext;
|
|
|
|
/* Add 4 for the next header, which should hopefully work */
|
|
|
|
LONGLONG rtSampleStop = rtSampleStart + MEDIATIME_FROM_BYTES(IMediaSample_GetSize(newsample));
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
if (rtSampleStop > pin->rtStop)
|
|
|
|
rtSampleStop = MEDIATIME_FROM_BYTES(ALIGNUP(BYTES_FROM_MEDIATIME(pin->rtStop), pin->cbAlign));
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
hr = IMediaSample_SetTime(newsample, &rtSampleStart, &rtSampleStop);
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
pin->rtCurrent = pin->rtNext;
|
|
|
|
pin->rtNext = rtSampleStop;
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
IMediaSample_SetPreroll(newsample, 0);
|
|
|
|
IMediaSample_SetDiscontinuity(newsample, 0);
|
|
|
|
IMediaSample_SetSyncPoint(newsample, 1);
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
hr = IAsyncReader_Request(pin->pReader, newsample, 0);
|
|
|
|
}
|
2008-04-16 22:39:10 +02:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
REFERENCE_TIME tAviStart, tAviStop;
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
IMediaSample_SetSyncPoint(pSample, TRUE);
|
|
|
|
pOutputPin->dwSamplesProcessed++;
|
2008-04-13 01:52:26 +02:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
tAviStart = bytepos_to_duration(This, tStart);
|
|
|
|
tAviStop = bytepos_to_duration(This, tStart + MEDIATIME_FROM_BYTES(IMediaSample_GetActualDataLength(pSample)));
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
IMediaSample_SetTime(pSample, &tAviStart, &tAviStop);
|
2005-02-10 18:13:18 +01:00
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
hr = OutputPin_SendSample(&pOutputPin->pin, pSample);
|
2008-04-30 23:34:19 +02:00
|
|
|
if (hr != S_OK && hr != S_FALSE && hr != VFW_E_WRONG_STATE)
|
2008-04-22 22:57:11 +02:00
|
|
|
ERR("Error sending sample (%x)\n", hr);
|
2008-04-30 23:34:19 +02:00
|
|
|
else if (hr != S_OK)
|
|
|
|
/* Unset progression if denied! */
|
|
|
|
This->Parser.pInputPin->rtCurrent = tStart;
|
2005-02-10 18:13:18 +01:00
|
|
|
}
|
|
|
|
|
2008-04-30 23:34:19 +02:00
|
|
|
if (tStop >= This->EndOfFile || (bytepos_to_duration(This, tStop) >= This->Parser.mediaSeeking.llStop) || hr == VFW_E_NOT_CONNECTED)
|
2005-03-02 11:12:12 +01:00
|
|
|
{
|
2008-11-04 23:22:53 +01:00
|
|
|
unsigned int i;
|
2005-03-02 11:12:12 +01:00
|
|
|
|
|
|
|
TRACE("End of file reached\n");
|
|
|
|
|
|
|
|
for (i = 0; i < This->Parser.cStreams; i++)
|
|
|
|
{
|
|
|
|
IPin* ppin;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2008-11-04 23:22:53 +01:00
|
|
|
TRACE("Send End Of Stream to output pin %u\n", i);
|
2005-03-02 11:12:12 +01:00
|
|
|
|
|
|
|
hr = IPin_ConnectedTo(This->Parser.ppPins[i+1], &ppin);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IPin_EndOfStream(ppin);
|
|
|
|
IPin_Release(ppin);
|
|
|
|
}
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2006-10-12 20:57:23 +02:00
|
|
|
ERR("%x\n", hr);
|
2005-03-02 11:12:12 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Force the pullpin thread to stop */
|
|
|
|
hr = S_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-02-10 18:13:18 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WAVEParser_QueryAccept(LPVOID iface, const AM_MEDIA_TYPE * pmt)
|
|
|
|
{
|
|
|
|
if (!IsEqualIID(&pmt->majortype, &MEDIATYPE_Stream))
|
|
|
|
return S_FALSE;
|
|
|
|
if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_WAVE))
|
|
|
|
return S_OK;
|
|
|
|
if (IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_AU) || IsEqualIID(&pmt->subtype, &MEDIASUBTYPE_AIFF))
|
|
|
|
FIXME("AU and AIFF files not supported yet!\n");
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2008-04-13 01:52:26 +02:00
|
|
|
static HRESULT WAVEParserImpl_seek(IBaseFilter *iface)
|
|
|
|
{
|
|
|
|
WAVEParserImpl *This = (WAVEParserImpl *)iface;
|
|
|
|
PullPin *pPin = This->Parser.pInputPin;
|
|
|
|
IPin *victim = NULL;
|
|
|
|
LONGLONG newpos, curpos, endpos, bytepos;
|
|
|
|
|
|
|
|
newpos = This->Parser.mediaSeeking.llCurrent;
|
|
|
|
curpos = bytepos_to_duration(This, pPin->rtCurrent);
|
|
|
|
endpos = bytepos_to_duration(This, This->EndOfFile);
|
|
|
|
bytepos = duration_to_bytepos(This, newpos);
|
|
|
|
|
|
|
|
if (newpos > endpos)
|
|
|
|
{
|
|
|
|
WARN("Requesting position %x%08x beyond end of stream %x%08x\n", (DWORD)(newpos>>32), (DWORD)newpos, (DWORD)(endpos>>32), (DWORD)endpos);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curpos/1000000 == newpos/1000000)
|
|
|
|
{
|
|
|
|
TRACE("Requesting position %x%08x same as current position %x%08x\n", (DWORD)(newpos>>32), (DWORD)newpos, (DWORD)(curpos>>32), (DWORD)curpos);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Moving sound to %08u bytes!\n", (DWORD)BYTES_FROM_MEDIATIME(bytepos));
|
|
|
|
|
|
|
|
EnterCriticalSection(&pPin->thread_lock);
|
|
|
|
IPin_BeginFlush((IPin *)pPin);
|
|
|
|
|
|
|
|
/* Make sure this is done while stopped, BeginFlush takes care of this */
|
|
|
|
EnterCriticalSection(&This->Parser.csFilter);
|
|
|
|
IPin_ConnectedTo(This->Parser.ppPins[1], &victim);
|
|
|
|
if (victim)
|
|
|
|
{
|
|
|
|
IPin_NewSegment(victim, newpos, endpos, pPin->dRate);
|
|
|
|
IPin_Release(victim);
|
|
|
|
}
|
|
|
|
|
|
|
|
pPin->rtStart = pPin->rtCurrent = bytepos;
|
2008-04-16 22:39:10 +02:00
|
|
|
((Parser_OutputPin *)This->Parser.ppPins[1])->dwSamplesProcessed = 0;
|
2008-04-13 01:52:26 +02:00
|
|
|
LeaveCriticalSection(&This->Parser.csFilter);
|
|
|
|
|
|
|
|
TRACE("Done flushing\n");
|
|
|
|
IPin_EndFlush((IPin *)pPin);
|
|
|
|
LeaveCriticalSection(&pPin->thread_lock);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props)
|
2005-02-10 18:13:18 +01:00
|
|
|
{
|
|
|
|
PullPin *This = (PullPin *)iface;
|
|
|
|
HRESULT hr;
|
|
|
|
RIFFLIST list;
|
|
|
|
RIFFCHUNK chunk;
|
|
|
|
LONGLONG pos = 0; /* in bytes */
|
|
|
|
PIN_INFO piOutput;
|
|
|
|
AM_MEDIA_TYPE amt;
|
|
|
|
WAVEParserImpl * pWAVEParser = (WAVEParserImpl *)This->pin.pinInfo.pFilter;
|
2008-03-19 00:05:00 +01:00
|
|
|
LONGLONG length, avail;
|
2005-02-10 18:13:18 +01:00
|
|
|
|
|
|
|
piOutput.dir = PINDIR_OUTPUT;
|
|
|
|
piOutput.pFilter = (IBaseFilter *)This;
|
2005-03-28 16:17:51 +02:00
|
|
|
lstrcpynW(piOutput.achName, wcsOutputPinName, sizeof(piOutput.achName) / sizeof(piOutput.achName[0]));
|
2005-02-10 18:13:18 +01:00
|
|
|
|
|
|
|
hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(list), (BYTE *)&list);
|
|
|
|
pos += sizeof(list);
|
|
|
|
|
2008-04-11 00:45:32 +02:00
|
|
|
if (list.fcc != FOURCC_RIFF)
|
2005-02-10 18:13:18 +01:00
|
|
|
{
|
|
|
|
ERR("Input stream not a RIFF file\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
if (list.cb > 1 * 1024 * 1024 * 1024) /* cannot be more than 1Gb in size */
|
|
|
|
{
|
|
|
|
ERR("Input stream violates RIFF spec\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
if (list.fccListType != mmioFOURCC('W','A','V','E'))
|
|
|
|
{
|
|
|
|
ERR("Input stream not an WAVE RIFF file\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(chunk), (BYTE *)&chunk);
|
|
|
|
pos += sizeof(chunk);
|
|
|
|
if (chunk.fcc != mmioFOURCC('f','m','t',' '))
|
|
|
|
{
|
|
|
|
ERR("Expected 'fmt ' chunk, but got %.04s\n", (LPSTR)&chunk.fcc);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2008-03-12 21:32:07 +01:00
|
|
|
amt.majortype = MEDIATYPE_Audio;
|
|
|
|
amt.formattype = FORMAT_WaveFormatEx;
|
2005-02-10 18:13:18 +01:00
|
|
|
amt.cbFormat = chunk.cb;
|
|
|
|
amt.pbFormat = CoTaskMemAlloc(amt.cbFormat);
|
|
|
|
amt.pUnk = NULL;
|
|
|
|
hr = IAsyncReader_SyncRead(This->pReader, pos, amt.cbFormat, amt.pbFormat);
|
2008-03-12 21:32:07 +01:00
|
|
|
amt.subtype = MEDIATYPE_Audio;
|
2005-02-10 18:13:18 +01:00
|
|
|
amt.subtype.Data1 = ((WAVEFORMATEX*)amt.pbFormat)->wFormatTag;
|
|
|
|
|
|
|
|
pos += chunk.cb;
|
|
|
|
hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(chunk), (BYTE *)&chunk);
|
|
|
|
if (chunk.fcc == mmioFOURCC('f','a','c','t'))
|
|
|
|
{
|
|
|
|
FIXME("'fact' chunk not supported yet\n");
|
|
|
|
pos += sizeof(chunk) + chunk.cb;
|
|
|
|
hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(chunk), (BYTE *)&chunk);
|
|
|
|
}
|
|
|
|
if (chunk.fcc != mmioFOURCC('d','a','t','a'))
|
|
|
|
{
|
|
|
|
ERR("Expected 'data' chunk, but got %.04s\n", (LPSTR)&chunk.fcc);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
pWAVEParser->StartOfFile = MEDIATIME_FROM_BYTES(pos + sizeof(RIFFCHUNK));
|
|
|
|
pWAVEParser->EndOfFile = MEDIATIME_FROM_BYTES(pos + chunk.cb + sizeof(RIFFCHUNK));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hr != S_OK)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
props->cbAlign = ((WAVEFORMATEX*)amt.pbFormat)->nBlockAlign;
|
|
|
|
props->cbPrefix = 0;
|
|
|
|
props->cbBuffer = 4096;
|
2008-04-30 23:34:19 +02:00
|
|
|
props->cBuffers = 3;
|
2008-03-19 00:05:00 +01:00
|
|
|
pWAVEParser->dwSampleSize = ((WAVEFORMATEX*)amt.pbFormat)->nBlockAlign;
|
|
|
|
IAsyncReader_Length(This->pReader, &length, &avail);
|
|
|
|
pWAVEParser->dwLength = length / (ULONGLONG)pWAVEParser->dwSampleSize;
|
2008-04-13 01:52:26 +02:00
|
|
|
pWAVEParser->nSamplesPerSec = ((WAVEFORMATEX*)amt.pbFormat)->nSamplesPerSec;
|
2008-04-22 22:57:11 +02:00
|
|
|
hr = Parser_AddPin(&(pWAVEParser->Parser), &piOutput, props, &amt);
|
2008-04-13 01:52:26 +02:00
|
|
|
CoTaskMemFree(amt.pbFormat);
|
|
|
|
|
|
|
|
pWAVEParser->Parser.mediaSeeking.llCurrent = 0;
|
|
|
|
pWAVEParser->Parser.mediaSeeking.llStop = pWAVEParser->Parser.mediaSeeking.llDuration = bytepos_to_duration(pWAVEParser, pWAVEParser->EndOfFile);
|
2008-04-19 07:23:19 +02:00
|
|
|
TRACE("Duration: %u seconds\n", (DWORD)(pWAVEParser->Parser.mediaSeeking.llDuration / (LONGLONG)10000000));
|
2008-04-13 01:52:26 +02:00
|
|
|
|
|
|
|
This->rtStop = pWAVEParser->EndOfFile;
|
|
|
|
This->rtStart = pWAVEParser->StartOfFile;
|
|
|
|
|
2005-02-10 18:13:18 +01:00
|
|
|
TRACE("WAVE File ok\n");
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2007-04-07 06:24:59 +02:00
|
|
|
static HRESULT WAVEParser_Cleanup(LPVOID iface)
|
|
|
|
{
|
|
|
|
WAVEParserImpl *This = (WAVEParserImpl*)iface;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-22 22:57:11 +02:00
|
|
|
static HRESULT WAVEParser_first_request(LPVOID iface)
|
|
|
|
{
|
|
|
|
WAVEParserImpl *This = (WAVEParserImpl *)iface;
|
|
|
|
PullPin *pin = This->Parser.pInputPin;
|
|
|
|
HRESULT hr;
|
|
|
|
IMediaSample *sample;
|
|
|
|
|
|
|
|
if (pin->rtCurrent >= pin->rtStop)
|
|
|
|
{
|
|
|
|
/* Last sample has already been queued, request nothing more */
|
|
|
|
TRACE("Done!\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IMemAllocator_GetBuffer(pin->pAlloc, &sample, NULL, NULL, 0);
|
|
|
|
|
|
|
|
pin->rtNext = pin->rtCurrent;
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
LONGLONG rtSampleStart = pin->rtNext;
|
|
|
|
/* Add 4 for the next header, which should hopefully work */
|
|
|
|
LONGLONG rtSampleStop = rtSampleStart + MEDIATIME_FROM_BYTES(IMediaSample_GetSize(sample));
|
|
|
|
Parser_OutputPin *outpin = (Parser_OutputPin *)This->Parser.ppPins[1];
|
|
|
|
|
|
|
|
if (rtSampleStop > pin->rtStop)
|
|
|
|
rtSampleStop = MEDIATIME_FROM_BYTES(ALIGNUP(BYTES_FROM_MEDIATIME(pin->rtStop), pin->cbAlign));
|
|
|
|
|
|
|
|
hr = IMediaSample_SetTime(sample, &rtSampleStart, &rtSampleStop);
|
|
|
|
|
|
|
|
pin->rtCurrent = pin->rtNext;
|
|
|
|
pin->rtNext = rtSampleStop;
|
|
|
|
|
|
|
|
IMediaSample_SetPreroll(sample, FALSE);
|
|
|
|
if (!outpin->dwSamplesProcessed++)
|
|
|
|
IMediaSample_SetDiscontinuity(sample, TRUE);
|
|
|
|
else
|
|
|
|
IMediaSample_SetDiscontinuity(sample, FALSE);
|
|
|
|
|
|
|
|
hr = IAsyncReader_Request(pin->pReader, sample, 0);
|
|
|
|
}
|
|
|
|
if (FAILED(hr))
|
2008-06-24 17:52:52 +02:00
|
|
|
ERR("Horsemen of the apocalypse came to bring error 0x%08x %p\n", hr, sample);
|
2008-04-22 22:57:11 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-04-16 05:39:36 +02:00
|
|
|
static HRESULT WAVEParser_disconnect(LPVOID iface)
|
|
|
|
{
|
|
|
|
/* TODO: Find and plug memory leaks */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-23 20:23:43 +02:00
|
|
|
static const IBaseFilterVtbl WAVEParser_Vtbl =
|
|
|
|
{
|
|
|
|
Parser_QueryInterface,
|
|
|
|
Parser_AddRef,
|
|
|
|
Parser_Release,
|
|
|
|
Parser_GetClassID,
|
|
|
|
Parser_Stop,
|
|
|
|
Parser_Pause,
|
|
|
|
Parser_Run,
|
|
|
|
Parser_GetState,
|
|
|
|
Parser_SetSyncSource,
|
|
|
|
Parser_GetSyncSource,
|
|
|
|
Parser_EnumPins,
|
|
|
|
Parser_FindPin,
|
|
|
|
Parser_QueryFilterInfo,
|
|
|
|
Parser_JoinFilterGraph,
|
|
|
|
Parser_QueryVendorInfo
|
|
|
|
};
|
|
|
|
|
2005-02-10 18:13:18 +01:00
|
|
|
HRESULT WAVEParser_create(IUnknown * pUnkOuter, LPVOID * ppv)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WAVEParserImpl * This;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", pUnkOuter, ppv);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (pUnkOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
/* Note: This memory is managed by the transform filter once created */
|
|
|
|
This = CoTaskMemAlloc(sizeof(WAVEParserImpl));
|
|
|
|
|
2008-04-25 23:59:05 +02:00
|
|
|
hr = Parser_Create(&(This->Parser), &WAVEParser_Vtbl, &CLSID_WAVEParser, WAVEParser_Sample, WAVEParser_QueryAccept, WAVEParser_InputPin_PreConnect, WAVEParser_Cleanup, WAVEParser_disconnect, WAVEParser_first_request, NULL, NULL, WAVEParserImpl_seek, NULL);
|
2005-02-10 18:13:18 +01:00
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
*ppv = (LPVOID)This;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|