Search
lxdream.org :: lxdream/src/drivers/cdrom/cdrom.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/cdrom/cdrom.h
changeset 1109:700c5ab26a63
prev1108:305ef2082079
next1296:30ecee61f811
author nkeynes
date Wed Jan 19 17:50:09 2011 +1000 (13 years ago)
permissions -rw-r--r--
last change Implement vertex array range support, and move buffer operations to gl_vbo.c
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * Copyright (c) 2005-2009 Nathan Keynes.
     5  *
     6  * This program is free software; you can redistribute it and/or modify
     7  * it under the terms of the GNU General Public License as published by
     8  * the Free Software Foundation; either version 2 of the License, or
     9  * (at your option) any later version.
    10  *
    11  * This program is distributed in the hope that it will be useful,
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  * GNU General Public License for more details.
    15  */
    17 #ifndef cdrom_cdrom_H
    18 #define cdrom_cdrom_H 1
    20 #include <stdio.h>
    21 #include <glib/glist.h>
    22 #include "drivers/cdrom/defs.h"
    23 #include "drivers/cdrom/sector.h"
    25 #ifdef __cplusplus
    26 extern "C" {
    27 #endif
    29 typedef enum {
    30     CDROM_DISC_NONE =  0x06,
    31     CDROM_DISC_AUDIO = 0x00,
    32     CDROM_DISC_NONXA = 0x10,
    33     CDROM_DISC_XA    = 0x20,
    34     CDROM_DISC_GDROM = 0x80
    35 } cdrom_disc_type_t;
    37 #define TRACK_FLAG_PREEMPH   0x10 /* Pre-emphasis (audio only) */
    38 #define TRACK_FLAG_COPYPERM  0x20 /* Copy permitted */
    39 #define TRACK_FLAG_DATA      0x40 /* Data track */
    40 #define TRACK_FLAG_FOURCHAN  0x80 /* 4-channel audio */
    42 struct cdrom_track {
    43     cdrom_trackno_t trackno;
    44     cdrom_sessionno_t sessionno;  /* session # containing this track */
    45     cdrom_lba_t lba;            /* start sector address */
    46     uint8_t flags;              /* Track flags */
    47     sector_source_t source;
    48 };
    50 /**
    51  * A CDROM disc, either an image file, or an open physical host device.
    52  */
    53 struct cdrom_disc {
    54     struct sector_source source;
    55     const char *name; /* Filename or identifier used to open the disc */
    56     cdrom_disc_type_t disc_type;
    57     gchar mcn[14]; /* Media catalogue number, null terminated. */
    58     cdrom_trackno_t track_count;
    59     cdrom_sessionno_t session_count;
    60     cdrom_lba_t leadout; /* LBA of the disc leadout */
    61     struct cdrom_track track[99];
    63     /* Reference to an underlying source, if any. */
    64     sector_source_t base_source;
    66     /* Private implementation-specific data */
    67     void *impl_data;
    69     /** Check for media change. If the media cannot change (ie image file)
    70      * or is notified asynchonously, this should be a no-op. In the event of
    71      * a change, this function should update the structure according to the
    72      * new media (including TOC), and return TRUE.
    73      * @return TRUE if the media has changed since the last check, otherwise
    74      * FALSE.
    75      */
    76     gboolean (*check_media)(cdrom_disc_t disc);
    78     /**
    79      * Read the table of contents from the given file
    80      */
    81     gboolean (*read_toc)(cdrom_disc_t disc, ERROR *err);
    83     /**
    84      * Begin playing audio from the given lba address on the disc.
    85      */
    86     cdrom_error_t (*play_audio)(cdrom_disc_t disc, cdrom_lba_t lba, cdrom_count_t length);
    88     cdrom_error_t (*scan_audio)(cdrom_disc_t disc, cdrom_lba_t lba, gboolean direction);
    90     cdrom_error_t (*stop_audio)(cdrom_disc_t disc);
    92 };
    94 /**
    95  * Open an image file or device
    96  */
    97 cdrom_disc_t cdrom_disc_open( const char *filename, ERROR *err );
    99 /**
   100  * Construct a disc around a source track.
   101  * @param type Disc type, which must be compatible with the track mode
   102  * @param track The source of data for the main track
   103  * @param lba The position on disc of the main track. If non-zero,
   104  * a filler track is added before it, in 2 separate sessions.
   105  */
   106 cdrom_disc_t cdrom_disc_new_from_track( cdrom_disc_type_t type, sector_source_t track, cdrom_lba_t lba, ERROR *err );
   108 /**
   109  * Get the track information for the given track. If there is no such track,
   110  * return NULL;
   111  */
   112 cdrom_track_t cdrom_disc_get_track( cdrom_disc_t disc, cdrom_trackno_t track );
   114 /**
   115  * Get the track information for the first track of the given session. If there
   116  * is no such session, return NULL;
   117  */
   118 cdrom_track_t cdrom_disc_get_session( cdrom_disc_t disc, cdrom_sessionno_t session );
   120 cdrom_track_t cdrom_disc_get_last_track( cdrom_disc_t disc );
   122 /**
   123  * Get the track information for the last data track  on the disc
   124  */
   125 cdrom_track_t cdrom_disc_get_last_data_track( cdrom_disc_t disc );
   127 cdrom_track_t cdrom_disc_prev_track( cdrom_disc_t disc, cdrom_track_t track );
   128 cdrom_track_t cdrom_disc_next_track( cdrom_disc_t disc, cdrom_track_t track );
   130 /**
   131  * Return the size of the track in sectors, including inter-track gap
   132  */
   133 cdrom_count_t cdrom_disc_get_track_size( cdrom_disc_t disc, cdrom_track_t track );
   135 /**
   136  * Find the track containing the sector specified by LBA.
   137  * Note: this function does not check for media change.
   138  * @return The track, or NULL if no track contains the sector.
   139  */
   140 cdrom_track_t cdrom_disc_get_track_by_lba( cdrom_disc_t disc, cdrom_lba_t lba );
   142 /** 
   143  * Check if the disc contains valid media.
   144  * @return CDROM_ERROR_OK if disc is present, otherwise CDROM_ERROR_NODISC
   145  */
   146 cdrom_error_t cdrom_disc_check_media( cdrom_disc_t disc );
   148 /**
   149  * Read sectors from the disc.
   150  * @return status code
   151  */
   152 cdrom_error_t cdrom_disc_read_sectors( cdrom_disc_t disc, cdrom_lba_t lba, cdrom_count_t count, cdrom_read_mode_t mode,
   153                                        unsigned char *buf, size_t *length );
   155 /**
   156  * Print the disc's table of contents to the given output stream.
   157  */
   158 void cdrom_disc_print_toc( FILE *f, cdrom_disc_t disc );
   160 #define cdrom_disc_ref(disc) sector_source_ref((sector_source_t)disc)
   161 #define cdrom_disc_unref(disc) sector_source_unref((sector_source_t)disc)
   163 #ifdef __cplusplus
   164 }
   165 #endif
   167 #endif /* !cdrom_cdrom_H */
.