diff -Naur xbmc.orig/xbmc/xbox/IoSupport.cpp xbmc/xbmc/xbox/IoSupport.cpp --- xbmc.orig/xbmc/xbox/IoSupport.cpp 2008-12-07 23:17:19.000000000 +0100 +++ xbmc/xbmc/xbox/IoSupport.cpp 2008-12-07 23:31:17.000000000 +0100 @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #endif @@ -445,37 +446,31 @@ if (hDevice->m_bCDROM) { int fd = hDevice->fd; - int lba = (dwSector + CD_MSF_OFFSET) ; - int m,s,f; - union - { - struct cdrom_msf msf; - char buffer[2356]; - } arg; - // convert sector offset to minute, second, frame format - // since that is what the 'ioctl' requires as input - f = lba % CD_FRAMES; - lba /= CD_FRAMES; - s = lba % CD_SECS; - lba /= CD_SECS; - m = lba; + // seek to requested sector + if (lseek(fd, dwSector * MODE1_DATA_SIZE, SEEK_SET) < 0) + { + CLog::Log(LOGERROR, "CD: ReadSector Request to read sector %d\n", (int)dwSector); + CLog::Log(LOGERROR, "CD: ReadSector error: %s\n", strerror(errno)); + OutputDebugString("CD Read error\n"); + return (-1); + } - arg.msf.cdmsf_min0 = m; - arg.msf.cdmsf_sec0 = s; - arg.msf.cdmsf_frame0 = f; - - int ret = ioctl(fd, CDROMREADMODE1, &arg); - if (ret==0) + // read data block of this sector + while (read(fd, lpczBuffer, MODE1_DATA_SIZE) < 0) { - memcpy(lpczBuffer, arg.buffer, 2048); - return 2048; + // read was interrupted - try again + if (errno == EINTR) + continue; + + // error reading sector + CLog::Log(LOGERROR, "CD: ReadSector Request to read sector %d\n", (int)dwSector); + CLog::Log(LOGERROR, "CD: ReadSector error: %s\n", strerror(errno)); + OutputDebugString("CD Read error\n"); + return (-1); } - CLog::Log(LOGERROR, "CD: ReadSector Request to read sector %d\n", (int)dwSector); - CLog::Log(LOGERROR, "CD: ReadSector error: %s\n", strerror(errno)); - CLog::Log(LOGERROR, "CD: ReadSector minute %d, second %d, frame %d\n", m, s, f); - OutputDebugString("CD Read error\n"); - return -1; + + return MODE1_DATA_SIZE; } #endif LARGE_INTEGER Displacement; diff -Naur xbmc.orig/xbmc/xbox/IoSupport.h xbmc/xbmc/xbox/IoSupport.h --- xbmc.orig/xbmc/xbox/IoSupport.h 2008-12-07 23:17:19.000000000 +0100 +++ xbmc/xbmc/xbox/IoSupport.h 2008-12-07 23:31:17.000000000 +0100 @@ -40,6 +40,8 @@ #define DRIVE_CLOSED_MEDIA_PRESENT 4 // Will be send once when the drive just have closed #define DRIVE_NONE 5 // system doesn't have an optical drive +#define MODE1_DATA_SIZE 2048 // Mode1 sector has 2048 bytes of data + #define MODE2_DATA_START 24 // Mode2 raw sector has 24 bytes before the data payload #define MODE2_DATA_SIZE 2324 // And has 2324 usable bytes #define RAW_SECTOR_SIZE 2352 // Raw sector size