sp193
Developer
So how did you remedy this? Did you increase the buffer with the patch to the audio module to allow for the occasional overflow or was it some other method like limiting the transfer to 16 sectors?
I am not at all questioning your work I'm just curious and find it interesting but I don't know a lot about game debugging![]()
No problem!
How I identified that the game was sometimes reading 17 sectors, was initially by enabling the debug messages within OPL's CDVDMAN module. I usually do that because we replace the game's CDVDMAN & CDVDFSV modules. The game goes crazy after the first 2 reads of 17 sectors. But it didn't occur to me at that point, that reading 17 sectors was a problem.
I observed that the reading errors occur due to it trying to read from an erroneous LSN, so the aim became to understand how the error started.
I studied the SOUNDREL module (and the similar SOUNDEB module, which has debug information) to locate common problems with the use of libcdvd, like failure to use sceCdSync(), not retrying etc. The game would always use sceCdSync() and retry whenever there are read errors, so the module is okay here.
Other than being downright wrong, the bad LSNs also seemed to change between boots, so something was getting corrupted. I noticed that the buffers that were used with sceCdRead() had a capacity of 0x8000 bytes (for 16 sectors), but 17 sectors is 0x8800. The game uses the 2 buffers, so it can read into one and unpack data from the other, simultaneously. Coupled with the facts that the 2 buffers are allocated back-to-back and the data read in will determine the LSN to read next, it would explain why reading 17 sectors into the first buffer could cause strange behaviour - since nearly every device we use will be faster than the processing capabilities of the IOP.
As for the fix, I made a module that will free the 2 buffers that SOUNDREL allocates, before allocating new buffers on its behalf: https://github.com/ifcaro/Open-PS2-...1e2c#diff-153cf38609a8983ab5a0003eaddcb360R60
The other code is for patching the place in the ELF where the game loads SOUNDREL.IRX, so that we can load the patch IRX after SOUNDREL.IRX.