=?UTF-8?Q?J=C3=B6rg=20H=C3=B6hle=20?=: winecoreaudio: Fix AudioRenderClient Get/ReleaseBuffer protocol.

Alexandre Julliard julliard at winehq.org
Wed Sep 7 12:35:30 CDT 2011


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

Author: Jörg Höhle <hoehle at users.sourceforge.net>
Date:   Sun Aug  7 07:06:48 2011 +0200

winecoreaudio: Fix AudioRenderClient Get/ReleaseBuffer protocol.

---

 dlls/winecoreaudio.drv/mmdevdrv.c |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c
index 6fd336f..78daa8c 100644
--- a/dlls/winecoreaudio.drv/mmdevdrv.c
+++ b/dlls/winecoreaudio.drv/mmdevdrv.c
@@ -127,7 +127,7 @@ struct ACImpl {
     UINT32 period_ms, bufsize_frames, inbuf_frames, written_frames;
     UINT64 last_time;
     AudioQueueBufferRef public_buffer;
-    BOOL getbuf_last;
+    UINT32 getbuf_last;
     int playing;
 
     AudioSession *session;
@@ -1602,6 +1602,7 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
 
     if(!data)
         return E_POINTER;
+    *data = NULL;
 
     OSSpinLockLock(&This->lock);
 
@@ -1611,7 +1612,6 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
     }
 
     if(!frames){
-        This->getbuf_last = TRUE;
         OSSpinLockUnlock(&This->lock);
         return S_OK;
     }
@@ -1656,7 +1656,7 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
 
     *data = This->public_buffer->mAudioData;
 
-    This->getbuf_last = TRUE;
+    This->getbuf_last = frames;
 
     OSSpinLockUnlock(&This->lock);
 
@@ -1673,11 +1673,27 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
 
     OSSpinLockLock(&This->lock);
 
+    if(!frames){
+        This->getbuf_last = 0;
+        if(This->public_buffer){
+            AQBuffer *buf = This->public_buffer->mUserData;
+            list_add_tail(&This->avail_buffers, &buf->entry);
+            This->public_buffer = NULL;
+        }
+        OSSpinLockUnlock(&This->lock);
+        return S_OK;
+    }
+
     if(!This->getbuf_last){
         OSSpinLockUnlock(&This->lock);
         return AUDCLNT_E_OUT_OF_ORDER;
     }
 
+    if(frames > This->getbuf_last){
+        OSSpinLockUnlock(&This->lock);
+        return AUDCLNT_E_INVALID_SIZE;
+    }
+
     if(flags & AUDCLNT_BUFFERFLAGS_SILENT){
         WAVEFORMATEXTENSIBLE *fmtex = (WAVEFORMATEXTENSIBLE*)This->fmt;
         if((This->fmt->wFormatTag == WAVE_FORMAT_PCM ||
@@ -1704,7 +1720,7 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
         AudioQueuePrime(This->aqueue, 0, NULL);
 
     This->public_buffer = NULL;
-    This->getbuf_last = FALSE;
+    This->getbuf_last = 0;
     This->written_frames += frames;
     This->inbuf_frames += frames;
 
@@ -1795,7 +1811,7 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
     *flags = 0;
     This->written_frames += *frames;
     This->inbuf_frames -= *frames;
-    This->getbuf_last = TRUE;
+    This->getbuf_last = 1;
 
     if(devpos || qpcpos)
         AudioClock_GetPosition_nolock(This, devpos, qpcpos, FALSE);
@@ -1809,8 +1825,7 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
         IAudioCaptureClient *iface, UINT32 done)
 {
     ACImpl *This = impl_from_IAudioCaptureClient(iface);
-    UINT32 pbuf_frames =
-        This->public_buffer->mAudioDataByteSize / This->fmt->nBlockAlign;
+    UINT32 pbuf_frames;
     OSStatus sc;
 
     TRACE("(%p)->(%u)\n", This, done);
@@ -1822,6 +1837,7 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
         return AUDCLNT_E_OUT_OF_ORDER;
     }
 
+    pbuf_frames = This->public_buffer->mAudioDataByteSize / This->fmt->nBlockAlign;
     if(done != 0 && done != pbuf_frames){
         OSSpinLockUnlock(&This->lock);
         return AUDCLNT_E_INVALID_SIZE;
@@ -1835,7 +1851,7 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
         This->public_buffer = NULL;
     }
 
-    This->getbuf_last = FALSE;
+    This->getbuf_last = 0;
 
     OSSpinLockUnlock(&This->lock);
 




More information about the wine-cvs mailing list