[Contents] [Index] [Help] [Retrace] [Browse <] [Browse >]


   NAME
       CD_TOCLSN -- Return table of contents information from CD (LSN form).

   IO REQUEST
       io_Device       preset by the call to opendevice()
       io_Unit         preset by the call to opendevice()
       io_Command      CD_TOCLSN
       io_Data         pointer to array where TOC is to be stored
       io_Length       number of CDTOC entries to be fetched
       io_Offset       entry to begin at (entry 0 is summary information)

   RESULTS
       io_Error        0 for success, or an error code as defined in
                       <devices/cd.h>
       io_Actual       Actual number of entries copied

   FUNCTION
       This command returns the table of contents of the disk currently in
       the drive.  The table of contents consists of up to 100 entries.
       Entry zero is summary information describing the number of tracks
       and the total number of minutes on the disk.  Entries 1 through N
       contain information about each individual track.  All position
       information will be in LSN format.

       The io_Data field points to an array of CDTOC structures to receive
       the TOC data.

       The io_Length field specifies the total number of entries to be
       fetched.  The array pointed to by io_Data must be at least this many
       elements in size.

       The io_Offset field specifies the entry number at which to start
       copying TOC data into *io_Data.

       Entry zero (the summary entry) contains the following:

       struct tocsummary {

           ubyte        firsttrack;    /* first track on disk (always 1)   */
           ubyte        lasttrack;     /* last track on disk               */
           union LSNMSF LeadOut;       /* Beginning of lead-out track      */
           };

       Track entries (entries 1 through number of tracks) contain:

       struct tocentry {

           ubyte        ctladr;        /* q-code info                  */
           ubyte        track;         /* track number                 */
           union LSNMSF Position;      /* Start position of this track */
           };

       CDTOC is described as a union between these two structures:

       union CDTOC {

           struct tocsummary summary;  /* first entry is summary info.  */
           struct tocentry   entry;    /* entries 1-n are track entries */
           };


   EXAMPLE

       union CDTOC tocarray[100];

       ior->io_Command = CD_TOCLSN;        /* Retrieve TOC information */
       ior->io_Offset  = 0;                /* Start with summary info  */
       ior->io_Length  = 100;              /* Max 99 tracks + summary  */
       ior->io_Data    = (APTR)tocarray;   /* Here's where we want it  */
       doio (ior);

       if (!ior->io_Error) {               /* Command succeeded        */

           firsttrack   = tocarray[0].Summary.FirstTrack;
           lasttrack    = tocarray[0].Summary.LastTrack;
           totalsectors = tocarray[0].Summary.LeadOut.LSN -
                          tocarray[1].Entry.Position.LSN;
           }

   NOTES

       In the above example, the amount of data on the disk is calculated as
       being equal to the location of the lead-out track minus the start of
       the first track (which is never zero).

   BUGS

   SEE ALSO