Updated xactengine3_7-callbacks patchset

Tested with
- Lost Chronicles of Zerzura.
- Monkey Island 2.
- Gridrunner   (Might still crashes in some scenario)
- Neptunia Rebirth1
This commit is contained in:
Alistair Leslie-Hughes 2022-07-22 09:33:13 +10:00
parent ab31919ee5
commit 86091d3b1f
11 changed files with 569 additions and 398 deletions

View File

@ -263,6 +263,7 @@ patch_enable_all ()
enable_xactengine_initial="$1"
enable_xactengine3_7_Notification="$1"
enable_xactengine3_7_PrepareWave="$1"
enable_xactengine3_7_callbacks="$1"
}
# Enable or disable a specific patchset
@ -812,6 +813,9 @@ patch_enable ()
xactengine3_7-PrepareWave)
enable_xactengine3_7_PrepareWave="$2"
;;
xactengine3_7-callbacks)
enable_xactengine3_7_callbacks="$2"
;;
*)
return 1
;;
@ -1159,6 +1163,13 @@ patch_apply()
}
if test "$enable_xactengine3_7_callbacks" -eq 1; then
if test "$enable_xactengine3_7_Notification" -gt 1; then
abort "Patchset xactengine3_7-Notification disabled, but xactengine3_7-callbacks depends on that."
fi
enable_xactengine3_7_Notification=1
fi
if test "$enable_winex11_WM_WINDOWPOSCHANGING" -eq 1; then
if test "$enable_winex11__NET_ACTIVE_WINDOW" -gt 1; then
abort "Patchset winex11-_NET_ACTIVE_WINDOW disabled, but winex11-WM_WINDOWPOSCHANGING depends on that."
@ -3890,6 +3901,26 @@ if test "$enable_xactengine3_7_PrepareWave" -eq 1; then
patch_apply xactengine3_7-PrepareWave/0003-xactengine3_7-Implement-IXACT3Engine-PrepareInMemory.patch
fi
# Patchset xactengine3_7-callbacks
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * xactengine3_7-Notification
# |
# | This patchset fixes the following Wine bugs:
# | * [#49678] - xactengine: Implement callback notifications.
# |
# | Modified files:
# | * dlls/xactengine3_7/xact_dll.c
# |
if test "$enable_xactengine3_7_callbacks" -eq 1; then
patch_apply xactengine3_7-callbacks/0001-xactengine3_7-Add-helper-function-to-add-entries.patch
patch_apply xactengine3_7-callbacks/0002-xactengine3_7-Map-SoundBank-interfaces.patch
patch_apply xactengine3_7-callbacks/0003-xactengine3_7-Map-IXACT3Cue-interfaces.patch
patch_apply xactengine3_7-callbacks/0004-xactengine3_7-Map-IXACT3Wave-interfaces.patch
patch_apply xactengine3_7-callbacks/0005-xactengine3_7-Implement-callback-for-supported-messa.patch
patch_apply xactengine3_7-callbacks/0006-xactengine3_7-Remove-Entry-after-FAudio-Destroyed-ca.patch
fi
if test "$enable_autoconf" -eq 1; then
if ! update_configure; then
abort "'autoreconf -f' failed."

View File

