Logo Search packages:      
Sourcecode: k9copy version File versions  Download package

bool K3bDevice::Device::readTocPmaAtip ( unsigned char **  data,
int &  dataLen,
int  format,
bool  time,
int  track 
) const

if true is returned dataLen specifies the actual length of *data which needs to be deleted after using.

Definition at line 507 of file k3bdevice_mmc.cpp.

References blockDeviceName().

Referenced by cdMediaType(), fixupToc(), numSessions(), readCdText(), and readRawToc().

{
  unsigned char header[2048];
  ::memset( header, 0, 2048 );

  ScsiCommand cmd( this );
  cmd[0] = MMC_READ_TOC_PMA_ATIP;
  cmd[1] = ( time ? 0x2 : 0x0 );
  cmd[2] = format & 0x0F;
  cmd[6] = track;
  cmd[8] = 2; // we only read the length first

  if( cmd.transport( TR_DIR_READ, header, 2 ) == 0 ) {
    // again with real length
    dataLen = from2Byte( header ) + 2;

    //
    // Some buggy firmwares do not return the size of the available data
    // but the returned data. So we use a high power of 2 to be on the safe side
    // with these buggy drives.
    // We cannot use this as default since many firmwares fail with a too high data length.
    //
    if( dataLen == 2 ) {
      cmd[7] = 2048>>8;
      cmd[8] = 2048;
      if( cmd.transport( TR_DIR_READ, header, 2048 ) == 0 )
      dataLen = from2Byte( header ) + 2;
    }

    *data = new unsigned char[dataLen];
    ::memset( *data, 0, dataLen );

    cmd[7] = dataLen>>8;
    cmd[8] = dataLen;
    if( cmd.transport( TR_DIR_READ, *data, dataLen ) == 0 )
      return true;
    else {
      kdDebug() << "(K3bDevice::Device) " << blockDeviceName() << ": READ TOC/PMA/ATIP format "
            << format << " with real length "
            << dataLen << " failed." << endl;
      delete [] *data;
    }
  }
  else
    kdDebug() << "(K3bDevice::Device) " << blockDeviceName() << ": READ TOC/PMA/ATIP length det failed." << endl;

  return false;
}


Generated by  Doxygen 1.6.0   Back to index