TOCTRACK, TOC


  typedef struct
  {
    BYTE   rsvd;
    BYTE   ADR;
    BYTE   trackNumber;
    BYTE   rsvd2;
    BYTE   addr[4];
  } PACKED TOCTRACK;

  typedef struct
  {
    WORD   tocLen;
    BYTE   firstTrack;
    BYTE   lastTrack;
    TOCTRACK tracks[100];
  } PACKED TOC, *PTOC, FAR *LPTOC;
  
Description: The TOC structure is used for calls to ReadTOC. It is essentially a direct copy of the format returned by the SCSI READ TOC (0x43) command.

Members:
TOCTRACK:
rsvd Not used
ADR ADR and format byte. If bit 2 of this byte is set, then the track is data.
trackNumber The number of the track entry. A value of 0xAA indicates that the track entry is for the start of the lead-out area.
rsvd2 Not used
addr The Logical Block Address (LBA) for the start of the track, represented as a 4-byte big-endian unsigned value. ModifyCDParms can be used to switch the address format to MSF (minute/second/frame). For MSF format, m = addr[1], s = addr[2], and f = addr[3].

TOC:
tocLen The length of the returned data
firstTrack The first track number in the TOC -- is usually 1 but is not required to be.
lastTrack The last track number.
tracks Array of track descriptor structures. Each element represents one entry in the TOC.


Example usage: The following example will read the TOC for an already opened CD-ROM, and print the start address (LBA) of each track.
    TOC t;
    int i;
    DWORD addr;

    memset( &t, 0, sizeof(t) );
    ReadTOC( hCD, &t );
    for( i = t.firstTrack; i < t.lastTrack; i++ )
    {
      addr = ((DWORD)t.tracks[i-1].addr[0]) << 24 +
             ((DWORD)t.tracks[i-1].addr[1]) << 16 +
             ((DWORD)t.tracks[i-1].addr[2]) << 8 +
             ((DWORD)t.tracks[i-1].addr[3]);
      printf( "Track %02d: %d\n", i, addr );
    }

  
See also: ReadTOC