From: Giovanni Mascellani gmascellani@codeweavers.com
The notifications are not sent immediately, but pushed to a queue and sent at the next DoWork() call. This seems to correspond to what happens on Windows.
Corresponding to upstream commit 9e53dbeebfdd8d0f23144b8b1aa895bca2727977.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/faudio/src/FACT.c | 26 ++++++++++++++++++++++++++ libs/faudio/src/FACT_internal.h | 1 + 2 files changed, 27 insertions(+)
diff --git a/libs/faudio/src/FACT.c b/libs/faudio/src/FACT.c index c3596ec2d48..bd8f89d3d8d 100644 --- a/libs/faudio/src/FACT.c +++ b/libs/faudio/src/FACT.c @@ -433,9 +433,17 @@ uint32_t FACTAudioEngine_DoWork(FACTAudioEngine *pEngine) uint8_t i; FACTCue *cue; LinkedList *list; + FACTNotification *note;
FAudio_PlatformLockMutex(pEngine->apiLock);
+ while (pEngine->wb_notifications_list) + { + note = (FACTNotification*) pEngine->wb_notifications_list->entry; + pEngine->notificationCallback(note); + LinkedList_RemoveEntry(&pEngine->wb_notifications_list, note, pEngine->apiLock, pEngine->pFree); + } + list = pEngine->sbList; while (list != NULL) { @@ -495,6 +503,7 @@ uint32_t FACTAudioEngine_CreateInMemoryWaveBank( uint32_t dwAllocAttributes, FACTWaveBank **ppWaveBank ) { + FACTNotification *note; uint32_t retval; FAudio_PlatformLockMutex(pEngine->apiLock); retval = FACT_INTERNAL_ParseWaveBank( @@ -507,6 +516,14 @@ uint32_t FACTAudioEngine_CreateInMemoryWaveBank( 0, ppWaveBank ); + if (pEngine->notifications & NOTIFY_WAVEBANKPREPARED) + { + note = (FACTNotification*) pEngine->pMalloc(sizeof(FACTNotification)); + note->type = FACTNOTIFICATIONTYPE_WAVEBANKPREPARED; + note->waveBank.pWaveBank = *ppWaveBank; + note->pvContext = pEngine->wb_context; + LinkedList_AddEntry(&pEngine->wb_notifications_list, note, pEngine->apiLock, pEngine->pMalloc); + } FAudio_PlatformUnlockMutex(pEngine->apiLock); return retval; } @@ -516,6 +533,7 @@ uint32_t FACTAudioEngine_CreateStreamingWaveBank( const FACTStreamingParameters *pParms, FACTWaveBank **ppWaveBank ) { + FACTNotification *note; uint32_t retval, packetSize; FAudio_PlatformLockMutex(pEngine->apiLock); if ( pEngine->pReadFile == FACT_INTERNAL_DefaultReadFile && @@ -538,6 +556,14 @@ uint32_t FACTAudioEngine_CreateStreamingWaveBank( 1, ppWaveBank ); + if (pEngine->notifications & NOTIFY_WAVEBANKPREPARED) + { + note = (FACTNotification*) pEngine->pMalloc(sizeof(FACTNotification)); + note->type = FACTNOTIFICATIONTYPE_WAVEBANKPREPARED; + note->waveBank.pWaveBank = *ppWaveBank; + note->pvContext = pEngine->wb_context; + LinkedList_AddEntry(&pEngine->wb_notifications_list, note, pEngine->apiLock, pEngine->pMalloc); + } FAudio_PlatformUnlockMutex(pEngine->apiLock); return retval; } diff --git a/libs/faudio/src/FACT_internal.h b/libs/faudio/src/FACT_internal.h index 8d46953be7b..97d09e56c66 100644 --- a/libs/faudio/src/FACT_internal.h +++ b/libs/faudio/src/FACT_internal.h @@ -440,6 +440,7 @@ struct FACTAudioEngine void *sb_context; void *wb_context; void *wave_context; + LinkedList *wb_notifications_list;
/* Settings handle */ void *settings;