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
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);
TRACE("(%p,%p)\n",This,wfex);
/* This method is not available on secondary buffers */
WARN("invalid call\n");
TRACE("(%p,%p)\n", iface, wfex);
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)
......
......@@ -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 */
......
......@@ -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(
......
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