Commit a2bc634e authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dsound: Handle primary buffers in IDirectSoundBufferImpl_SetFormat.

parent 3747fb74
...@@ -187,15 +187,24 @@ static inline IDirectSoundBufferImpl *impl_from_IDirectSoundBuffer8(IDirectSound ...@@ -187,15 +187,24 @@ static inline IDirectSoundBufferImpl *impl_from_IDirectSoundBuffer8(IDirectSound
return CONTAINING_RECORD(iface, IDirectSoundBufferImpl, IDirectSoundBuffer8_iface); 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, static HRESULT WINAPI IDirectSoundBufferImpl_SetFormat(IDirectSoundBuffer8 *iface,
LPCWAVEFORMATEX wfex) LPCWAVEFORMATEX wfex)
{ {
IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface); IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer8(iface);
TRACE("(%p,%p)\n",This,wfex); TRACE("(%p,%p)\n", iface, wfex);
/* This method is not available on secondary buffers */
WARN("invalid call\n"); if (is_primary_buffer(This))
return primarybuffer_SetFormat(This->device, wfex);
else {
WARN("not available for secondary buffers.\n");
return DSERR_INVALIDCALL; return DSERR_INVALIDCALL;
}
} }
static HRESULT WINAPI IDirectSoundBufferImpl_SetVolume(IDirectSoundBuffer8 *iface, LONG vol) static HRESULT WINAPI IDirectSoundBufferImpl_SetVolume(IDirectSoundBuffer8 *iface, LONG vol)
......
...@@ -336,6 +336,7 @@ HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_ ...@@ -336,6 +336,7 @@ HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_
HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb, HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb,
const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN; const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN;
void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN; void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
/* duplex.c */ /* duplex.c */
......
...@@ -472,12 +472,14 @@ LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) ...@@ -472,12 +472,14 @@ LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex)
return pwfx; return pwfx;
} }
static HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex, BOOL forced) HRESULT primarybuffer_SetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex)
{ {
HRESULT err = DSERR_BUFFERLOST; HRESULT err = DSERR_BUFFERLOST;
int i; int i;
DWORD nSamplesPerSec, bpp, chans; DWORD nSamplesPerSec, bpp, chans;
LPWAVEFORMATEX oldpwfx; LPWAVEFORMATEX oldpwfx;
BOOL forced = device->priolevel == DSSCL_WRITEPRIMARY;
TRACE("(%p,%p)\n", device, wfex); TRACE("(%p,%p)\n", device, wfex);
if (device->priolevel == DSSCL_NORMAL) { if (device->priolevel == DSSCL_NORMAL) {
...@@ -628,9 +630,8 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFormat( ...@@ -628,9 +630,8 @@ static HRESULT WINAPI PrimaryBufferImpl_SetFormat(
LPCWAVEFORMATEX wfex) LPCWAVEFORMATEX wfex)
{ {
IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface); IDirectSoundBufferImpl *This = impl_from_IDirectSoundBuffer(iface);
DirectSoundDevice *device = This->device;
TRACE("(%p,%p)\n", iface, wfex); 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( static HRESULT WINAPI PrimaryBufferImpl_SetVolume(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment