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:
Zebediah Figura 2017-06-19 14:15:32 -05:00 committed by Alexandre Julliard
parent e1d14d2665
commit e994c62e3e
2 changed files with 10 additions and 14 deletions

View File

@ -115,9 +115,9 @@ static REFERENCE_TIME time_from_pos(DSoundRenderImpl *This, DWORD pos) {
static DWORD pos_from_time(DSoundRenderImpl *This, REFERENCE_TIME time) {
WAVEFORMATEX *wfx = (WAVEFORMATEX*)This->renderer.pInputPin->pin.mtCurrent.pbFormat;
REFERENCE_TIME ret = time;
ret *= wfx->nSamplesPerSec;
ret *= wfx->nAvgBytesPerSec;
ret /= 10000000;
ret *= wfx->nBlockAlign;
ret -= ret % wfx->nBlockAlign;
return ret;
}
@ -424,7 +424,7 @@ static HRESULT WINAPI DSoundRender_CheckMediaType(BaseRenderer *iface, const AM_
TRACE("Format = %p\n", format);
TRACE("wFormatTag = %x %x\n", format->wFormatTag, WAVE_FORMAT_PCM);
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("nBlockAlign = %d\n", format->nBlockAlign);
TRACE("wBitsPerSample = %d\n", format->wBitsPerSample);

View File

@ -43,9 +43,8 @@ typedef struct WAVEParserImpl
ParserImpl Parser;
LONGLONG StartOfFile; /* in media time */
LONGLONG EndOfFile;
DWORD dwSampleSize;
DWORD nSamplesPerSec;
DWORD dwLength;
DWORD nAvgBytesPerSec;
DWORD nBlockAlign;
} WAVEParserImpl;
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);
duration *= 10000000;
duration /= (This->dwSampleSize * This->nSamplesPerSec);
duration /= This->nAvgBytesPerSec;
return duration;
}
@ -71,11 +70,11 @@ static LONGLONG duration_to_bytepos(WAVEParserImpl *This, LONGLONG duration)
{
LONGLONG bytepos;
bytepos = (This->dwSampleSize * This->nSamplesPerSec);
bytepos = This->nAvgBytesPerSec;
bytepos *= duration;
bytepos /= 10000000;
bytepos -= bytepos % This->nBlockAlign;
bytepos += BYTES_FROM_MEDIATIME(This->StartOfFile);
bytepos -= bytepos % This->dwSampleSize;
return MEDIATIME_FROM_BYTES(bytepos);
}
@ -252,7 +251,6 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin,
PIN_INFO piOutput;
AM_MEDIA_TYPE amt;
WAVEParserImpl * pWAVEParser = impl_from_IBaseFilter(This->pin.pinInfo.pFilter);
LONGLONG length, avail;
piOutput.dir = PINDIR_OUTPUT;
piOutput.pFilter = &pWAVEParser->Parser.filter.IBaseFilter_iface;
@ -321,10 +319,8 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin,
props->cbPrefix = 0;
props->cbBuffer = 4096;
props->cBuffers = 3;
pWAVEParser->dwSampleSize = ((WAVEFORMATEX*)amt.pbFormat)->nBlockAlign;
IAsyncReader_Length(This->pReader, &length, &avail);
pWAVEParser->dwLength = length / (ULONGLONG)pWAVEParser->dwSampleSize;
pWAVEParser->nSamplesPerSec = ((WAVEFORMATEX*)amt.pbFormat)->nSamplesPerSec;
pWAVEParser->nBlockAlign = ((WAVEFORMATEX*)amt.pbFormat)->nBlockAlign;
pWAVEParser->nAvgBytesPerSec = ((WAVEFORMATEX*)amt.pbFormat)->nAvgBytesPerSec;
hr = Parser_AddPin(&(pWAVEParser->Parser), &piOutput, props, &amt);
CoTaskMemFree(amt.pbFormat);