Andrew Eikum : dsound: Request a more exact buffer size from MMDevAPI.

Alexandre Julliard julliard at winehq.org
Thu Oct 13 14:10:08 CDT 2011


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

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Wed Oct 12 15:10:04 2011 -0500

dsound: Request a more exact buffer size from MMDevAPI.

---

 dlls/dsound/primary.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index 7243cc6..9155634 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -84,6 +84,8 @@ static void DSOUND_RecalcPrimary(DirectSoundDevice *device)
 
 HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
 {
+    UINT prebuf_frames;
+    REFERENCE_TIME prebuf_rt;
     HRESULT hres;
 
     TRACE("(%p, %d)\n", device, forcewave);
@@ -112,10 +114,11 @@ HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
         return hres;
     }
 
-    /* buffer size = 200 * 100000 (100 ns) = 2.0 seconds */
+    prebuf_frames = device->prebuf * DSOUND_fraglen(device->pwfx->nSamplesPerSec, device->pwfx->nBlockAlign) / device->pwfx->nBlockAlign;
+    prebuf_rt = (prebuf_frames / (double)device->pwfx->nSamplesPerSec) * 10000000;
     hres = IAudioClient_Initialize(device->client,
             AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_NOPERSIST,
-            200 * 100000, 50000, device->pwfx, NULL);
+            prebuf_rt, 50000, device->pwfx, NULL);
     if(FAILED(hres)){
         IAudioClient_Release(device->client);
         device->client = NULL;




More information about the wine-cvs mailing list