@ -1,159 +0,0 @@
From 71be762c3d84b84c3d9249f80467797ce3519bb6 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Sat, 12 Sep 2020 16:31:09 +1000
Subject: Add support for private contexts
diff --git a/libs/faudio/include/FACT.h b/libs/faudio/include/FACT.h
index 579b7168812..084b1e55cfe 100644
--- a/libs/faudio/include/FACT.h
+++ b/libs/faudio/include/FACT.h
@@ -805,6 +805,18 @@ FACTAPI uint32_t FACTCue_SetOutputVoiceMatrix(
const float *pLevelMatrix /* SourceChannels * DestinationChannels */
);
+FACTAPI void FACTWave_SetPrivateContext(FACTWave *pWave, void *context);
+FACTAPI void* FACTWave_GetPrivateContext(FACTWave *pWave);
+
+FACTAPI void FACTWaveBank_SetPrivateContext(FACTWaveBank *pWaveBank, void *context);
+FACTAPI void* FACTWaveBank_GetPrivateContext(FACTWaveBank *pWaveBank);
+
+FACTAPI void FACTSoundBank_SetPrivateContext(FACTSoundBank *pSoundBank, void *context);
+FACTAPI void* FACTSoundBank_GetPrivateContext(FACTSoundBank *pSoundBank);
+
+FACTAPI void FACTCue_SetPrivateContext(FACTCue *pCue, void *context);
+FACTAPI void* FACTCue_GetPrivateContext(FACTCue *pCue);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/libs/faudio/src/FACT.c b/libs/faudio/src/FACT.c
index 5eca83b389f..e2e7b10058d 100644
--- a/libs/faudio/src/FACT.c
+++ b/libs/faudio/src/FACT.c
@@ -1177,6 +1177,9 @@ uint32_t FACTSoundBank_Prepare(
(*ppCue)->notifyOnDestroy = 0;
(*ppCue)->usercontext = NULL;
+ /* User data */
+ (*ppCue)->privatecontext = NULL;
+
/* Sound data */
(*ppCue)->data = &pSoundBank->cues[nCueIndex];
if ((*ppCue)->data->flags & 0x04)
@@ -1798,6 +1801,9 @@ uint32_t FACTWaveBank_Prepare(
(*ppWave)->pitch = 0;
(*ppWave)->loopCount = nLoopCount;
+ /* User data */
+ (*ppWave)->privatecontext = NULL;
+
/* TODO: Convert dwPlayOffset to a byte offset */
FAudio_assert(dwPlayOffset == 0);
#if 0
@@ -2175,11 +2181,14 @@ uint32_t FACTWave_Stop(FACTWave *pWave, uint32_t dwFlags)
{
FACTNotification note;
note.type = FACTNOTIFICATIONTYPE_WAVESTOP;
+ note.wave.cueIndex = pWave->parentCue->index;
+ note.wave.pCue = pWave->parentCue;
+ note.wave.pSoundBank = pWave->parentCue->parentBank;
note.wave.pWave = pWave;
- if (pWave->parentBank->parentEngine->notifications & NOTIFY_WAVESTOP)
- {
- note.pvContext = pWave->parentBank->parentEngine->wave_context;
- }
+ note.wave.pWaveBank = pWave->parentBank;
+
+ note.pvContext = pWave->parentBank->parentEngine->wave_context;
+
pWave->parentBank->parentEngine->notificationCallback(&note);
}
@@ -3018,4 +3027,42 @@ uint32_t FACTCue_SetOutputVoiceMatrix(
return 0;
}
+void FACTWave_SetPrivateContext(FACTWave *pWave, void *context)
+{
+ pWave->privatecontext = context;
+}
+void* FACTWave_GetPrivateContext(FACTWave *pWave)
+{
+ return pWave->privatecontext;
+}
+
+FACTAPI void FACTWaveBank_SetPrivateContext(FACTWaveBank *pWaveBank, void *context)
+{
+ pWaveBank->privatecontext = context;
+}
+
+FACTAPI void* FACTWaveBank_GetPrivateContext(FACTWaveBank *pWaveBank)
+{
+ return pWaveBank->privatecontext;
+}
+
+FACTAPI void FACTSoundBank_SetPrivateContext(FACTSoundBank *pSoundBank, void *context)
+{
+ pSoundBank->privatecontext = context;
+}
+FACTAPI void* FACTSoundBank_GetPrivateContext(FACTSoundBank *pSoundBank)
+{
+ return pSoundBank->privatecontext;
+}
+
+FACTAPI void FACTCue_SetPrivateContext(FACTCue *pCue, void *context)
+{
+ pCue->privatecontext = context;
+}
+
+FACTAPI void* FACTCue_GetPrivateContext(FACTCue *pCue)
+{
+ return pCue->privatecontext;
+}
+
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */
diff --git a/libs/faudio/src/FACT_internal.h b/libs/faudio/src/FACT_internal.h
index 6bf522e64c4..52d07e5f9d3 100644
--- a/libs/faudio/src/FACT_internal.h
+++ b/libs/faudio/src/FACT_internal.h
@@ -473,6 +473,9 @@ struct FACTSoundBank
uint32_t *variationCodes;
FACTTransitionTable *transitions;
uint32_t *transitionCodes;
+
+ /* Application data */
+ void *privatecontext;
};
struct FACTWaveBank
@@ -498,6 +501,9 @@ struct FACTWaveBank
uint8_t *packetBuffer;
uint32_t packetBufferLen;
void* io;
+
+ /* Application data */
+ void *privatecontext;
};
struct FACTWave
@@ -524,6 +530,9 @@ struct FACTWave
uint16_t srcChannels;
FAudioSourceVoice *voice;
FACTWaveCallback callback;
+
+ /* Application data */
+ void *privatecontext;
};
struct FACTCue
@@ -569,6 +578,9 @@ struct FACTCue
/* Timer */
uint32_t start;
uint32_t elapsed;
+
+ /* Application data */
+ void *privatecontext;
};
/* Internal functions */

View File

