How To: Use XACT Input/Output Callbacks
How To: Use XACT Input/Output Callbacks
How to use input/output (I/O) callbacks to override the default behavior for I/O
operations performed by XACT is described. The example implementation in this how to simply reproduces the default
behavior of XACT. By changing the example implementation of the callbacks, the steps provided can be used to allow
XACT to use a game's custom resource manager.
To use I/O callbacks
-
Create an XACT_GETOVERLAPPEDRESULT_CALLBACK function.
Note This function is called by XACT instead of the system GetOverlappedResult function.
-
BOOL getOverlappedResultCallback (
HANDLE hFile,
LPOVERLAPPED lpOverlapped,
LPDWORD lpNumberOfBytesTransferred,
BOOL bWait )
{
return GetOverlappedResult(hFile,lpOverlapped,lpNumberOfBytesTransferred,bWait);
}
-
Create an XACT_READFILE_CALLBACK function.
Note This function is called by XACT instead of the system ReadFile function.
-
BOOL readFileCallback (
HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped )
{
return ReadFile(hFile,lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,lpOverlapped);
}
-
Populate an XACT_FILEIO_CALLBACKS structure with the I/O functions created.
-
Set the readFileCallback member to the XACT_READFILE_CALLBACK function.
-
Set the getOverlappedResultCallback member to the
XACT_GETOVERLAPPEDRESULT_CALLBACK function.
-
XACT_FILEIO_CALLBACKS fileIOCallbacks;
fileIOCallbacks.getOverlappedResultCallback = getOverlappedResultCallback;
fileIOCallbacks.readFileCallback = readFileCallback;
-
Populate a XACT_RUNTIME_PARAMETERS structure setting the fileIOCallbacks
member to the XACT_FILEIO_CALLBACKS structure.
-
XACT_RUNTIME_PARAMETERS EngineParameters = {0};
-
EngineParameters.fileIOCallbacks = fileIOCallbacks;
-
Initialize the XACT engine as described in How To: Initialize XACT.
Related Topics
- XACT Key Concepts
- Provides an overview of key XACT concepts.