mirror of https://github.com/PCSX2/pcsx2.git
cdvdgigaherz: Use bool return for ReadSectors*
More readable.
This commit is contained in:
parent
fc085c1758
commit
9c440ab6b7
|
@ -74,8 +74,8 @@ public:
|
|||
|
||||
u32 GetSectorCount() const;
|
||||
const std::vector<toc_entry> &ReadTOC() const;
|
||||
s32 ReadSectors2048(u32 sector, u32 count, char *buffer);
|
||||
s32 ReadSectors2352(u32 sector, u32 count, char *buffer);
|
||||
bool ReadSectors2048(u32 sector, u32 count, char *buffer) const;
|
||||
bool ReadSectors2352(u32 sector, u32 count, char *buffer) const;
|
||||
u32 GetLayerBreakAddress() const;
|
||||
s32 GetMediaType() const;
|
||||
void SetSpindleSpeed(bool restore_defaults) const;
|
||||
|
|
|
@ -162,28 +162,21 @@ DWORD CALLBACK cdvdThread(PVOID param)
|
|||
}
|
||||
|
||||
if (threadRequestPending || prefetch_left) {
|
||||
s32 ret = -1;
|
||||
s32 tries = 5;
|
||||
|
||||
s32 count = 16;
|
||||
|
||||
s32 left = src->GetSectorCount() - info.lsn;
|
||||
|
||||
if (left < count)
|
||||
count = left;
|
||||
|
||||
do {
|
||||
if (info.mode == CDVD_MODE_2048)
|
||||
ret = src->ReadSectors2048(info.lsn, count, info.data);
|
||||
else
|
||||
ret = src->ReadSectors2352(info.lsn, count, info.data);
|
||||
|
||||
if (ret == 0)
|
||||
break;
|
||||
|
||||
tries--;
|
||||
|
||||
} while ((ret < 0) && (tries > 0));
|
||||
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);
|
||||
|
||||
|
@ -309,28 +302,21 @@ s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer)
|
|||
|
||||
EnterCriticalSection(&CacheMutex);
|
||||
if (!cdvdCacheFetch(sector, mode, data)) {
|
||||
s32 ret = -1;
|
||||
s32 tries = 5;
|
||||
|
||||
s32 count = 16;
|
||||
|
||||
s32 left = src->GetSectorCount() - sector;
|
||||
|
||||
if (left < count)
|
||||
count = left;
|
||||
|
||||
do {
|
||||
if (mode == CDVD_MODE_2048)
|
||||
ret = src->ReadSectors2048(sector, count, data);
|
||||
else
|
||||
ret = src->ReadSectors2352(sector, count, data);
|
||||
|
||||
if (ret == 0)
|
||||
break;
|
||||
|
||||
tries--;
|
||||
|
||||
} while ((ret < 0) && (tries > 0));
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ const std::vector<toc_entry> &IOCtlSrc::ReadTOC() const
|
|||
return m_toc;
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::ReadSectors2048(u32 sector, u32 count, char *buffer)
|
||||
bool IOCtlSrc::ReadSectors2048(u32 sector, u32 count, char *buffer) const
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_lock);
|
||||
LARGE_INTEGER offset;
|
||||
|
@ -120,14 +120,14 @@ s32 IOCtlSrc::ReadSectors2048(u32 sector, u32 count, char *buffer)
|
|||
if (!SetFilePointerEx(m_device, offset, nullptr, FILE_BEGIN)) {
|
||||
fprintf(stderr, " * CDVD SetFilePointerEx failed: sector %u: error %u\n",
|
||||
sector, GetLastError());
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
const DWORD bytes_to_read = 2048 * count;
|
||||
DWORD bytes_read;
|
||||
if (ReadFile(m_device, buffer, bytes_to_read, &bytes_read, nullptr)) {
|
||||
if (bytes_read == bytes_to_read)
|
||||
return 0;
|
||||
return true;
|
||||
fprintf(stderr, " * CDVD ReadFile: sectors %u-%u: %u bytes read, %u bytes expected\n",
|
||||
sector, sector + count - 1, bytes_read, bytes_to_read);
|
||||
} else {
|
||||
|
@ -135,10 +135,10 @@ s32 IOCtlSrc::ReadSectors2048(u32 sector, u32 count, char *buffer)
|
|||
sector, sector + count - 1, GetLastError());
|
||||
}
|
||||
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 IOCtlSrc::ReadSectors2352(u32 sector, u32 count, char *buffer)
|
||||
bool IOCtlSrc::ReadSectors2352(u32 sector, u32 count, char *buffer) const
|
||||
{
|
||||
struct sptdinfo
|
||||
{
|
||||
|
@ -188,10 +188,10 @@ s32 IOCtlSrc::ReadSectors2352(u32 sector, u32 count, char *buffer)
|
|||
for (const auto &c : sptd.sense_buffer)
|
||||
printf(" %02X", c);
|
||||
putchar('\n');
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IOCtlSrc::ReadDVDInfo()
|
||||
|
|
Loading…
Reference in New Issue