|
◆ BatchCancel()
virtual void AK::StreamMgr::IAkIOHookDeferredBatch::BatchCancel |
( |
AkUInt32 |
in_uNumTransfers, |
|
|
BatchIoTransferItem * |
in_pTransferItems, |
|
|
bool ** |
io_ppbCancelAllTransfersForThisFile |
|
) |
|
|
|
pure virtual |
Notifies that a transfer request is cancelled. It will be flushed by the streaming device when completed. Cancellation is normal and happens regularly; for example, whenever a sound stops before the end or stops looping. It happens even more frequently when buffering (AkDeviceSettings::fTargetAutoStmBufferLength and AkDeviceSettings::uGranularity) is large and when you low-level IO hook accepts many concurrent requests at the same time.
- 警告
- The calling thread holds the stream's lock. You may call the callback function directly from here (if you can guarantee that the I/O buffer will not be accessed in the meantime), but you must not wait here for another thread to call the callback function.
- Likewise, if you resolve transfers with your own thread and use a lock to protect your transfers queue, be careful not to run into a deadlock. Cancel() can be executed by any thread. Thus, if you need to lock your queue in Cancel(), you must never hold this lock when calling back transfers, either from within Cancel() or from your worker thread's routine. Lock your list, dequeue the transfer if you can, unlock, and call pCallback if and only if the transfer was found and dequeued. On the other hand, if you choose not to do anything in Cancel(), the lock only protects your list between Read()/Write() and your worker thread's routine, and since the device I/O thread does not hold the stream's lock while calling Read()/Write(), your worker thread may therefore hold it while calling back transfers.
- A race condition exists when cancelling all transfers (io_bCancelAllTransfersForThisFile is true) directly from within this hook. If you handle the io_bCancelAllTransfersForThisFile == true case, you need to defer calling the completion callback to later (from your usual I/O completion thread, for example). This will be fixed in a future version of Wwise.
- 参数
-
in_uNumTransfers |
Number of transfers to process |
in_pTransferItems |
List of transfer items to process |
io_ppbCancelAllTransfersForThisFile |
Flag for each transfer indicating whether all transfers should be cancelled for this file (see notes in function description). |
在 AK::StreamMgr::IAkIOHookDeferred 内被实现.
|