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 1097:d4807997e450
next1099:566cdeb157ec
author nkeynes
date Sun Jan 31 18:35:06 2010 +1000 (10 years ago)
permissions -rw-r--r--
last change Refactor CDROM host support
- Completely separate GDROM hardware (in gdrom/gdrom.c) from generic CDROM
support (now in drivers/cdrom)
- Add concept of 'sector sources' that can be mixed and matched to create
cdrom discs (makes support of arbitrary disc types much simpler)
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  * Get the track information for the given track. If there is no such track,
   101  * return NULL;
   102  */
   103 cdrom_track_t cdrom_disc_get_track( cdrom_disc_t disc, cdrom_trackno_t track );
   105 /**
   106  * Get the track information for the first track of the given session. If there
   107  * is no such session, return NULL;
   108  */
   109 cdrom_track_t cdrom_disc_get_session( cdrom_disc_t disc, cdrom_sessionno_t session );
   111 cdrom_track_t cdrom_disc_get_last_track( cdrom_disc_t disc );
   113 cdrom_track_t cdrom_disc_prev_track( cdrom_disc_t disc, cdrom_track_t track );
   114 cdrom_track_t cdrom_disc_next_track( cdrom_disc_t disc, cdrom_track_t track );
   116 /**
   117  * Return the size of the track in sectors, including inter-track gap
   118  */
   119 cdrom_count_t cdrom_disc_get_track_size( cdrom_disc_t disc, cdrom_track_t track );
   121 /**
   122  * Find the track containing the sector specified by LBA.
   123  * Note: this function does not check for media change.
   124  * @return The track, or NULL if no track contains the sector.
   125  */
   126 cdrom_track_t cdrom_disc_get_track_by_lba( cdrom_disc_t disc, cdrom_lba_t lba );
   128 /** 
   129  * Check if the disc contains valid media.
   130  * @return CDROM_ERROR_OK if disc is present, otherwise CDROM_ERROR_NODISC
   131  */
   132 cdrom_error_t cdrom_disc_check_media( cdrom_disc_t disc );
   134 /**
   135  * Read sectors from the disc.
   136  * @return status code
   137  */
   138 cdrom_error_t cdrom_disc_read_sectors( cdrom_disc_t disc, cdrom_lba_t lba, cdrom_count_t count, cdrom_read_mode_t mode,
   139                                        unsigned char *buf, size_t *length );
   141 /**
   142  * Print the disc's table of contents to the given output stream.
   143  */
   144 void cdrom_disc_print_toc( FILE *f, cdrom_disc_t disc );
   146 #define cdrom_disc_ref(disc) sector_source_ref((sector_source_t)disc)
   147 #define cdrom_disc_unref(disc) sector_source_unref((sector_source_t)disc)
   149 #ifdef __cplusplus
   150 }
   151 #endif
   153 #endif /* !cdrom_cdrom_H */
.