Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 260844
Collapse All | Expand All

(-)xbmc.orig/xbmc/xbox/IoSupport.cpp (-27 / +22 lines)
Lines 40-45 Link Here
40
#include <linux/limits.h>
40
#include <linux/limits.h>
41
#include <sys/types.h>
41
#include <sys/types.h>
42
#include <sys/ioctl.h>
42
#include <sys/ioctl.h>
43
#include <unistd.h>
43
#include <fcntl.h>
44
#include <fcntl.h>
44
#include <linux/cdrom.h>
45
#include <linux/cdrom.h>
45
#endif
46
#endif
Lines 445-481 Link Here
445
  if (hDevice->m_bCDROM)
446
  if (hDevice->m_bCDROM)
446
  {    
447
  {    
447
    int fd = hDevice->fd;
448
    int fd = hDevice->fd;
448
    int lba = (dwSector + CD_MSF_OFFSET) ;
449
    int m,s,f;
450
    union 
451
    {
452
      struct cdrom_msf msf;
453
      char buffer[2356];
454
    } arg;
455
449
456
    // convert sector offset to minute, second, frame format
450
    // seek to requested sector
457
    // since that is what the 'ioctl' requires as input
451
    if (lseek(fd, dwSector * MODE1_DATA_SIZE, SEEK_SET) < 0)
458
    f = lba % CD_FRAMES;
452
    {
459
    lba /= CD_FRAMES;
453
      CLog::Log(LOGERROR, "CD: ReadSector Request to read sector %d\n", (int)dwSector);
460
    s = lba % CD_SECS;
454
      CLog::Log(LOGERROR, "CD: ReadSector error: %s\n", strerror(errno));
461
    lba /= CD_SECS;
455
      OutputDebugString("CD Read error\n");
462
    m = lba;
456
      return (-1);
457
    }
463
458
464
    arg.msf.cdmsf_min0 = m;
459
    // read data block of this sector
465
    arg.msf.cdmsf_sec0 = s;
460
    while (read(fd, lpczBuffer, MODE1_DATA_SIZE) < 0)
466
    arg.msf.cdmsf_frame0 = f;
467
    
468
    int ret = ioctl(fd, CDROMREADMODE1, &arg);
469
    if (ret==0)
470
    {
461
    {
471
      memcpy(lpczBuffer, arg.buffer, 2048);
462
      // read was interrupted - try again
472
      return 2048;
463
      if (errno == EINTR)
464
        continue;
465
466
      // error reading sector
467
      CLog::Log(LOGERROR, "CD: ReadSector Request to read sector %d\n", (int)dwSector);
468
      CLog::Log(LOGERROR, "CD: ReadSector error: %s\n", strerror(errno));
469
      OutputDebugString("CD Read error\n");
470
      return (-1);
473
    }
471
    }
474
    CLog::Log(LOGERROR, "CD: ReadSector Request to read sector %d\n", (int)dwSector);
472
475
    CLog::Log(LOGERROR, "CD: ReadSector error: %s\n", strerror(errno));
473
    return MODE1_DATA_SIZE;
476
    CLog::Log(LOGERROR, "CD: ReadSector minute %d, second %d, frame %d\n", m, s, f);
477
    OutputDebugString("CD Read error\n");
478
    return -1;    
479
  }
474
  }
480
#endif
475
#endif
481
  LARGE_INTEGER Displacement;
476
  LARGE_INTEGER Displacement;
(-)xbmc.orig/xbmc/xbox/IoSupport.h (+2 lines)
Lines 40-45 Link Here
40
#define DRIVE_CLOSED_MEDIA_PRESENT  4 // Will be send once when the drive just have closed
40
#define DRIVE_CLOSED_MEDIA_PRESENT  4 // Will be send once when the drive just have closed
41
#define DRIVE_NONE  5 // system doesn't have an optical drive
41
#define DRIVE_NONE  5 // system doesn't have an optical drive
42
42
43
#define MODE1_DATA_SIZE    2048 // Mode1 sector has 2048 bytes of data
44
43
#define MODE2_DATA_START   24   // Mode2 raw sector has 24 bytes before the data payload
45
#define MODE2_DATA_START   24   // Mode2 raw sector has 24 bytes before the data payload
44
#define MODE2_DATA_SIZE    2324 // And has 2324 usable bytes
46
#define MODE2_DATA_SIZE    2324 // And has 2324 usable bytes
45
#define RAW_SECTOR_SIZE    2352 // Raw sector size
47
#define RAW_SECTOR_SIZE    2352 // Raw sector size

Return to bug 260844