dsound: Block align SetCurrentPosition and add test for it

Maarten Lankhorst m.b.lankhorst at gmail.com
Thu May 24 13:58:58 CDT 2007


This test passes in windows and (now also) in linux
-------------- next part --------------
>From 7095041644d1390be11e9ff91eef46c238610671 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date: Thu, 24 May 2007 20:42:14 +0200
Subject: [PATCH] dsound: Add block align test

---
 dlls/dsound/buffer.c       |    1 +
 dlls/dsound/tests/dsound.c |   16 +++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index 252fbc8..b1cecd7 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -687,6 +687,7 @@ static HRESULT WINAPI IDirectSoundBufferImpl_SetCurrentPosition(
 	EnterCriticalSection(&(This->lock));
 
 	newpos %= This->buflen;
+	newpos -= newpos%This->pwfx->nBlockAlign;
 	This->buf_mixpos = newpos;
 	if (This->hwbuf) {
 		hres = IDsDriverBuffer_SetPosition(This->hwbuf, This->buf_mixpos);
diff --git a/dlls/dsound/tests/dsound.c b/dlls/dsound/tests/dsound.c
index 6f95264..cbb6829 100644
--- a/dlls/dsound/tests/dsound.c
+++ b/dlls/dsound/tests/dsound.c
@@ -9,6 +9,7 @@
  * So this is only done if the test is being run in interactive mode.
  *
  * Copyright (c) 2002-2004 Francois Gouget
+ * Copyright (c) 2007 Maarten Lankhorst
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -764,6 +765,7 @@ static HRESULT test_block_align(LPGUID lpGuid)
     DSBUFFERDESC bufdesc;
     DSBCAPS dsbcaps;
     WAVEFORMATEX wfx;
+    DWORD pos, pos2;
     int ref;
 
     /* Create the DirectSound object */
@@ -790,11 +792,23 @@ static HRESULT test_block_align(LPGUID lpGuid)
         rc=IDirectSoundBuffer_GetCaps(secondary,&dsbcaps);
         ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() should have returned DS_OK, "
            "returned: %s\n", DXGetErrorString8(rc));
-        if (rc==DS_OK)
+        if (rc==DS_OK && wfx.nBlockAlign > 1)
+        {
             ok(dsbcaps.dwBufferBytes==(wfx.nAvgBytesPerSec + wfx.nBlockAlign),
                "Buffer size not a multiple of nBlockAlign: requested %d, "
                "got %d, should be %d\n", bufdesc.dwBufferBytes,
                dsbcaps.dwBufferBytes, wfx.nAvgBytesPerSec + wfx.nBlockAlign);
+
+            rc = IDirectSoundBuffer_SetCurrentPosition(secondary, 0);
+            ok(rc == DS_OK, "Could not set position to 0: %s\n", DXGetErrorString8(rc));
+            rc = IDirectSoundBuffer_GetCurrentPosition(secondary, &pos, NULL);
+            ok(rc == DS_OK, "Could not get position: %s\n", DXGetErrorString8(rc));
+            rc = IDirectSoundBuffer_SetCurrentPosition(secondary, 1);
+            ok(rc == DS_OK, "Could not set position to 1: %s\n", DXGetErrorString8(rc));
+            rc = IDirectSoundBuffer_GetCurrentPosition(secondary, &pos2, NULL);
+            ok(rc == DS_OK, "Could not get new position: %s\n", DXGetErrorString8(rc));
+            ok(pos == pos2, "Positions not the same! Old position: %d, new position: %d\n", pos, pos2);
+        }
         ref=IDirectSoundBuffer_Release(secondary);
         ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d references, "
            "should have 0\n",ref);
-- 
1.4.4.2



More information about the wine-patches mailing list