Click to Rate and Give Feedback
MSDN
MSDN Library
DirectX
SDK Documentation
DirectX Audio
Overviews
XACT
Callbacks
 How To: Use XACT Input/Output Callb...

  Switch on low bandwidth view
How To: Use XACT Input/Output Callbacks
Cc677045.XDK_CHM_BANNER_left(en-us,VS.85).jpgCc677045.XDK_CHM_BANNER_right(en-us,VS.85).jpg

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

  1. 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);
    }
  2. 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);
    }
  3. Populate an XACT_FILEIO_CALLBACKS structure with the I/O functions created.

  4. Set the readFileCallback member to the XACT_READFILE_CALLBACK function.

  5. Set the getOverlappedResultCallback member to the XACT_GETOVERLAPPEDRESULT_CALLBACK function.

    XACT_FILEIO_CALLBACKS fileIOCallbacks;
    fileIOCallbacks.getOverlappedResultCallback = getOverlappedResultCallback;
    fileIOCallbacks.readFileCallback = readFileCallback;
  6. Populate a XACT_RUNTIME_PARAMETERS structure setting the fileIOCallbacks member to the XACT_FILEIO_CALLBACKS structure.

    XACT_RUNTIME_PARAMETERS EngineParameters = {0};
    EngineParameters.fileIOCallbacks = fileIOCallbacks;
  7. Initialize the XACT engine as described in How To: Initialize XACT.

Related Topics

XACT Key Concepts
Provides an overview of key XACT concepts.
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker