diff --git a/pcsx2/CDVD/CDVDdiscReader.cpp b/pcsx2/CDVD/CDVDdiscReader.cpp index 75a4448c8cfb7..6956bbbf9526c 100644 --- a/pcsx2/CDVD/CDVDdiscReader.cpp +++ b/pcsx2/CDVD/CDVDdiscReader.cpp @@ -105,7 +105,7 @@ void cdvdParseTOC() tracks[track].type = CDVD_AUDIO_TRACK; } #ifdef PCSX2_DEBUG - DevCon.Write("cdvdParseTOC: Track %u: LBA %u, Type %u\n", track, tracks[track].start_lba, tracks[track].type); + DevCon.Write("cdvdParseTOC: Track %u: LBA %u, Type %u\n", track, tracks[track].start_lba, tracks[track].type); #endif } } @@ -133,7 +133,7 @@ static void keepAliveThread() std::unique_lock guard(s_keepalive_lock); while (!s_keepalive_cv.wait_for(guard, std::chrono::seconds(30), - []() { return !s_keepalive_is_open; })) + []() { return !s_keepalive_is_open; })) { //printf(" * keepAliveThread: polling drive.\n"); @@ -273,20 +273,28 @@ static s32 DISCreadSubQ(u32 lsn, cdvdSubQ* subq) memset(subq, 0, sizeof(cdvdSubQ)); - if (!src->ReadTrackSubQ(subq)) - { - lsn_to_msf(&subq->discM, &subq->discS, &subq->discF, lsn + 150); + lsn_to_msf(&subq->discM, &subq->discS, &subq->discF, lsn + 150); + + u8 i = strack; + while (i < etrack && lsn >= tracks[i + 1].start_lba) + ++i; - u8 i = strack; - while (i < etrack && lsn >= tracks[i + 1].start_lba) - ++i; + lsn -= tracks[i].start_lba; - lsn -= tracks[i].start_lba; + lsn_to_msf(&subq->trackM, &subq->trackS, &subq->trackF, lsn); - lsn_to_msf(&subq->trackM, &subq->trackS, &subq->trackF, lsn); + subq->ctrl = tracks[i].type; + // It's important to note that we do _not_ use the current MSF values + // from the host's device. We use the MSF values from the lsn. + // An easy way to test an implementation is to see if the OSDSYS + // CD player can display the correct minute and second values. + // From my testing, the IOCTL returns 0 for ctrl. This also breaks + // the OSDSYS player. The only "safe" values to receive from the IOCTL + // are ADR, trackNum and trackIndex. + if (!src->ReadTrackSubQ(subq)) + { subq->adr = 1; - subq->ctrl = tracks[i].type; subq->trackNum = i; subq->trackIndex = 1; } diff --git a/pcsx2/CDVD/Linux/IOCtlSrc.cpp b/pcsx2/CDVD/Linux/IOCtlSrc.cpp index cb79222446c2c..c180d7585a76d 100644 --- a/pcsx2/CDVD/Linux/IOCtlSrc.cpp +++ b/pcsx2/CDVD/Linux/IOCtlSrc.cpp @@ -208,18 +208,8 @@ bool IOCtlSrc::ReadTrackSubQ(cdvdSubQ* subQ) const } subQ->adr = osSubQ.cdsc_adr; - subQ->ctrl = osSubQ.cdsc_ctrl; subQ->trackNum = osSubQ.cdsc_trk; subQ->trackIndex = osSubQ.cdsc_ind; - - subQ->discM = osSubQ.cdsc_absaddr.msf.minute; - subQ->discS = osSubQ.cdsc_absaddr.msf.second; - subQ->discF = osSubQ.cdsc_absaddr.msf.frame; - - subQ->trackM = osSubQ.cdsc_reladdr.msf.minute; - subQ->trackS = osSubQ.cdsc_reladdr.msf.second; - subQ->trackF = osSubQ.cdsc_reladdr.msf.frame; - return true; } diff --git a/pcsx2/CDVD/Windows/IOCtlSrc.cpp b/pcsx2/CDVD/Windows/IOCtlSrc.cpp index f6e004be5f68c..005f6e846a528 100644 --- a/pcsx2/CDVD/Windows/IOCtlSrc.cpp +++ b/pcsx2/CDVD/Windows/IOCtlSrc.cpp @@ -320,17 +320,8 @@ bool IOCtlSrc::ReadTrackSubQ(cdvdSubQ* subQ) const else { subQ->adr = osSubQ.CurrentPosition.ADR; - subQ->ctrl = osSubQ.CurrentPosition.Control; subQ->trackNum = osSubQ.CurrentPosition.TrackNumber; subQ->trackIndex = osSubQ.CurrentPosition.IndexNumber; - - subQ->trackM = osSubQ.CurrentPosition.TrackRelativeAddress[0]; - subQ->trackS = osSubQ.CurrentPosition.TrackRelativeAddress[1]; - subQ->trackF = osSubQ.CurrentPosition.TrackRelativeAddress[2]; - - subQ->discM = osSubQ.CurrentPosition.AbsoluteAddress[0]; - subQ->discS = osSubQ.CurrentPosition.AbsoluteAddress[1]; - subQ->discF = osSubQ.CurrentPosition.AbsoluteAddress[2]; } return true;