quartz: Use nAvgBytesPerSec to calculate length.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e1d14d2665
commit
e994c62e3e
|
@ -115,9 +115,9 @@ static REFERENCE_TIME time_from_pos(DSoundRenderImpl *This, DWORD pos) {
|
||||||
static DWORD pos_from_time(DSoundRenderImpl *This, REFERENCE_TIME time) {
|
static DWORD pos_from_time(DSoundRenderImpl *This, REFERENCE_TIME time) {
|
||||||
WAVEFORMATEX *wfx = (WAVEFORMATEX*)This->renderer.pInputPin->pin.mtCurrent.pbFormat;
|
WAVEFORMATEX *wfx = (WAVEFORMATEX*)This->renderer.pInputPin->pin.mtCurrent.pbFormat;
|
||||||
REFERENCE_TIME ret = time;
|
REFERENCE_TIME ret = time;
|
||||||
ret *= wfx->nSamplesPerSec;
|
ret *= wfx->nAvgBytesPerSec;
|
||||||
ret /= 10000000;
|
ret /= 10000000;
|
||||||
ret *= wfx->nBlockAlign;
|
ret -= ret % wfx->nBlockAlign;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ static HRESULT WINAPI DSoundRender_CheckMediaType(BaseRenderer *iface, const AM_
|
||||||
TRACE("Format = %p\n", format);
|
TRACE("Format = %p\n", format);
|
||||||
TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
|
TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
|
||||||
TRACE("nChannels = %d\n", format->nChannels);
|
TRACE("nChannels = %d\n", format->nChannels);
|
||||||
TRACE("nSamplesPerSec = %d\n", format->nAvgBytesPerSec);
|
TRACE("nSamplesPerSec = %d\n", format->nSamplesPerSec);
|
||||||
TRACE("nAvgBytesPerSec = %d\n", format->nAvgBytesPerSec);
|
TRACE("nAvgBytesPerSec = %d\n", format->nAvgBytesPerSec);
|
||||||
TRACE("nBlockAlign = %d\n", format->nBlockAlign);
|
TRACE("nBlockAlign = %d\n", format->nBlockAlign);
|
||||||
TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
|
TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);
|
||||||
|
|
|
@ -43,9 +43,8 @@ typedef struct WAVEParserImpl
|
||||||
ParserImpl Parser;
|
ParserImpl Parser;
|
||||||
LONGLONG StartOfFile; /* in media time */
|
LONGLONG StartOfFile; /* in media time */
|
||||||
LONGLONG EndOfFile;
|
LONGLONG EndOfFile;
|
||||||
DWORD dwSampleSize;
|
DWORD nAvgBytesPerSec;
|
||||||
DWORD nSamplesPerSec;
|
DWORD nBlockAlign;
|
||||||
DWORD dwLength;
|
|
||||||
} WAVEParserImpl;
|
} WAVEParserImpl;
|
||||||
|
|
||||||
static inline WAVEParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
|
static inline WAVEParserImpl *impl_from_IMediaSeeking( IMediaSeeking *iface )
|
||||||
|
@ -62,7 +61,7 @@ static LONGLONG bytepos_to_duration(WAVEParserImpl *This, LONGLONG bytepos)
|
||||||
{
|
{
|
||||||
LONGLONG duration = BYTES_FROM_MEDIATIME(bytepos - This->StartOfFile);
|
LONGLONG duration = BYTES_FROM_MEDIATIME(bytepos - This->StartOfFile);
|
||||||
duration *= 10000000;
|
duration *= 10000000;
|
||||||
duration /= (This->dwSampleSize * This->nSamplesPerSec);
|
duration /= This->nAvgBytesPerSec;
|
||||||
|
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
@ -71,11 +70,11 @@ static LONGLONG duration_to_bytepos(WAVEParserImpl *This, LONGLONG duration)
|
||||||
{
|
{
|
||||||
LONGLONG bytepos;
|
LONGLONG bytepos;
|
||||||
|
|
||||||
bytepos = (This->dwSampleSize * This->nSamplesPerSec);
|
bytepos = This->nAvgBytesPerSec;
|
||||||
bytepos *= duration;
|
bytepos *= duration;
|
||||||
bytepos /= 10000000;
|
bytepos /= 10000000;
|
||||||
|
bytepos -= bytepos % This->nBlockAlign;
|
||||||
bytepos += BYTES_FROM_MEDIATIME(This->StartOfFile);
|
bytepos += BYTES_FROM_MEDIATIME(This->StartOfFile);
|
||||||
bytepos -= bytepos % This->dwSampleSize;
|
|
||||||
|
|
||||||
return MEDIATIME_FROM_BYTES(bytepos);
|
return MEDIATIME_FROM_BYTES(bytepos);
|
||||||
}
|
}
|
||||||
|
@ -252,7 +251,6 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin,
|
||||||
PIN_INFO piOutput;
|
PIN_INFO piOutput;
|
||||||
AM_MEDIA_TYPE amt;
|
AM_MEDIA_TYPE amt;
|
||||||
WAVEParserImpl * pWAVEParser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
|
WAVEParserImpl * pWAVEParser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
|
||||||
LONGLONG length, avail;
|
|
||||||
|
|
||||||
piOutput.dir = PINDIR_OUTPUT;
|
piOutput.dir = PINDIR_OUTPUT;
|
||||||
piOutput.pFilter = &pWAVEParser->Parser.filter.IBaseFilter_iface;
|
piOutput.pFilter = &pWAVEParser->Parser.filter.IBaseFilter_iface;
|
||||||
|
@ -321,10 +319,8 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin,
|
||||||
props->cbPrefix = 0;
|
props->cbPrefix = 0;
|
||||||
props->cbBuffer = 4096;
|
props->cbBuffer = 4096;
|
||||||
props->cBuffers = 3;
|
props->cBuffers = 3;
|
||||||
pWAVEParser->dwSampleSize = ((WAVEFORMATEX*)amt.pbFormat)->nBlockAlign;
|
pWAVEParser->nBlockAlign = ((WAVEFORMATEX*)amt.pbFormat)->nBlockAlign;
|
||||||
IAsyncReader_Length(This->pReader, &length, &avail);
|
pWAVEParser->nAvgBytesPerSec = ((WAVEFORMATEX*)amt.pbFormat)->nAvgBytesPerSec;
|
||||||
pWAVEParser->dwLength = length / (ULONGLONG)pWAVEParser->dwSampleSize;
|
|
||||||
pWAVEParser->nSamplesPerSec = ((WAVEFORMATEX*)amt.pbFormat)->nSamplesPerSec;
|
|
||||||
hr = Parser_AddPin(&(pWAVEParser->Parser), &piOutput, props, &amt);
|
hr = Parser_AddPin(&(pWAVEParser->Parser), &piOutput, props, &amt);
|
||||||
CoTaskMemFree(amt.pbFormat);
|
CoTaskMemFree(amt.pbFormat);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue