Michael Stefaniuc : dsound: Don' t bother shrinking the secondary buffer list.

Alexandre Julliard julliard at winehq.org
Wed Sep 26 14:06:49 CDT 2012


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

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Tue Sep 25 23:23:31 2012 +0200

dsound: Don't bother shrinking the secondary buffer list.

---

 dlls/dsound/dsound.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c
index a7a6f13..666f29f 100644
--- a/dlls/dsound/dsound.c
+++ b/dlls/dsound/dsound.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include <assert.h>
 #include <stdarg.h>
 #include <stdio.h>
 
@@ -1090,22 +1091,21 @@ HRESULT DirectSoundDevice_RemoveBuffer(
 
     RtlAcquireResourceExclusive(&(device->buffer_list_lock), TRUE);
 
-    for (i = 0; i < device->nrofbuffers; i++)
-        if (device->buffers[i] == pDSB)
-            break;
-
-    if (i < device->nrofbuffers) {
-        /* Put the last buffer of the list in the (now empty) position */
-        device->buffers[i] = device->buffers[device->nrofbuffers - 1];
-        device->nrofbuffers--;
-        device->buffers = HeapReAlloc(GetProcessHeap(),0,device->buffers,sizeof(LPDIRECTSOUNDBUFFER8)*device->nrofbuffers);
-        TRACE("buffer count is now %d\n", device->nrofbuffers);
-    }
-
-    if (device->nrofbuffers == 0) {
-        HeapFree(GetProcessHeap(),0,device->buffers);
+    if (device->nrofbuffers == 1) {
+        assert(device->buffers[0] == pDSB);
+        HeapFree(GetProcessHeap(), 0, device->buffers);
         device->buffers = NULL;
+    } else {
+        for (i = 0; i < device->nrofbuffers; i++) {
+            if (device->buffers[i] == pDSB) {
+                /* Put the last buffer of the list in the (now empty) position */
+                device->buffers[i] = device->buffers[device->nrofbuffers - 1];
+                break;
+            }
+        }
     }
+    device->nrofbuffers--;
+    TRACE("buffer count is now %d\n", device->nrofbuffers);
 
     RtlReleaseResource(&(device->buffer_list_lock));
 




More information about the wine-cvs mailing list