From 885782f9e28d085b0d1b14e80ae4f9d440537f2b Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 14 Jan 2020 08:30:00 +1100
Subject: [PATCH] xaudio2_7: Correct callback to windows function.

The unix library cannot directly call the windows callback
due to calling conventions.
---
 dlls/xaudio2_7/xact_dll.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/dlls/xaudio2_7/xact_dll.c b/dlls/xaudio2_7/xact_dll.c
index 92434a7084..dfe74cebc2 100644
--- a/dlls/xaudio2_7/xact_dll.c
+++ b/dlls/xaudio2_7/xact_dll.c
@@ -108,6 +108,7 @@ typedef struct _XACT3EngineImpl {
 
     XACT_READFILE_CALLBACK pReadFile;
     XACT_GETOVERLAPPEDRESULT_CALLBACK pGetOverlappedResult;
+    XACT_NOTIFICATION_CALLBACK notification_callback;
 } XACT3EngineImpl;
 
 typedef struct wrap_readfile_struct {
@@ -930,6 +931,25 @@ static HRESULT WINAPI IXACT3EngineImpl_GetFinalMixFormat(IXACT3Engine *iface,
             (FAudioWaveFormatExtensible*) pFinalMixFormat);
 }
 
+static void FACTCALL fact_notification_cb(const FACTNotification *pNotification)
+{
+    XACT3EngineImpl *engine = (XACT3EngineImpl *)pNotification->pvContext;
+
+    /* Older versions of FAudio don't pass through the context */
+    if (!engine)
+    {
+        WARN("Notification context is NULL\n");
+        return;
+    }
+
+    if (pNotification->type == XACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED)
+    {
+        FIXME("Callback XACTNOTIFICATIONTYPE_SOUNDBANKDESTROYED\n");
+    }
+    else
+        FIXME("Unsupported callback type %d\n", pNotification->type);
+}
+
 static HRESULT WINAPI IXACT3EngineImpl_Initialize(IXACT3Engine *iface,
         const XACT_RUNTIME_PARAMETERS *pParams)
 {
@@ -973,6 +993,9 @@ static HRESULT WINAPI IXACT3EngineImpl_Initialize(IXACT3Engine *iface,
                 GetOverlappedResult;
     params.fileIOCallbacks.readFileCallback = wrap_readfile;
     params.fileIOCallbacks.getOverlappedResultCallback = wrap_getoverlappedresult;
+    params.fnNotificationCallback = fact_notification_cb;
+
+    This->notification_callback = (XACT_NOTIFICATION_CALLBACK)pParams->fnNotificationCallback;
 
     ret = FACTAudioEngine_Initialize(This->fact_engine, &params);
     if (ret != 0)
@@ -1253,6 +1276,7 @@ static HRESULT WINAPI IXACT3EngineImpl_RegisterNotification(IXACT3Engine *iface,
     TRACE("(%p)->(%p)\n", This, pNotificationDesc);
 
     unwrap_notificationdesc(&fdesc, pNotificationDesc);
+    fdesc.pvContext = This;
     return FACTAudioEngine_RegisterNotification(This->fact_engine, &fdesc);
 }
 
@@ -1265,6 +1289,7 @@ static HRESULT WINAPI IXACT3EngineImpl_UnRegisterNotification(IXACT3Engine *ifac
     TRACE("(%p)->(%p)\n", This, pNotificationDesc);
 
     unwrap_notificationdesc(&fdesc, pNotificationDesc);
+    fdesc.pvContext = This;
     return FACTAudioEngine_UnRegisterNotification(This->fact_engine, &fdesc);
 }
 
-- 
2.25.1

