4 * Copyright (c) 2005-2009 Nathan Keynes.
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.
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.
18 #define cdrom_cdrom_H 1
21 #include <glib/glist.h>
22 #include "drivers/cdrom/defs.h"
23 #include "drivers/cdrom/sector.h"
30 CDROM_DISC_NONE = 0x06,
31 CDROM_DISC_AUDIO = 0x00,
32 CDROM_DISC_NONXA = 0x10,
34 CDROM_DISC_GDROM = 0x80
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 */
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;
51 * A CDROM disc, either an image file, or an open physical host device.
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 */
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
76 gboolean (*check_media)(cdrom_disc_t disc);
79 * Read the table of contents from the given file
81 gboolean (*read_toc)(cdrom_disc_t disc, ERROR *err);
84 * Begin playing audio from the given lba address on the disc.
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);
95 * Open an image file or device
97 cdrom_disc_t cdrom_disc_open( const char *filename, ERROR *err );
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.
106 cdrom_disc_t cdrom_disc_new_from_track( cdrom_disc_type_t type, sector_source_t track, cdrom_lba_t lba, ERROR *err );
109 * Get the track information for the given track. If there is no such track,
112 cdrom_track_t cdrom_disc_get_track( cdrom_disc_t disc, cdrom_trackno_t track );
115 * Get the track information for the first track of the given session. If there
116 * is no such session, return NULL;
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 );
123 * Get the track information for the last data track on the disc
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 );
131 * Return the size of the track in sectors, including inter-track gap
133 cdrom_count_t cdrom_disc_get_track_size( cdrom_disc_t disc, cdrom_track_t track );
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.
140 cdrom_track_t cdrom_disc_get_track_by_lba( cdrom_disc_t disc, cdrom_lba_t lba );
143 * Check if the disc contains valid media.
144 * @return CDROM_ERROR_OK if disc is present, otherwise CDROM_ERROR_NODISC
146 cdrom_error_t cdrom_disc_check_media( cdrom_disc_t disc );
149 * Read sectors from the disc.
150 * @return status code
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 );
156 * Print the disc's table of contents to the given output stream.
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)
167 #endif /* !cdrom_cdrom_H */
.