Commit Graph

127 Commits

Author SHA1 Message Date
Jonathan Li cf131b51a2 cdvdgigaherz: Avoid LL after date in library name string 2017-04-11 00:31:14 +01:00
Gregory Hainaut da1bb43618 cmake: Add various missing file in CMakeLists.txt
Add some windows code path. It would reduce the burden to port Cmake to windows.
(sill miss 3rdparty/some plugins/...)
2017-02-16 20:11:57 +01:00
np511 de6216b37b Remove warnings about ISO C++11 conformance 2017-01-29 09:06:10 -05:00
Jonathan Li 5a63a62454 cdvdgigaherz: Fix read past the end of the buffer 2016-12-19 23:56:48 +00:00
Jonathan Li f2edc50675 cdvdgigaherz: Improve prefetch logic
Avoid reading past the end of the disk.
Avoid waiting when there are prefetches remaining.
Fix the maths so that the first prefetch after a request attempts to
read the next block of sectors and not the block of sectors that was
just read (which will just be skipped anyway because the data has just
been cached).
Avoid potential prefetch after disk is swapped (though disc swap doesn't
work properly if you just eject and insert a different disk).
Stop prefetching on disk read failure (Suikoden hits this case - 2048
byte reads are requested, but only 2352 byte reads will succeed).

Also reduce the read retry count to 2.
2016-12-19 23:56:48 +00:00
Jonathan Li c1160f40d0 cdvdgigaherz: Rename variables/parameters in cdvdDirectReadSector
s/sector/sector_block
s/first/sector
2016-12-19 23:56:48 +00:00
Jonathan Li 3f89f4bd32 cdvdgigaherz: Use constant for sectors per read 2016-12-19 23:56:48 +00:00
Jonathan Li 592d4b024a cdvdgigaherz:linux: Swap Ok and Cancel button order
This now matches the usual GTK GUI button order.

Also bump the version number.
2016-12-07 01:40:44 +00:00
Jonathan Li 1d634f9b44 cdvdgigaherz:linux: Use pread instead of lseek + read
It'll make it unnecessary to use a lock when reading disc sectors.
2016-12-07 00:54:11 +00:00
Jonathan Li 483b3d6368 cdvdgigaherz: Avoid holding lock during thread sleep
Fixes Coverity CID 127721: Program hangs

Change the sleep to a condition variable wait, which has the added
benefit of allowing the plugin to close ever so slightly faster if
there's no disc in the drive.
2016-11-22 21:26:41 +01:00
Jonathan Li 29c2ccb310 cdvdgigaherz: Use a queue to manage sector requests
Fixes a data race.

Also avoid copying from the cache when it's unnecessary to do so.
2016-11-22 21:26:41 +01:00
Jonathan Li 3919a32dc3 cdvdgigaherz: Avoid race condition by reading from cache/disk
Instead of reading from a buffer shared by multiple threads, just read
the correct data from the cache or disk instead.
2016-11-22 21:26:41 +01:00
Jonathan Li 31b0b53394 cdvdgigaherz: Read correct sector type in keepalive thread
It'll prevent errors messages when raw sector reading is used.
2016-11-22 21:26:41 +01:00
Jonathan Li a34942c882 cdvdgigaherz: Only update cache if the read succeeds 2016-11-22 21:26:41 +01:00
Jonathan Li bb25ce1c6a cdvdgigaherz: Add cache entry check function
Useful when you don't actually want the cached data.
2016-11-22 21:26:41 +01:00
Jonathan Li 23f48e07ed cdvdgigaherz: Change signs
Avoid some unnecessary casting.
2016-11-22 21:26:41 +01:00
Jonathan Li 008fea5d89 common|cdvdgigaherz: Fix API sign mismatch
The typedef and function declaration don't quite match.
2016-11-22 21:26:41 +01:00
Jonathan Li f513ca2a28 cdvdgigaherz:linux: Check ioctl return value
Fixes Coverity CID 172718: Unchecked return value

Also avoid adding the sector leadout descriptor info to the TOC since it
actually isn't used.
2016-11-12 23:28:17 +00:00
Jonathan Li a283e95fed cmake: Add cdvdgigaherz and dependencies
Only new dependency is libudev.
2016-11-07 00:08:23 +00:00
Jonathan Li 16b6cc41a4 cdvdgigaherz:linux: Add config and GUI code 2016-11-07 00:08:23 +00:00
Jonathan Li 747f4dc3fe cdvdgigaherz:linux: Add initial IOCtlSrc implementation 2016-11-07 00:08:23 +00:00
Jonathan Li f13f50779c cdvdgigaherz: Export plugin interface when using gcc/clang 2016-11-07 00:08:23 +00:00
Jonathan Li 363b581926 cdvdgigaherz: ifdef Windows specific stuff 2016-11-07 00:08:23 +00:00
Jonathan Li 1573f513ce cdvdgigaherz: Move lba_to_msf to header
Also use proper inline keyword.
2016-11-07 00:08:23 +00:00
Jonathan Li ae0577bc16 cdvdgigaherz: Fix write-strings warnings
Too bad I can't change PS2Edef.h to use a const char*.

