Zebediah Figura : quartz: Use nAvgBytesPerSec to calculate length.

Alexandre Julliard julliard at winehq.org
Wed Jun 21 16:43:44 CDT 2017


Module: wine
Branch: master
Commit: e994c62e3e66aebe137a3f2b15bdf3246fdaa08a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e994c62e3e66aebe137a3f2b15bdf3246fdaa08a

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon Jun 19 14:15:32 2017 -0500

quartz: Use nAvgBytesPerSec to calculate length.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/quartz/dsoundrender.c |  6 +++---
 dlls/quartz/waveparser.c   | 18 +++++++-----------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/dlls/quartz/dsoundrender.c b/dlls/quartz/dsoundrender.c
index 9e8f69c..7902955 100644
--- a/dlls/quartz/dsoundrender.c
+++ b/dlls/quartz/dsoundrender.c
@@ -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);
diff --git a/dlls/quartz/waveparser.c b/dlls/quartz/waveparser.c
index 6e8c664..f6bea2c 100644
--- a/dlls/quartz/waveparser.c
+++ b/dlls/quartz/waveparser.c
@@ -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);
 




More information about the wine-cvs mailing list