dsound: Add force format flag so drivers can determine wether to
fail if specific format cannot be set or not
Maarten Lankhorst
m.b.lankhorst at gmail.com
Mon Jun 4 08:26:56 CDT 2007
This is useful so drivers can set a vague match without failing if the
application doesn't have DSSCL_EXCLUSIVE priority.
-------------- next part --------------
>From 0e7a4b93bc657f42fa2a3727a0c77fdcd9d8b681 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date: Sat, 2 Jun 2007 17:02:44 +0200
Subject: [PATCH] dsound: Add DSBCAPS_FORCEFORMAT so drivers can determine wether format is requested or forced
---
dlls/dsound/primary.c | 11 ++++++++---
include/dsound.h | 2 ++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index ad7a5b0..9afb204 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -383,18 +383,23 @@ HRESULT DSOUND_PrimarySetFormat(DirectSoundDevice *device, LPCWAVEFORMATEX wfex)
goto done;
}
} else if (device->hwbuf) {
+ DWORD dwFlags = (device->priolevel != DSSCL_WRITEPRIMARY ? DSBCAPS_DONTFORCEFORMAT : 0);
err = IDsDriverBuffer_SetFormat(device->hwbuf, device->pwfx);
if (err == DSERR_BUFFERLOST) {
/* Wine-only: the driver wants us to recreate the HW buffer */
IDsDriverBuffer_Release(device->hwbuf);
err = IDsDriver_CreateSoundBuffer(device->driver,device->pwfx,
- DSBCAPS_PRIMARYBUFFER,0,
+ DSBCAPS_PRIMARYBUFFER, dwFlags,
&(device->buflen),&(device->buffer),
(LPVOID)&(device->hwbuf));
- if (err != DS_OK) {
- WARN("IDsDriver_CreateSoundBuffer failed\n");
+ if (FAILED(err)) {
+ WARN("IDsDriver_CreateSoundBuffer failed: %08x\n", err);
goto done;
}
+ /* Wine-only: S_FALSE means format wasn't accepted, but a different format was set */
+ if (err == S_FALSE)
+ /* Didn't get an exact match, but we did change format, so recalculate */
+ err = DSERR_BADFORMAT;
if (device->state == STATE_PLAYING) device->state = STATE_STARTING;
else if (device->state == STATE_STOPPING) device->state = STATE_STOPPED;
} else if (FAILED(err)) {
diff --git a/include/dsound.h b/include/dsound.h
index fc1eeff..ef42529 100644
--- a/include/dsound.h
+++ b/include/dsound.h
@@ -221,6 +221,8 @@ typedef const DSCAPS *LPCDSCAPS;
#define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000
#define DSBCAPS_LOCDEFER 0x00040000
+#define DSBCAPS_DONTFORCEFORMAT 0xf0000000 /* Wine specific extension: don't fail on not setting exact format, set closest matching */
+
#define DSBSIZE_MIN 4
#define DSBSIZE_MAX 0xFFFFFFF
#define DSBPAN_LEFT -10000
--
1.4.4.2
More information about the wine-patches
mailing list