TRACKBUF


  typedef struct
  {
    DWORD   startFrame;
    DWORD   numFrames;
    DWORD   maxLen;
    DWORD   len;
    DWORD   status;
    int     startOffset;
    BYTE    buf[1024*1024];
  } *PTRACKBUF, FAR *LPTRACKBUF;
  
Description: The TRACKBUF structure is used by ReadCDAudioLBA. It should not be allocated directly, but rather a buffer of the desired size should be allocated and typecast to an LPTRACKBUF -- since TRACKBUF is not actually defined, this section should by all rights be entitled LPTRACKBUF. The amount of memory to allocate is calculated by the following formula: numBytes = (2352 * numFrames) + TRACKBUFEXTRA. TRACKBUFEXTRA is defined in akrip32.h.

This structure is designed to allow for easy jitter correction. After a read, the value for startOffset will be zero, and len will be the number of frames * 2352 bytes. After jitter correction, startFrame, startOffset, len and numFrames will be adjusted to reflect the start of data; this is done to avoid an unnecessary move of the data to the beginning of buf. The maxLen member should never change.

Members:
startFrame For calls to ReadCDAudioLBA, this should be set to the first frame to read. Once data has been read, startFrame specifies the LBA of the first frame of valid data in buf.
numFrames The number of frames to read, or after data has been read, the number of complete frames contained in buf.
maxLen The length of the array buf.
len The number of valid bytes actually stored in buf.
status The value from SRB_Status from the call to the ASPI manager for the read.
startOffset The starting offset of valid data in buf. After a read, this will be set to zero, but after jitter correction, this value may change to indicate the position where data begins in buf.
buf The actual audio data itself.


Example usage: The following function can be used to allocate a new LPTRACKBUF of a size sufficient to read numFrames frames of data. One frame is 2352 bytes.
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: ReadCDAudioLBA