mirror of https://github.com/PCSX2/pcsx2.git
cdvdgigaherz:linux: Use pread instead of lseek + read
It'll make it unnecessary to use a lock when reading disc sectors.
This commit is contained in:
parent
5109687a31
commit
1d634f9b44
|
@ -63,6 +63,7 @@ class IOCtlSrc
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
HANDLE m_device = INVALID_HANDLE_VALUE;
|
HANDLE m_device = INVALID_HANDLE_VALUE;
|
||||||
std::wstring m_filename;
|
std::wstring m_filename;
|
||||||
|
mutable std::mutex m_lock;
|
||||||
#else
|
#else
|
||||||
int m_device = -1;
|
int m_device = -1;
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
|
@ -72,7 +73,6 @@ class IOCtlSrc
|
||||||
u32 m_sectors = 0;
|
u32 m_sectors = 0;
|
||||||
u32 m_layer_break = 0;
|
u32 m_layer_break = 0;
|
||||||
std::vector<toc_entry> m_toc;
|
std::vector<toc_entry> m_toc;
|
||||||
mutable std::mutex m_lock;
|
|
||||||
|
|
||||||
bool ReadDVDInfo();
|
bool ReadDVDInfo();
|
||||||
bool ReadCDInfo();
|
bool ReadCDInfo();
|
||||||
|
|
|
@ -86,16 +86,8 @@ const std::vector<toc_entry> &IOCtlSrc::ReadTOC() const
|
||||||
|
|
||||||
bool IOCtlSrc::ReadSectors2048(u32 sector, u32 count, u8 *buffer) const
|
bool IOCtlSrc::ReadSectors2048(u32 sector, u32 count, u8 *buffer) const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_lock);
|
|
||||||
|
|
||||||
if (lseek(m_device, sector * 2048ULL, SEEK_SET) == -1) {
|
|
||||||
fprintf(stderr, " * CDVD lseek sectors %u failed: %s\n",
|
|
||||||
sector, strerror(errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ssize_t bytes_to_read = 2048 * count;
|
const ssize_t bytes_to_read = 2048 * count;
|
||||||
ssize_t bytes_read = read(m_device, buffer, bytes_to_read);
|
ssize_t bytes_read = pread(m_device, buffer, bytes_to_read, sector * 2048ULL);
|
||||||
if (bytes_read == bytes_to_read)
|
if (bytes_read == bytes_to_read)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue