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