Also remove SVN_MOD ifdef from version string.
2016-11-07 00:08:23 +00:00
Jonathan Li cccf216dbb cdvdgigaherz: Use C++11 threads instead of Win32 threads 2016-11-07 00:08:23 +00:00
Jonathan Li d872c0560a cdvdgigaherz: Use unique_ptr for src 2016-11-07 00:08:23 +00:00
Jonathan Li f8f79788e4 cdvdgigaherz: Use condition variables for event waiting
Also use atomics for thread exit variables.
2016-11-07 00:08:23 +00:00
Jonathan Li f678ff8cfd cdvdgigaherz: Replace critical section with mutex 2016-11-07 00:08:23 +00:00
Jonathan Li b1850f2465 cdvdgigaherz: Move dllmain to a Windows only file 2016-11-07 00:08:23 +00:00
Jonathan Li d7866831ae cdvdgigaherz: Use Unicode on Windows 2016-11-07 00:08:23 +00:00
Jonathan Li 5917bf31c3 cdvdgigaherz: Remove old config code 2016-11-07 00:08:23 +00:00
Jonathan Li 59247c7838 cdvdgigaherz: Switch to using the new settings system
Also refactor the default drive selection and GUI code so optical drive
detection is shared.

Note: This breaks the current config, but there's only one setting
anyway.
2016-11-07 00:08:23 +00:00
Jonathan Li dce3c57e6a cdvdgigaherz: Add portable setting class
Can load/save inis (though functionality is very basic).
2016-11-07 00:08:23 +00:00
Jonathan Li 9c440ab6b7 cdvdgigaherz: Use bool return for ReadSectors*
More readable.
2016-11-07 00:08:23 +00:00
Jonathan Li fc085c1758 cdvdgigaherz: Improve IOCtlSrc::ReadSectors2048
Don't use a RAW_READ_INFO struct when only the LARGE_INTEGER member is
used. Use SetFilePointerEx which is slightly simpler and doesn't require
checking GetLastError() in some circumstances to check whether the read
has actually failed.

Also use a mutex to prevent simultaneous access from both the read
thread and the keepalive thread to prevent overlapping SetFilePointerEx
calls from causing the wrong data to be read.

And print error messages should a failure occur.
2016-11-07 00:08:23 +00:00
Jonathan Li fdd6ea3651 cdvdgigaherz: Simplify SetSpindleSpeed
Also set the max drive speed to 4x DVD and 24xCD (down from 8x DVD and
36x CD) - it seems to reduce pausing slightly since the drive doesn't
require as much time to spin up to the desired speed.
2016-11-07 00:08:23 +00:00
Jonathan Li 1834b7d0f9 cdvdgigaherz: Get disc info when disc is first ready
Also set the disc speed at the correct time - CDROM SET SPEED only stays
in effect till the disc is removed.

Also fix a memleak in CDVDopen when the drive cannot be accessed.
2016-11-07 00:08:23 +00:00
Jonathan Li 95b98c5a38 cdvdgigaherz: Use a formatted TOC instead of a raw TOC
It's simpler and provides almost the same information. The only
information that might be lost is the first track specific track type.
2016-11-07 00:08:23 +00:00
Jonathan Li 327515366f cdvdgigaherz: Don't calculate the track length
Not really necessary.

Also fix 2 off-by-ones.
2016-11-07 00:08:23 +00:00
Jonathan Li 1f60e3101e cdvdgigaherz: Reduce disc info ioctl calls
It's rather unnecessary to use the same ioctls multiple times per disc
when the info returned doesn't change. Just use each ioctl once and
read/calculate all the necessary info all at onace.

This also fixes an issue where the IOCTL_DVD_START_SESSION ioctl is
repeatedly used if the returned session ID is 0. The previous code
assumed that 0 was not a valid session ID and would repeatedly use the
ioctl to obtain a non-zero session ID. However, 0 is a valid session ID,
and it seems IOCTL_DVD_START_SESSION can repeatedly return a 0 session
ID even if the corresponding IOCTL_DVD_END_SESSION has not been called.
In our case, a DVD session is only necessary for DVD detection and
reading the physical format information. This fix seems to alter drive
speed behaviour.
2016-11-07 00:08:23 +00:00
Jonathan Li f8e474a1c5 cdvdgigaherz: s/device/m_device/ 2016-11-07 00:08:23 +00:00
Jonathan Li 8f11049c9f cdvdgigaherz: Remove non-SPTI raw sector reading code
There doesn't seem to be any issues calling CreateFile with
GENERIC_WRITE access (which is necessary for SPTI) on a standard user
account, so the SPTI code should work in all cases.
2016-11-07 00:08:23 +00:00
Jonathan Li f314c2a4d9 cdvdgigaherz: Simplify Q subchannel relative offset calculation
That way there's no need to calculate the track length for each track.
2016-11-07 00:08:23 +00:00
Jonathan Li 86a6f5d67c cdvdgigaherz: s/itob/dec_to_bcd/
There's no need to have 2 ways to convert a u8 to a binary coded
decimal. Remove the macro version.
2016-10-26 22:11:40 +01:00
Jonathan Li 852ed21e88 cdvdgigaherz: Remove no drive support
It's the same as "No disc" or having no disc in the drive.
2016-10-26 17:30:28 +01:00
Jonathan Li c023d7676a cdvdgigaherz: Remove Source base class
Also remove virtuals from IOCtlSrc.
2016-10-26 17:30:27 +01:00
Jonathan Li 9f6c6d9917 cdvdgigaherz: Don't use GetFileSizeEx to get disk size
It doesn't seem to work for disks, and IOCTL_DISK_GET_LENGTH_INFO
usually succeeds instead.
2016-10-26 17:30:23 +01:00
Jonathan Li 9c643ae9ca cdvdgigaherz: Remove CDVDabout and SysMessage
It's not accessible from PCSX2. More importantly, I don't want to port
it.
2016-10-26 17:30:21 +01:00
Jonathan Li fb3580efa1 cdvdgigaherz: Remove unneeded code 2016-10-26 17:30:16 +01:00