Add some comments for sceAtrac

This commit is contained in:
oioitff 2013-05-12 21:14:41 +08:00
parent 7b8fb33ebc
commit 066a2e2182

View file

@ -427,6 +427,12 @@ u32 sceAtracGetAtracID(int codecType)
return atracID;
}
// PSP allow games to add stream data to a temp buf, the buf size is given by "atracBufSize "here.
// "first.offset" means how many bytes the temp buf has been written,
// and "first.writableBytes" means how many bytes the temp buf is allowed to write
// (We always have "first.offset + first.writableBytes = atracBufSize").
// We only reset the temp buf when games call sceAtracGetStreamDataInfo,
// because that function would tell games how to add the left stream data.
u32 sceAtracAddStreamData(int atracID, u32 bytesToAdd)
{
INFO_LOG(HLE, "sceAtracAddStreamData(%i, %08x)", atracID, bytesToAdd);
@ -738,6 +744,9 @@ u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoopStartSa
return 0;
}
// Games call this function to get some info for add more stream data,
// such as where the data read from, where the data add to,
// and how many bytes are allowed to add.
u32 sceAtracGetStreamDataInfo(int atracID, u32 writeAddr, u32 writableBytesAddr, u32 readOffsetAddr)
{
DEBUG_LOG(HLE, "sceAtracGetStreamDataInfo(%i, %08x, %08x, %08x)", atracID, writeAddr, writableBytesAddr, readOffsetAddr);
@ -745,8 +754,10 @@ u32 sceAtracGetStreamDataInfo(int atracID, u32 writeAddr, u32 writableBytesAddr,
if (!atrac) {
//return -1;
} else {
// reset the temp buf for adding more stream data
atrac->first.writableBytes = std::min(atrac->first.filesize - atrac->first.size, atrac->atracBufSize);
atrac->first.offset = 0;
if (Memory::IsValidAddress(writeAddr))
Memory::Write_U32(atrac->first.addr, writeAddr);
if (Memory::IsValidAddress(writableBytesAddr))
@ -887,10 +898,12 @@ int __AtracSetContext(Atrac *atrac, u32 buffer, u32 bufferSize)
int _AtracSetData(Atrac *atrac, u32 buffer, u32 bufferSize)
{
atrac->atracBufSize = bufferSize;
if (atrac->first.size > atrac->first.filesize)
atrac->first.size = atrac->first.filesize;
atrac->first.fileoffset = atrac->first.size;
// got the size of temp buf, and calculate writableBytes and offset
atrac->atracBufSize = bufferSize;
atrac->first.writableBytes = (u32)std::max((int)bufferSize - (int)atrac->first.size, 0);
atrac->first.offset = atrac->first.size;