mirror of https://github.com/PCSX2/pcsx2.git
cdvdgigaherz: Only update cache if the read succeeds
This commit is contained in:
parent
bb25ce1c6a
commit
a34942c882
|
@ -108,6 +108,23 @@ void cdvdCacheReset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cdvdReadBlockOfSectors(u32 sector, s32 mode, u8 *data)
|
||||||
|
{
|
||||||
|
u32 count = std::min(16U, src->GetSectorCount() - sector);
|
||||||
|
|
||||||
|
// TODO: Is it really necessary to retry 3 times if it fails?
|
||||||
|
for (int tries = 0; tries < 4; ++tries) {
|
||||||
|
if (mode == CDVD_MODE_2048) {
|
||||||
|
if (src->ReadSectors2048(sector, count, data))
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (src->ReadSectors2352(sector, count, data))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void cdvdCallNewDiscCB()
|
void cdvdCallNewDiscCB()
|
||||||
{
|
{
|
||||||
weAreInNewDiskCB = true;
|
weAreInNewDiskCB = true;
|
||||||
|
@ -170,18 +187,7 @@ void cdvdThread()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threadRequestPending || prefetch_left) {
|
if (threadRequestPending || prefetch_left) {
|
||||||
u32 count = std::min(16U, src->GetSectorCount() - info.lsn);
|
if (cdvdReadBlockOfSectors(info.lsn, info.mode, info.data))
|
||||||
|
|
||||||
for (int tries = 0; tries < 4; ++tries) {
|
|
||||||
if (info.mode == CDVD_MODE_2048) {
|
|
||||||
if (src->ReadSectors2048(info.lsn, count, info.data))
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (src->ReadSectors2352(info.lsn, count, info.data))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cdvdCacheUpdate(info.lsn, info.mode, info.data);
|
cdvdCacheUpdate(info.lsn, info.mode, info.data);
|
||||||
|
|
||||||
if (handlingRequest) {
|
if (handlingRequest) {
|
||||||
|
@ -286,18 +292,7 @@ s32 cdvdDirectReadSector(u32 first, s32 mode, u8 *buffer)
|
||||||
u32 sector = first & (~15); //align to 16-sector block
|
u32 sector = first & (~15); //align to 16-sector block
|
||||||
|
|
||||||
if (!cdvdCacheFetch(sector, mode, data)) {
|
if (!cdvdCacheFetch(sector, mode, data)) {
|
||||||
u32 count = std::min(16U, src->GetSectorCount() - sector);
|
if (cdvdReadBlockOfSectors(sector, mode, data))
|
||||||
|
|
||||||
for (int tries = 0; tries < 4; ++tries) {
|
|
||||||
if (mode == CDVD_MODE_2048) {
|
|
||||||
if (src->ReadSectors2048(sector, count, data))
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if (src->ReadSectors2352(sector, count, data))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cdvdCacheUpdate(sector, mode, data);
|
cdvdCacheUpdate(sector, mode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue