Michael Stefaniuc : dsound: Handle primary buffers in IDirectSoundBufferImpl_SetFormat.
Alexandre Julliard
julliard at winehq.org
Wed Aug 31 13:19:21 CDT 2011
Module: wine
Branch: master
Commit: a2bc634eaaf43a9e199f20d621b7b1a3fcf63752
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a2bc634eaaf43a9e199f20d621b7b1a3fcf63752
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Wed Aug 31 01:17:04 2011 +0200
dsound: Handle primary buffers in IDirectSoundBufferImpl_SetFormat.
---
dlls/dsound/buffer.c | 19 ++++++++++++++-----
dlls/dsound/dsound_private.h | 1 +
dlls/dsound/primary.c | 7 ++++---
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index 5c8fbba..7f1d005 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -187,15 +187,24 @@ static inline IDirectSoundBufferImpl *impl_from_IDirectSoundBuffer8(IDirectSound
return CONTAINING_RECORD(iface, IDirectSoundBufferImpl, IDirectSoundBuffer8_iface);
}
+static inline BOOL is_primary_buffer(IDirectSoundBufferImpl *This)
+{
+ return This->dsbd.dwFlags & DSBCAPS_PRIMARYBUFFER ? TRUE : FALSE;
+}
+
static HRESULT WINAPI IDirectSoundBufferImpl_SetFormat(IDirectSoundBuffer8 *iface,
LPCWAVEFORMATEX wfex)
{
- IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface);
+ IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface);
+
+ TRACE("(%p,%p)\n", iface, wfex);
- TRACE("(%p,%p)\n",This,wfex);
- /* This method is not available on secondary buffers */
- WARN("invalid call\n");
- return DSERR_INVALIDCALL;
+ if (is_primary_buffer(This))
+ return primarybuffer_SetFormat(This->device, wfex);
+ else {
+ WARN("not available for secondary buffers.\n");
+ return DSERR_INVALIDCALL;
+ }
}
static HRESULT WINAPI IDirectSoundBufferImpl_SetVolume(IDirectSoundBuffer8 *iface, LONG vol)
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index ed13b71..61c8b0d 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -336,6 +336,7 @@ HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_
HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb,
const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN;
void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
+HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
/* duplex.c */
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index b3d1517..c726edf 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -472,12 +472,14 @@ LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex)
return pwfx;
}
-static HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex, BOOL forced)
+HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex)
{
HRESULT err = DSERR_BUFFERLOST;
int i;
DWORD nSamplesPerSec, bpp, chans;
LPWAVEFORMATEX oldpwfx;
+ BOOL forced = device->priolevel == DSSCL_WRITEPRIMARY;
+
TRACE("(%p,%p)\n", device, wfex);
if (device->priolevel == DSSCL_NORMAL) {
@@ -628,9 +630,8 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFormat(
LPCWAVEFORMATEX wfex)
{
IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface);
- DirectSoundDevice *device = This->device;
TRACE("(%p,%p)\n", iface, wfex);
- return DSOUND_PrimarySetFormat(device, wfex, device->priolevel == DSSCL_WRITEPRIMARY);
+ return primarybuffer_SetFormat(This->device, wfex);
}
static HRESULT WINAPI PrimaryBufferImpl_SetVolume(
More information about the wine-cvs
mailing list