DWORD ReadCDAudioLBAEx( HCDROM hCD, LPTRACKBUF lpTrackBuf, LPTRACKBUF lpOverlap );


Description: Extended version of ReadCDAudioLBA. Reads CD-DA audio from a CD-ROM device using LBA (Logical Block Address) mode addressing. The track to be read is specified by the lpTrackBuf parameter, which also receives the audio data read. The data in lpOverlap is used to perform jitter correction on the data read into lpTrackBuf. After a successful read, the last numOverlap frames (as specified in the GETCDHAND structure) are copied into lpOverlap for use in successive calls to ReadCDAudioLBAEx. On the first read, or after an error, lpOverlap->len should be set to 0.

Parameters:
hCD Handle to the CD-ROM device to read from
lpTrackBuf Pointer to a TRACKBUF structure specifying the audio to be read
lpOverlap Pointer to a TRACKBUF structure containing data from the end of the last read operation. On the first read, or after an error, its len member should be set to 0.

Return Value:

SS_COMP Audio read successfully
SS_ERR An error occured. Use GetAspiLibError to retrieve the specific error code.

Notes: The LPTRACKBUF is allocated the same way as for ReadCDAudioLBA. This function will attempt to perform jitter correction on the buffer read. If you do not wish to use automatic jitter correction, then you should call ReadCDAudioLBA instead. The following code demonstrates the usage of ReadCDAudioLBAEx to rip a complete track to a file as a raw sample using jitter correction. newTrackBuf is shown in ReadCDAudioLBA. In real usage, the return value from ReadCDAudioLBAEx should be checked for errors. Also, you should make sure that the values you have provided for jitter correction (from the call to GetCDHandle are correct. Those values can be changed by calling ModifyCDParms. See the notes for GETCDHAND for details on suitable values for jitter correction.
int ripTrack( HCDROM hCD, DWORD startLBA, DWORD numFrames, FILE *fp )
{
  LPTRACKBUF t, tOverlap;

  t = newTrackBuf( 27 );
  tOverlap = newTrackBuf( 3 );  // we set numOverlap=3 in GETCDHAND

  tOverlap->len = tOverlap->startFrame = tOverlap->numFrames = 0;
  while( numFrames > 0 )
  {
    t->startFrame = startLBA;
    t->numFrames = 27;
    ReadCDAudioLBAEx( hCD, t, tOverlap );

    // t->numFrames will contain the number of full frames available
    // after jitter correction.
    startLBA += t->numFrames;
    numFrames -= t->numFrames;
    fwrite( t->buf + t->startOffset, 1, t->len, fp );
  }

  return 0;
}
See also: GetAspiLibError, ReadCDAudioLBA