DWORD ReadCDAudioLBA( HCDROM hCD, LPTRACKBUF lpTrackBuf );


Description: 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.

Parameters:
hCD Handle to the CD-ROM device to read from
lpTrackBuf Pointer to a TRACKBUF structure specifying the audio to be read

Return Value:

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

Notes: If you look at the header file "akrip32.h", you might notice that there is no actual structure for TRACKBUF, but rather only LPTRACKBUF. You can use the function below to allocate a suitable LPTRACKBUF -- each frame is 2352 bytes long, and there is an extra overhead for the structure itself. The "numFrames" parameter specifies the maximum number of frames of digital audio you will want to extract at once. When calling ReadCDAudioLBA, set startFrame and numFrames according to the where you want to start reading audio and how many frames. The status member of the structure will contain the last SRB_Status member from the call to the ASPI layer.
LPTRACKBUF newTrackBuf( DWORD numFrames )
{
  LPTRACKBUF t;
  int numAlloc;

  numAlloc = (((int)numFrames)*2352) + TRACKBUFEXTRA;

  t = (LPTRACKBUF)malloc( numAlloc );

  if ( !t )
    return NULL;

  t->startFrame = 0;
  t->numFrames = 0;
  t->maxLen = numFrames * 2352;
  t->len = 0;
  t->status = 0;
  t->startOffset = 0;

  return t;
}

See also: GetAspiLibError