Summary

A state manager used to manage adpcm playback initiated through cdlib_queue_adpcm_play. It’s main purpose is to track the progress of a stream and requeue a play if the loop bit is set.

Behavior

Call CdSync to check the interrupt status of the CD, then take the following actions based on the result.

If the interrupt status was CdlComplete check the value of cdlib_countdown_to_check. If its not equal to zero decrement it by 1 then return we dont need to check the status of the stream yet. If its equal to zero the function checks the status of the stream on every call.

The status is checked in two ways depending if the cdlib_manager call counter is a multiple of 10 or not. If the call counter is a multiple of 10 execute a Nop command and read the value of the return buffer. If the value doesn’t have bit 0 or 2 set return. If it does print a debug string with the value then return.

When the call counter is not a multiple of 10 execute a Getlocp instead. Check if the command was accepted if it wasnt no big deal print a debug string and return. If it was get the position of the seek head by reading the last three bytes of the return value buffer, then get the extentSectors and fileLBA members of the current file. Convert the position of the seek head into LBA location to substract the fileLBA value from this value. Then compare it with the value of the extentSectors. If extentSectors is bigger return as the CD is not done playing the file. If extentSectors is smaller the full file has been played so the function checks the bitFlags member of the file for the loop bit. If the loop bit is set, queue another play of the file. If its not there is nothing left to do and the function returns. In both cases the IO state is set to Ready before returning.

If the interrupt status is greater than or equal to CdlAcknowledge then check if it’s equal to CdlDiskError and return if it’s not. If it was call a Nop command to get the latest CD ROM status followed by printing a debug string with the latest status value. Then check if the IO status is streaming, error or ready returning if its not. Set the IO state to error and check the bitFlags member of the current file for the loop bit. If its not set return otherwise queue the file for adpcm playback again and return.

Check if the interrupt status was CdlNoIntr returning if it wasnt. If it was print a debug string then return.

Notes

  • The control flow of this function is nothing short of messy, just like cdlib_manager my notes and behavior is based off the assembly ignoring the decomp as its full of artifacts.
  • cdlib_manager only calls the xa manager every 5th cdlib_manager call which means if everything is going to plan the Nop and GetLocP commands alternate.
  • The ivar1 = countdown to check in every branch followed by countdown to check = ivar1 at the end of the function is a decompilation artifact, the only time we store a value in countdown to check is when decrementing it.

Function Signature

Parameters: None

Returns

Always 0

References

Calls

Sony Functions:
Custom Functions:

Called By

Memory Referenced