@ -0,0 +1,137 @@
From 5eaf6ecd797b085898e95c6710b6d47e805b7811 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 20 Jul 2022 11:32:36 +1000
Subject: [PATCH 1/4] xactengine3_7: Add helper function to add entries
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/xactengine3_7/xact_dll.c | 67 +++++++++++++++++------------------
1 file changed, 33 insertions(+), 34 deletions(-)
diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c
index 7664328dbc4..421c509fcfa 100644
--- a/dlls/xactengine3_7/xact_dll.c
+++ b/dlls/xactengine3_7/xact_dll.c
@@ -88,6 +88,33 @@ typedef struct _XACT3EngineImpl {
CRITICAL_SECTION wb_wrapper_lookup_cs;
} XACT3EngineImpl;
+static HRESULT wrapper_add_entry(XACT3EngineImpl *engine, void *fwb, void *xact)
+{
+ struct wrapper_lookup *lookup;
+ UINT ret;
+
+ lookup = HeapAlloc(GetProcessHeap(), 0, sizeof(*lookup));
+ if (!lookup)
+ {
+ ERR("Failed to allocate wrapper_lookup!\n");
+ return E_OUTOFMEMORY;
+ }
+ lookup->fact = fwb;
+ lookup->xact = xact;
+
+ EnterCriticalSection(&engine->wb_wrapper_lookup_cs);
+ ret = wine_rb_put(&engine->wb_wrapper_lookup, lookup->fact, &lookup->entry);
+ LeaveCriticalSection(&engine->wb_wrapper_lookup_cs);
+
+ if (ret)
+ {
+ WARN("wrapper_lookup already present in the tree??\n");
+ HeapFree(GetProcessHeap(), 0, lookup);
+ }
+
+ return S_OK;
+}
+
typedef struct _XACT3CueImpl {
IXACT3Cue IXACT3Cue_iface;
FACTCue *fact_cue;
@@ -1086,9 +1113,9 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateInMemoryWaveBank(IXACT3Engine *ifac
DWORD dwAllocAttributes, IXACT3WaveBank **ppWaveBank)
{
XACT3EngineImpl *This = impl_from_IXACT3Engine(iface);
- struct wrapper_lookup *lookup;
XACT3WaveBankImpl *wb;
FACTWaveBank *fwb;
+ HRESULT hr;
UINT ret;
TRACE("(%p)->(%p, %lu, 0x%lx, 0x%lx, %p)\n", This, pvBuffer, dwSize, dwFlags,
@@ -1110,28 +1137,14 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateInMemoryWaveBank(IXACT3Engine *ifac
return E_OUTOFMEMORY;
}
- lookup = HeapAlloc(GetProcessHeap(), 0, sizeof(*lookup));
- if (!lookup)
+ hr = wrapper_add_entry(This, fwb, &wb->IXACT3WaveBank_iface);
+ if (FAILED(hr))
{
FACTWaveBank_Destroy(fwb);
HeapFree(GetProcessHeap(), 0, wb);
ERR("Failed to allocate wrapper_lookup!\n");
return E_OUTOFMEMORY;
}
- lookup->fact = fwb;
- lookup->xact = &wb->IXACT3WaveBank_iface;
-
- EnterCriticalSection(&This->wb_wrapper_lookup_cs);
-
- ret = wine_rb_put(&This->wb_wrapper_lookup, lookup->fact, &lookup->entry);
-
- LeaveCriticalSection(&This->wb_wrapper_lookup_cs);
-
- if (ret)
- {
- WARN("wrapper_lookup already present in the tree??\n");
- HeapFree(GetProcessHeap(), 0, lookup);
- }
wb->IXACT3WaveBank_iface.lpVtbl = &XACT3WaveBank_Vtbl;
wb->fact_wavebank = fwb;
@@ -1149,11 +1162,11 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateStreamingWaveBank(IXACT3Engine *ifa
{
XACT3EngineImpl *This = impl_from_IXACT3Engine(iface);
FACTStreamingParameters fakeParms;
- struct wrapper_lookup *lookup;
wrap_readfile_struct *fake;
XACT3WaveBankImpl *wb;
FACTWaveBank *fwb;
UINT ret;
+ HRESULT hr;
TRACE("(%p)->(%p, %p)\n", This, pParms, ppWaveBank);
@@ -1183,28 +1196,14 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateStreamingWaveBank(IXACT3Engine *ifa
return E_OUTOFMEMORY;
}
- lookup = HeapAlloc(GetProcessHeap(), 0, sizeof(*lookup));
- if (!lookup)
+ hr = wrapper_add_entry(This, fwb, &wb->IXACT3WaveBank_iface);
+ if (FAILED(hr))
{
FACTWaveBank_Destroy(fwb);
HeapFree(GetProcessHeap(), 0, wb);
ERR("Failed to allocate wrapper_lookup!\n");
return E_OUTOFMEMORY;
}
- lookup->fact = fwb;
- lookup->xact = &wb->IXACT3WaveBank_iface;
-
- EnterCriticalSection(&This->wb_wrapper_lookup_cs);
-
- ret = wine_rb_put(&This->wb_wrapper_lookup, lookup->fact, &lookup->entry);
-
- LeaveCriticalSection(&This->wb_wrapper_lookup_cs);
-
- if (ret)
- {
- WARN("wrapper_lookup already present in the tree??\n");
- HeapFree(GetProcessHeap(), 0, lookup);
- }
wb->IXACT3WaveBank_iface.lpVtbl = &XACT3WaveBank_Vtbl;
wb->fact_wavebank = fwb;
--
2.35.1

View File

@ -0,0 +1,41 @@
From 2ca9f0e03bed89e91c1ff42f2e23b67e8f1b2e0c Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 22 Jul 2022 09:57:22 +1000
Subject: [PATCH] xactengine3_7: Map SoundBank interfaces
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/xactengine3_7/xact_dll.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c
index 421c509fcfa..106f912ffa0 100644
--- a/dlls/xactengine3_7/xact_dll.c
+++ b/dlls/xactengine3_7/xact_dll.c
@@ -1079,6 +1079,7 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateSoundBank(IXACT3Engine *iface,
XACT3SoundBankImpl *sb;
FACTSoundBank *fsb;
UINT ret;
+ HRESULT hr;
TRACE("(%p)->(%p, %lu, 0x%lx, 0x%lx, %p): stub!\n", This, pvBuffer, dwSize, dwFlags,
dwAllocAttributes, ppSoundBank);
@@ -1099,6 +1100,15 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateSoundBank(IXACT3Engine *iface,
return E_OUTOFMEMORY;
}
+ hr = wrapper_add_entry(This, fsb, &sb->IXACT3SoundBank_iface);
+ if (FAILED(hr))
+ {
+ FACTSoundBank_Destroy(fsb);
+ HeapFree(GetProcessHeap(), 0, sb);
+ ERR("Failed to allocate wrapper_lookup!\n");
+ return E_OUTOFMEMORY;
+ }
+
sb->IXACT3SoundBank_iface.lpVtbl = &XACT3SoundBank_Vtbl;
sb->fact_soundbank = fsb;
*ppSoundBank = &sb->IXACT3SoundBank_iface;
--
2.35.1

View File

@ -1,155 +0,0 @@
From a5439a8a6d3706ee6c3ea13cd76deee1484083d4 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Sat, 12 Sep 2020 14:10:18 +1000
Subject: xactengine3_7: notifications
diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c
index 326f79f0ecd..62084f9234f 100644
--- a/dlls/xactengine3_7/xact_dll.c
+++ b/dlls/xactengine3_7/xact_dll.c
@@ -329,6 +329,8 @@ static HRESULT WINAPI IXACT3SoundBankImpl_Prepare(IXACT3SoundBank *iface,
cue->fact_cue = fcue;
*ppCue = &cue->IXACT3Cue_iface;
+ FACTCue_SetPrivateContext(fcue, &cue->IXACT3Cue_iface);
+
TRACE("Created Cue: %p\n", cue);
return S_OK;
@@ -370,6 +372,8 @@ static HRESULT WINAPI IXACT3SoundBankImpl_Play(IXACT3SoundBank *iface,
cue->IXACT3Cue_iface.lpVtbl = &XACT3Cue_Vtbl;
cue->fact_cue = fcue;
*ppCue = &cue->IXACT3Cue_iface;
+
+ FACTCue_SetPrivateContext(fcue, &cue->IXACT3Cue_iface);
}
return hr;
@@ -627,6 +631,8 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Prepare(IXACT3WaveBank *iface,
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
+ FACTWave_SetPrivateContext(fwave, &wave->IXACT3Wave_iface);
+
TRACE("Created Wave: %p\n", wave);
return S_OK;
@@ -668,6 +674,8 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Play(IXACT3WaveBank *iface,
wave->IXACT3Wave_iface.lpVtbl = &XACT3Wave_Vtbl;
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
+
+ FACTWave_SetPrivateContext(fwave, &wave->IXACT3Wave_iface);
}
return hr;
@@ -837,6 +845,7 @@ static HRESULT WINAPI IXACT3EngineImpl_GetFinalMixFormat(IXACT3Engine *iface,
static void FACTCALL fact_notification_cb(const FACTNotification *notification)
{
XACT3EngineImpl *engine = (XACT3EngineImpl *)notification->pvContext;
+ XACT_NOTIFICATION note;
/* Older versions of FAudio don't pass through the context */
if (!engine)
@@ -845,7 +854,45 @@ static void FACTCALL fact_notification_cb(const FACTNotification *notification)
return;
}
- FIXME("Unsupported callback type %d\n", notification->type);
+ note.type = notification->type;
+ note.pvContext = engine->contexts[notification->type - 1];
+
+ switch (notification->type)
+ {
+ case XACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED:
+ note.soundBank.pSoundBank = FACTSoundBank_GetPrivateContext(notification->wave.pSoundBank);
+ break;
+#if XACT3_VER >= 0x0205
+ case XACTNOTIFICATIONTYPE_WAVEDESTROYED:
+ case XACTNOTIFICATIONTYPE_WAVELOOPED:
+ case XACTNOTIFICATIONTYPE_WAVEPLAY:
+ case XACTNOTIFICATIONTYPE_WAVEPREPARED:
+#endif
+ case XACTNOTIFICATIONTYPE_WAVESTOP:
+ note.wave.cueIndex = notification->wave.cueIndex;
+ note.wave.pCue = FACTCue_GetPrivateContext(notification->wave.pCue);
+ note.wave.pSoundBank = FACTSoundBank_GetPrivateContext(notification->wave.pSoundBank);
+#if XACT3_VER >= 0x0205
+ note.wave.pWave = FACTWave_GetPrivateContext(notification->wave.pWave);
+#endif
+ note.wave.pWaveBank = FACTWaveBank_GetPrivateContext(notification->wave.pWaveBank);
+ break;
+
+ case XACTNOTIFICATIONTYPE_CUEPLAY:
+ case XACTNOTIFICATIONTYPE_CUEPREPARED:
+ case XACTNOTIFICATIONTYPE_CUESTOP:
+ note.cue.pCue = FACTCue_GetPrivateContext(notification->cue.pCue);
+ /* Fall through */
+ case XACTNOTIFICATIONTYPE_CUEDESTROYED:
+ note.cue.cueIndex = notification->cue.cueIndex;
+ note.cue.pSoundBank = FACTSoundBank_GetPrivateContext(notification->cue.pSoundBank);
+ break;
+ default:
+ FIXME("Unsupported callback type %d\n", notification->type);
+ return;
+ }
+
+ engine->notification_callback(&note);
}
static HRESULT WINAPI IXACT3EngineImpl_Initialize(IXACT3Engine *iface,
@@ -961,6 +1008,8 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateSoundBank(IXACT3Engine *iface,
sb->fact_soundbank = fsb;
*ppSoundBank = &sb->IXACT3SoundBank_iface;
+ FACTSoundBank_SetPrivateContext(fsb, &sb->IXACT3SoundBank_iface);
+
TRACE("Created SoundBank: %p\n", sb);
return S_OK;
@@ -1037,6 +1086,8 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateInMemoryWaveBank(IXACT3Engine *ifac
send_wavebank_notification(This, &wb->IXACT3WaveBank_iface);
+ FACTWaveBank_SetPrivateContext(fwb, &wb->IXACT3WaveBank_iface);
+
TRACE("Created in-memory WaveBank: %p\n", wb);
return S_OK;
@@ -1087,6 +1138,8 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateStreamingWaveBank(IXACT3Engine *ifa
send_wavebank_notification(This, &wb->IXACT3WaveBank_iface);
+ FACTWaveBank_SetPrivateContext(fwb, &wb->IXACT3WaveBank_iface);
+
TRACE("Created streaming WaveBank: %p\n", wb);
return S_OK;
@@ -1135,6 +1188,8 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareInMemoryWave(IXACT3Engine *iface,
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
+ FACTWave_SetPrivateContext(fwave, &wave->IXACT3Wave_iface);
+
TRACE("Created Wave: %p\n", wave);
return S_OK;
@@ -1197,6 +1252,8 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareStreamingWave(IXACT3Engine *iface,
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
+ FACTWave_SetPrivateContext(fwave, &wave->IXACT3Wave_iface);
+
TRACE("Created Wave: %p\n", wave);
return S_OK;
@@ -1234,6 +1291,8 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareWave(IXACT3Engine *iface,
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
+ FACTWave_SetPrivateContext(fwave, &wave->IXACT3Wave_iface);
+
TRACE("Created Wave: %p\n", wave);
return S_OK;

View File

@ -0,0 +1,73 @@
From c0a826bcea42fe6988b110d811064fa2208a3c5c Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Thu, 21 Jul 2022 08:04:13 +1000
Subject: [PATCH] xactengine3_7: Map IXACT3Cue interfaces
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/xactengine3_7/xact_dll.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c
index 106f912ffa0..b3e66dbf717 100644
--- a/dlls/xactengine3_7/xact_dll.c
+++ b/dlls/xactengine3_7/xact_dll.c
@@ -320,6 +320,7 @@ typedef struct _XACT3SoundBankImpl {
IXACT3SoundBank IXACT3SoundBank_iface;
FACTSoundBank *fact_soundbank;
+ XACT3EngineImpl *engine;
} XACT3SoundBankImpl;
static inline XACT3SoundBankImpl *impl_from_IXACT3SoundBank(IXACT3SoundBank *iface)
@@ -369,6 +370,7 @@ static HRESULT WINAPI IXACT3SoundBankImpl_Prepare(IXACT3SoundBank *iface,
FACTCue *fcue;
UINT ret;
+ HRESULT hr;
TRACE("(%p)->(%u, 0x%lx, %lu, %p)\n", This, nCueIndex, dwFlags, timeOffset,
ppCue);
@@ -389,6 +391,15 @@ static HRESULT WINAPI IXACT3SoundBankImpl_Prepare(IXACT3SoundBank *iface,
return E_OUTOFMEMORY;
}
+ hr = wrapper_add_entry(This->engine, fcue, &cue->IXACT3Cue_iface);
+ if (FAILED(hr))
+ {
+ FACTCue_Destroy(fcue);
+ HeapFree(GetProcessHeap(), 0, cue);
+ ERR("Failed to allocate wrapper_lookup!\n");
+ return E_OUTOFMEMORY;
+ }
+
cue->IXACT3Cue_iface.lpVtbl = &XACT3Cue_Vtbl;
cue->fact_cue = fcue;
*ppCue = &cue->IXACT3Cue_iface;
@@ -431,6 +442,15 @@ static HRESULT WINAPI IXACT3SoundBankImpl_Play(IXACT3SoundBank *iface,
return E_OUTOFMEMORY;
}
+ hr = wrapper_add_entry(This->engine, fcue, &cue->IXACT3Cue_iface);
+ if (FAILED(hr))
+ {
+ FACTCue_Destroy(fcue);
+ HeapFree(GetProcessHeap(), 0, cue);
+ ERR("Failed to allocate wrapper_lookup!\n");
+ return E_OUTOFMEMORY;
+ }
+
cue->IXACT3Cue_iface.lpVtbl = &XACT3Cue_Vtbl;
cue->fact_cue = fcue;
*ppCue = &cue->IXACT3Cue_iface;
@@ -1111,6 +1131,7 @@ static HRESULT WINAPI IXACT3EngineImpl_CreateSoundBank(IXACT3Engine *iface,
sb->IXACT3SoundBank_iface.lpVtbl = &XACT3SoundBank_Vtbl;
sb->fact_soundbank = fsb;
+ sb->engine = This;
*ppSoundBank = &sb->IXACT3SoundBank_iface;
TRACE("Created SoundBank: %p\n", sb);
--
2.35.1

View File

@ -1,83 +0,0 @@
From cb0480cc441f4f2c599f506fbac5d27552f55cdd Mon Sep 17 00:00:00 2001
From: "Olivier F. R. Dierick" <o.dierick@piezo-forte.be>
Date: Sat, 29 Jan 2022 22:46:07 +0100
Subject: xactengine3_7: Don't use switch with constant integers.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52478
diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c
index 62084f9234f..83b7b760118 100644
--- a/dlls/xactengine3_7/xact_dll.c
+++ b/dlls/xactengine3_7/xact_dll.c
@@ -857,40 +857,43 @@ static void FACTCALL fact_notification_cb(const FACTNotification *notification)
note.type = notification->type;
note.pvContext = engine->contexts[notification->type - 1];
- switch (notification->type)
+ if (notification->type == XACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED)
{
- case XACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED:
- note.soundBank.pSoundBank = FACTSoundBank_GetPrivateContext(notification->wave.pSoundBank);
- break;
+ note.soundBank.pSoundBank = FACTSoundBank_GetPrivateContext(notification->wave.pSoundBank);
+ }
+ else if (notification->type == XACTNOTIFICATIONTYPE_WAVESTOP
#if XACT3_VER >= 0x0205
- case XACTNOTIFICATIONTYPE_WAVEDESTROYED:
- case XACTNOTIFICATIONTYPE_WAVELOOPED:
- case XACTNOTIFICATIONTYPE_WAVEPLAY:
- case XACTNOTIFICATIONTYPE_WAVEPREPARED:
+ || notification->type == XACTNOTIFICATIONTYPE_WAVEDESTROYED
+ || notification->type == XACTNOTIFICATIONTYPE_WAVELOOPED
+ || notification->type == XACTNOTIFICATIONTYPE_WAVEPLAY
+ || notification->type == XACTNOTIFICATIONTYPE_WAVEPREPARED)
+#else
+ )
#endif
- case XACTNOTIFICATIONTYPE_WAVESTOP:
- note.wave.cueIndex = notification->wave.cueIndex;
- note.wave.pCue = FACTCue_GetPrivateContext(notification->wave.pCue);
- note.wave.pSoundBank = FACTSoundBank_GetPrivateContext(notification->wave.pSoundBank);
+ {
+ note.wave.cueIndex = notification->wave.cueIndex;
+ note.wave.pCue = FACTCue_GetPrivateContext(notification->wave.pCue);
+ note.wave.pSoundBank = FACTSoundBank_GetPrivateContext(notification->wave.pSoundBank);
#if XACT3_VER >= 0x0205
- note.wave.pWave = FACTWave_GetPrivateContext(notification->wave.pWave);
+ note.wave.pWave = FACTWave_GetPrivateContext(notification->wave.pWave);
#endif
- note.wave.pWaveBank = FACTWaveBank_GetPrivateContext(notification->wave.pWaveBank);
- break;
-
- case XACTNOTIFICATIONTYPE_CUEPLAY:
- case XACTNOTIFICATIONTYPE_CUEPREPARED:
- case XACTNOTIFICATIONTYPE_CUESTOP:
+ note.wave.pWaveBank = FACTWaveBank_GetPrivateContext(notification->wave.pWaveBank);
+ }
+ else if (notification->type == XACTNOTIFICATIONTYPE_CUEPLAY ||
+ notification->type == XACTNOTIFICATIONTYPE_CUEPREPARED ||
+ notification->type == XACTNOTIFICATIONTYPE_CUESTOP ||
+ notification->type == XACTNOTIFICATIONTYPE_CUEDESTROYED)
+ {
+ if (notification->type != XACTNOTIFICATIONTYPE_CUEDESTROYED)
note.cue.pCue = FACTCue_GetPrivateContext(notification->cue.pCue);
- /* Fall through */
- case XACTNOTIFICATIONTYPE_CUEDESTROYED:
- note.cue.cueIndex = notification->cue.cueIndex;
- note.cue.pSoundBank = FACTSoundBank_GetPrivateContext(notification->cue.pSoundBank);
- break;
- default:
- FIXME("Unsupported callback type %d\n", notification->type);
- return;
- }
+ note.cue.cueIndex = notification->cue.cueIndex;
+ note.cue.pSoundBank = FACTSoundBank_GetPrivateContext(notification->cue.pSoundBank);
+ }
+ else
+ {
+ FIXME("Unsupported callback type %d\n", notification->type);
+ return;
+ }
engine->notification_callback(&note);
}

View File

@ -0,0 +1,129 @@
From f454464118716f88cc783e0ca4b49ee8af779083 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 22 Jul 2022 08:50:57 +1000
Subject: [PATCH] xactengine3_7: Map IXACT3Wave interfaces
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/xactengine3_7/xact_dll.c | 49 +++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c
index 5cd7ed3342a..2e5dd7e9935 100644
--- a/dlls/xactengine3_7/xact_dll.c
+++ b/dlls/xactengine3_7/xact_dll.c
@@ -710,6 +710,7 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Prepare(IXACT3WaveBank *iface,
XACT3WaveImpl *wave;
FACTWave *fwave;
UINT ret;
+ HRESULT hr;
TRACE("(%p)->(0x%x, %lu, 0x%lx, %u, %p)\n", This, nWaveIndex, dwFlags,
dwPlayOffset, nLoopCount, ppWave);
@@ -730,6 +731,15 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Prepare(IXACT3WaveBank *iface,
return E_OUTOFMEMORY;
}
+ hr = wrapper_add_entry(This->engine, fwave, &wave->IXACT3Wave_iface);
+ if (FAILED(hr))
+ {
+ FACTWave_Destroy(fwave);
+ HeapFree(GetProcessHeap(), 0, wave);
+ ERR("Failed to allocate wrapper_lookup!\n");
+ return E_OUTOFMEMORY;
+ }
+
wave->IXACT3Wave_iface.lpVtbl = &XACT3Wave_Vtbl;
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
@@ -772,6 +782,15 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Play(IXACT3WaveBank *iface,
return E_OUTOFMEMORY;
}
+ hr = wrapper_add_entry(This->engine, fwave, &wave->IXACT3Wave_iface);
+ if (FAILED(hr))
+ {
+ FACTWave_Destroy(fwave);
+ HeapFree(GetProcessHeap(), 0, wave);
+ ERR("Failed to allocate wrapper_lookup!\n");
+ return E_OUTOFMEMORY;
+ }
+
wave->IXACT3Wave_iface.lpVtbl = &XACT3Wave_Vtbl;
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
@@ -1258,6 +1277,7 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareInMemoryWave(IXACT3Engine *iface,
FACTWave *fwave = NULL;
FACTWaveBankEntry fact_wavebank;
UINT ret;
+ HRESULT hr;
TRACE("(%p)->(0x%08lx, %p, %p, %p, %ld, %d, %p)\n", This, dwFlags, &entry, pdwSeekTable,
pbWaveData, dwPlayOffset, nLoopCount, ppWave);
@@ -1285,6 +1305,15 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareInMemoryWave(IXACT3Engine *iface,
return E_OUTOFMEMORY;
}
+ hr = wrapper_add_entry(This, fwave, &wave->IXACT3Wave_iface);
+ if (FAILED(hr))
+ {
+ FACTWave_Destroy(fwave);
+ HeapFree(GetProcessHeap(), 0, wave);
+ ERR("Failed to allocate wrapper_lookup!\n");
+ return E_OUTOFMEMORY;
+ }
+
wave->IXACT3Wave_iface.lpVtbl = &XACT3Wave_Vtbl;
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
@@ -1307,6 +1336,7 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareStreamingWave(IXACT3Engine *iface,
wrap_readfile_struct *fake;
FACTWaveBankEntry fact_wavebank;
UINT ret;
+ HRESULT hr;
TRACE("(%p)->(0x%08lx, %p, %p, %ld, %p, %ld, %d, %p)\n", This, dwFlags, &entry, &streamingParams,
dwAlignment, pdwSeekTable, dwPlayOffset, nLoopCount, ppWave);
@@ -1347,6 +1377,15 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareStreamingWave(IXACT3Engine *iface,
return E_OUTOFMEMORY;
}
+ hr = wrapper_add_entry(This, fwave, &wave->IXACT3Wave_iface);
+ if (FAILED(hr))
+ {
+ FACTWave_Destroy(fwave);
+ HeapFree(GetProcessHeap(), 0, wave);
+ ERR("Failed to allocate wrapper_lookup!\n");
+ return E_OUTOFMEMORY;
+ }
+
wave->IXACT3Wave_iface.lpVtbl = &XACT3Wave_Vtbl;
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
@@ -1365,6 +1404,7 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareWave(IXACT3Engine *iface,
XACT3WaveImpl *wave;
FACTWave *fwave = NULL;
UINT ret;
+ HRESULT hr;
TRACE("(%p)->(0x%08lx, %s, %d, %ld, %ld, %d, %p)\n", This, dwFlags, debugstr_a(szWavePath),
wStreamingPacketSize, dwAlignment, dwPlayOffset, nLoopCount, ppWave);
@@ -1384,6 +1424,15 @@ static HRESULT WINAPI IXACT3EngineImpl_PrepareWave(IXACT3Engine *iface,
return E_OUTOFMEMORY;
}
+ hr = wrapper_add_entry(This, fwave, &wave->IXACT3Wave_iface);
+ if (FAILED(hr))
+ {
+ FACTWave_Destroy(fwave);
+ HeapFree(GetProcessHeap(), 0, wave);
+ ERR("Failed to allocate wrapper_lookup!\n");
+ return E_OUTOFMEMORY;
+ }
+
wave->IXACT3Wave_iface.lpVtbl = &XACT3Wave_Vtbl;
wave->fact_wave = fwave;
*ppWave = &wave->IXACT3Wave_iface;
--
2.35.1

View File

@ -0,0 +1,116 @@
From d826bba5230b20f6a78eb3c1bf5a68e4a994eede Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 22 Jul 2022 09:17:06 +1000
Subject: [PATCH] xactengine3_7: Implement callback for supported messages
---
dlls/xactengine3_7/xact_dll.c | 69 +++++++++++++++++++++++++++--------
1 file changed, 53 insertions(+), 16 deletions(-)
diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c
index 3ae76f55495..6a1e95c7277 100644
--- a/dlls/xactengine3_7/xact_dll.c
+++ b/dlls/xactengine3_7/xact_dll.c
@@ -115,6 +115,23 @@ static HRESULT wrapper_add_entry(XACT3EngineImpl *engine, void *fwb, void *xact)
return S_OK;
}
+/* Must be protected by engine->wb_wrapper_lookup_cs */
+static void* wrapper_find_entry(XACT3EngineImpl *engine, void *faudio)
+{
+ struct wrapper_lookup *lookup;
+ struct wine_rb_entry *entry;
+
+ entry = wine_rb_get(&engine->wb_wrapper_lookup, faudio);
+ if (entry)
+ {
+ lookup = WINE_RB_ENTRY_VALUE(entry, struct wrapper_lookup, entry);
+ return lookup->xact;
+ }
+
+ WARN("cannot find interface in wrapper lookup\n");
+ return NULL;
+}
+
typedef struct _XACT3CueImpl {
IXACT3Cue IXACT3Cue_iface;
FACTCue *fact_cue;
@@ -987,10 +1004,8 @@ static void FACTCALL fact_notification_cb(const FACTNotification *notification)
{
XACT3EngineImpl *engine = (XACT3EngineImpl *)notification->pvContext;
XACT_NOTIFICATION xnotification;
- struct wrapper_lookup *lookup;
- struct wine_rb_entry *entry;
- TRACE("notification %p\n", notification->pvContext);
+ TRACE("notification %d, context %p\n", notification->type, notification->pvContext);
/* Older versions of FAudio don't pass through the context */
if (!engine)
@@ -1003,28 +1018,50 @@ static void FACTCALL fact_notification_cb(const FACTNotification *notification)
xnotification.timeStamp = notification->timeStamp;
xnotification.pvContext = engine->contexts[notification->type - 1];
+ EnterCriticalSection(&engine->wb_wrapper_lookup_cs);
if (notification->type == XACTNOTIFICATIONTYPE_WAVEBANKPREPARED
|| notification->type == XACTNOTIFICATIONTYPE_WAVEBANKDESTROYED)
{
- EnterCriticalSection(&engine->wb_wrapper_lookup_cs);
- entry = wine_rb_get(&engine->wb_wrapper_lookup, notification->waveBank.pWaveBank);
- if (!entry)
- {
- WARN("cannot find wave bank in wrapper lookup\n");
- xnotification.waveBank.pWaveBank = NULL;
- }
- else
- {
- lookup = WINE_RB_ENTRY_VALUE(entry, struct wrapper_lookup, entry);
- xnotification.waveBank.pWaveBank = lookup->xact;
- }
- LeaveCriticalSection(&engine->wb_wrapper_lookup_cs);
+ xnotification.waveBank.pWaveBank = wrapper_find_entry(engine, notification->waveBank.pWaveBank);
+ }
+ else if(notification->type == XACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED)
+ {
+ xnotification.soundBank.pSoundBank = wrapper_find_entry(engine, notification->soundBank.pSoundBank);
+ }
+ else if (notification->type == XACTNOTIFICATIONTYPE_WAVESTOP
+#if XACT3_VER >= 0x0205
+ || notification->type == XACTNOTIFICATIONTYPE_WAVEDESTROYED
+ || notification->type == XACTNOTIFICATIONTYPE_WAVELOOPED
+ || notification->type == XACTNOTIFICATIONTYPE_WAVEPLAY
+ || notification->type == XACTNOTIFICATIONTYPE_WAVEPREPARED)
+#else
+ )
+#endif
+ {
+ xnotification.wave.cueIndex = notification->wave.cueIndex;
+ xnotification.wave.pCue = wrapper_find_entry(engine, notification->wave.pCue);
+ xnotification.wave.pSoundBank = wrapper_find_entry(engine, notification->wave.pSoundBank);
+#if XACT3_VER >= 0x0205
+ xnotification.wave.pWave = wrapper_find_entry(engine, notification->wave.pWave);
+#endif
+ xnotification.wave.pWaveBank = wrapper_find_entry(engine, notification->wave.pWaveBank);
+ }
+ else if (notification->type == XACTNOTIFICATIONTYPE_CUEPLAY ||
+ notification->type == XACTNOTIFICATIONTYPE_CUEPREPARED ||
+ notification->type == XACTNOTIFICATIONTYPE_CUESTOP ||
+ notification->type == XACTNOTIFICATIONTYPE_CUEDESTROYED)
+ {
+ xnotification.cue.pCue = wrapper_find_entry(engine, notification->cue.pCue);
+ xnotification.cue.cueIndex = notification->cue.cueIndex;
+ xnotification.cue.pSoundBank = wrapper_find_entry(engine, notification->cue.pSoundBank);
}
else
{
+ LeaveCriticalSection(&engine->wb_wrapper_lookup_cs);
FIXME("Unsupported callback type %d\n", notification->type);
return;
}
+ LeaveCriticalSection(&engine->wb_wrapper_lookup_cs);
engine->notification_callback(&xnotification);
}
--
2.35.1

View File

@ -0,0 +1,42 @@
From c2849dce7ff45f6c003198b43153c7e2c597c988 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 22 Jul 2022 12:34:27 +1000
Subject: [PATCH] xactengine3_7: Remove Entry after FAudio Destroyed call
FACTWaveBank_Destroy will invoke the callback which we
attempt to lookup the wavebank.
The callback must have a pointer, help states it isn't valid but still
points to the wavebank that was destroyed.
---
dlls/xactengine3_7/xact_dll.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c
index 19c02036907..a72afcc18e1 100644
--- a/dlls/xactengine3_7/xact_dll.c
+++ b/dlls/xactengine3_7/xact_dll.c
@@ -661,10 +661,11 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Destroy(IXACT3WaveBank *iface)
TRACE("(%p)\n", This);
+ hr = FACTWaveBank_Destroy(This->fact_wavebank);
+
EnterCriticalSection(&This->engine->wb_wrapper_lookup_cs);
entry = wine_rb_get(&This->engine->wb_wrapper_lookup, This->fact_wavebank);
-
if (!entry)
{
LeaveCriticalSection(&This->engine->wb_wrapper_lookup_cs);
@@ -681,7 +682,6 @@ static HRESULT WINAPI IXACT3WaveBankImpl_Destroy(IXACT3WaveBank *iface)
HeapFree(GetProcessHeap(), 0, lookup);
}
- hr = FACTWaveBank_Destroy(This->fact_wavebank);
HeapFree(GetProcessHeap(), 0, This);
return hr;
}
--
2.35.1

View File

@ -1,3 +1,2 @@
Fixes: [49678] - xactengine: Implement callback notifications.
Depends: xactengine3_7-Notification
Disabled: True