[PATCH 1/2] dsound: Add secondarybuffer_is_audible().

Florian Will florian.will at gmail.com
Thu Dec 2 09:37:07 CST 2021


Signed-off-by: Florian Will <florian.will at gmail.com>
---
 dlls/dsound/buffer.c         | 15 +++++++++++++++
 dlls/dsound/dsound_private.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index c595b19dd63..3d848053842 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -1197,6 +1197,21 @@ void secondarybuffer_destroy(IDirectSoundBufferImpl *This)
     TRACE("(%p) released\n", This);
 }
 
+/* Check if anything is audible. Even if this returns false, the lVolume of this buffer might not
+ * actually be DSBVOLUME_MIN. Setting the volume close to DSBVOLUME_MIN will lead to a
+ * dwTotalAmpFactor of 0, too. This function will return false in these cases because the effect is
+ * the same as setting the volume to DSBVOLUME_MIN, i.e. this buffer is not audible. */
+BOOL secondarybuffer_is_audible(IDirectSoundBufferImpl *This)
+{
+    UINT i;
+    for (i = 0; i < This->device->pwfx->nChannels; i++) {
+        if (This->volpan.dwTotalAmpFactor[i] != 0)
+            return TRUE;
+    }
+
+   return FALSE;
+}
+
 HRESULT IDirectSoundBufferImpl_Duplicate(
     DirectSoundDevice *device,
     IDirectSoundBufferImpl **ppdsb,
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index 9ec96504a50..18dc369db5c 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -193,6 +193,7 @@ HRESULT IDirectSoundBufferImpl_Duplicate(
     IDirectSoundBufferImpl **ppdsb,
     IDirectSoundBufferImpl *pdsb) DECLSPEC_HIDDEN;
 void secondarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
+BOOL secondarybuffer_is_audible(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
 extern const IDirectSound3DListenerVtbl ds3dlvt DECLSPEC_HIDDEN;
 extern const IDirectSound3DBufferVtbl ds3dbvt DECLSPEC_HIDDEN;
 extern const IKsPropertySetVtbl iksbvt DECLSPEC_HIDDEN;
-- 
2.32.0




More information about the wine-devel mailing list