From 462599cf79d964c6add1a7250f654d2e3110c4d2 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 23 Dec 2015 00:58:57 +0100
Subject: Revert "dsound: Use a better name for
 IDirectSoundBufferImpl_Create()."

This reverts commit bb72548f3870b1df03ad9fe7ad2e543a69d5d574.
---
 dlls/dsound/buffer.c         | 24 +++++++++++++++---------
 dlls/dsound/dsound.c         |  7 +++++--
 dlls/dsound/dsound_private.h |  6 ++++--
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index 2a80c3f..d7717fd 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -983,15 +983,19 @@ static const IDirectSoundBuffer8Vtbl dsbvt =
 	IDirectSoundBufferImpl_GetObjectInPath
 };
 
-HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *dsbd,
-        IDirectSoundBuffer **buffer)
+HRESULT IDirectSoundBufferImpl_Create(
+	DirectSoundDevice * device,
+	IDirectSoundBufferImpl **pdsb,
+	LPCDSBUFFERDESC dsbd)
 {
 	IDirectSoundBufferImpl *dsb;
 	LPWAVEFORMATEX wfex = dsbd->lpwfxFormat;
 	HRESULT err = DS_OK;
 	DWORD capf = 0;
 
-        TRACE("(%p,%p,%p)\n", device, dsbd, buffer);
+	TRACE("(%p,%p,%p)\n",device,pdsb,dsbd);
+
+        *pdsb = NULL;
 
 	if (dsbd->dwBufferBytes < DSBSIZE_MIN || dsbd->dwBufferBytes > DSBSIZE_MAX) {
 		WARN("invalid parameter: dsbd->dwBufferBytes = %d\n", dsbd->dwBufferBytes);
@@ -1103,12 +1107,14 @@ HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *ds
 
 	RtlInitializeResource(&dsb->lock);
 
-        /* register buffer */
-        err = DirectSoundDevice_AddBuffer(device, dsb);
-        if (err == DS_OK)
-                *buffer = (IDirectSoundBuffer*)&dsb->IDirectSoundBuffer8_iface;
-        else
-                IDirectSoundBuffer8_Release(&dsb->IDirectSoundBuffer8_iface);
+	/* register buffer if not primary */
+	if (!(dsbd->dwFlags & DSBCAPS_PRIMARYBUFFER)) {
+		err = DirectSoundDevice_AddBuffer(device, dsb);
+                if (err == DS_OK)
+                        *pdsb = dsb;
+                else
+                        IDirectSoundBuffer8_Release(&dsb->IDirectSoundBuffer8_iface);
+	}
 
 	return err;
 }
diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c
index ccefd1f..e50ef58 100644
--- a/dlls/dsound/dsound.c
+++ b/dlls/dsound/dsound.c
@@ -469,6 +469,8 @@ static HRESULT DirectSoundDevice_CreateSoundBuffer(
                 WARN("primarybuffer_create() failed\n");
         }
     } else {
+        IDirectSoundBufferImpl * dsb;
+
         if (dsbd->lpwfxFormat == NULL) {
             WARN("invalid parameter: dsbd->lpwfxFormat can't be NULL for "
                  "secondary buffer\n");
@@ -545,8 +547,9 @@ static HRESULT DirectSoundDevice_CreateSoundBuffer(
             return DSERR_INVALIDPARAM;
         }
 
-        hres = secondarybuffer_create(device, dsbd, ppdsb);
-        if (SUCCEEDED(hres)) {
+        hres = IDirectSoundBufferImpl_Create(device, &dsb, dsbd);
+        if (dsb) {
+            *ppdsb = (IDirectSoundBuffer*)&dsb->IDirectSoundBuffer8_iface;
             if (dsbd->dwFlags & DSBCAPS_LOCHARDWARE)
                 device->drvcaps.dwFreeHwMixingAllBuffers--;
         } else
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index 07bda48..9c001ed 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -182,8 +182,10 @@ void put_stereo2quad(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel
 void put_mono2surround51(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
 void put_stereo2surround51(const IDirectSoundBufferImpl *dsb, DWORD pos, DWORD channel, float value) DECLSPEC_HIDDEN;
 
-HRESULT secondarybuffer_create(DirectSoundDevice *device, const DSBUFFERDESC *dsbd,
-        IDirectSoundBuffer **buffer) DECLSPEC_HIDDEN;
+HRESULT IDirectSoundBufferImpl_Create(
+    DirectSoundDevice *device,
+    IDirectSoundBufferImpl **ppdsb,
+    LPCDSBUFFERDESC dsbd) DECLSPEC_HIDDEN;
 HRESULT IDirectSoundBufferImpl_Duplicate(
     DirectSoundDevice *device,
     IDirectSoundBufferImpl **ppdsb,
-- 
2.6.4

