Search
lxdream.org :: lxdream/src/drivers/cdrom/cdrom.h :: diff
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)
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/drivers/cdrom/cdrom.h Sun Jan 31 18:35:06 2010 +1000
1.3 @@ -0,0 +1,153 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * Copyright (c) 2005-2009 Nathan Keynes.
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or modify
1.10 + * it under the terms of the GNU General Public License as published by
1.11 + * the Free Software Foundation; either version 2 of the License, or
1.12 + * (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + */
1.19 +
1.20 +#ifndef cdrom_cdrom_H
1.21 +#define cdrom_cdrom_H 1
1.22 +
1.23 +#include <stdio.h>
1.24 +#include <glib/glist.h>
1.25 +#include "drivers/cdrom/defs.h"
1.26 +#include "drivers/cdrom/sector.h"
1.27 +
1.28 +#ifdef __cplusplus
1.29 +extern "C" {
1.30 +#endif
1.31 +
1.32 +typedef enum {
1.33 + CDROM_DISC_NONE = 0x06,
1.34 + CDROM_DISC_AUDIO = 0x00,
1.35 + CDROM_DISC_NONXA = 0x10,
1.36 + CDROM_DISC_XA = 0x20,
1.37 + CDROM_DISC_GDROM = 0x80
1.38 +} cdrom_disc_type_t;
1.39 +
1.40 +#define TRACK_FLAG_PREEMPH 0x10 /* Pre-emphasis (audio only) */
1.41 +#define TRACK_FLAG_COPYPERM 0x20 /* Copy permitted */
1.42 +#define TRACK_FLAG_DATA 0x40 /* Data track */
1.43 +#define TRACK_FLAG_FOURCHAN 0x80 /* 4-channel audio */
1.44 +
1.45 +struct cdrom_track {
1.46 + cdrom_trackno_t trackno;
1.47 + cdrom_sessionno_t sessionno; /* session # containing this track */
1.48 + cdrom_lba_t lba; /* start sector address */
1.49 + uint8_t flags; /* Track flags */
1.50 + sector_source_t source;
1.51 +};
1.52 +
1.53 +/**
1.54 + * A CDROM disc, either an image file, or an open physical host device.
1.55 + */
1.56 +struct cdrom_disc {
1.57 + struct sector_source source;
1.58 + const char *name; /* Filename or identifier used to open the disc */
1.59 + cdrom_disc_type_t disc_type;
1.60 + gchar mcn[14]; /* Media catalogue number, null terminated. */
1.61 + cdrom_trackno_t track_count;
1.62 + cdrom_sessionno_t session_count;
1.63 + cdrom_lba_t leadout; /* LBA of the disc leadout */
1.64 + struct cdrom_track track[99];
1.65 +
1.66 + /* Reference to an underlying source, if any. */
1.67 + sector_source_t base_source;
1.68 +
1.69 + /* Private implementation-specific data */
1.70 + void *impl_data;
1.71 +
1.72 + /** Check for media change. If the media cannot change (ie image file)
1.73 + * or is notified asynchonously, this should be a no-op. In the event of
1.74 + * a change, this function should update the structure according to the
1.75 + * new media (including TOC), and return TRUE.
1.76 + * @return TRUE if the media has changed since the last check, otherwise
1.77 + * FALSE.
1.78 + */
1.79 + gboolean (*check_media)(cdrom_disc_t disc);
1.80 +
1.81 + /**
1.82 + * Read the table of contents from the given file
1.83 + */
1.84 + gboolean (*read_toc)(cdrom_disc_t disc, ERROR *err);
1.85 +
1.86 + /**
1.87 + * Begin playing audio from the given lba address on the disc.
1.88 + */
1.89 + cdrom_error_t (*play_audio)(cdrom_disc_t disc, cdrom_lba_t lba, cdrom_count_t length);
1.90 +
1.91 + cdrom_error_t (*scan_audio)(cdrom_disc_t disc, cdrom_lba_t lba, gboolean direction);
1.92 +
1.93 + cdrom_error_t (*stop_audio)(cdrom_disc_t disc);
1.94 +
1.95 +};
1.96 +
1.97 +/**
1.98 + * Open an image file or device
1.99 + */
1.100 +cdrom_disc_t cdrom_disc_open( const char *filename, ERROR *err );
1.101 +
1.102 +/**
1.103 + * Get the track information for the given track. If there is no such track,
1.104 + * return NULL;
1.105 + */
1.106 +cdrom_track_t cdrom_disc_get_track( cdrom_disc_t disc, cdrom_trackno_t track );
1.107 +
1.108 +/**
1.109 + * Get the track information for the first track of the given session. If there
1.110 + * is no such session, return NULL;
1.111 + */
1.112 +cdrom_track_t cdrom_disc_get_session( cdrom_disc_t disc, cdrom_sessionno_t session );
1.113 +
1.114 +cdrom_track_t cdrom_disc_get_last_track( cdrom_disc_t disc );
1.115 +
1.116 +cdrom_track_t cdrom_disc_prev_track( cdrom_disc_t disc, cdrom_track_t track );
1.117 +cdrom_track_t cdrom_disc_next_track( cdrom_disc_t disc, cdrom_track_t track );
1.118 +
1.119 +/**
1.120 + * Return the size of the track in sectors, including inter-track gap
1.121 + */
1.122 +cdrom_count_t cdrom_disc_get_track_size( cdrom_disc_t disc, cdrom_track_t track );
1.123 +
1.124 +/**
1.125 + * Find the track containing the sector specified by LBA.
1.126 + * Note: this function does not check for media change.
1.127 + * @return The track, or NULL if no track contains the sector.
1.128 + */
1.129 +cdrom_track_t cdrom_disc_get_track_by_lba( cdrom_disc_t disc, cdrom_lba_t lba );
1.130 +
1.131 +/**
1.132 + * Check if the disc contains valid media.
1.133 + * @return CDROM_ERROR_OK if disc is present, otherwise CDROM_ERROR_NODISC
1.134 + */
1.135 +cdrom_error_t cdrom_disc_check_media( cdrom_disc_t disc );
1.136 +
1.137 +/**
1.138 + * Read sectors from the disc.
1.139 + * @return status code
1.140 + */
1.141 +cdrom_error_t cdrom_disc_read_sectors( cdrom_disc_t disc, cdrom_lba_t lba, cdrom_count_t count, cdrom_read_mode_t mode,
1.142 + unsigned char *buf, size_t *length );
1.143 +
1.144 +/**
1.145 + * Print the disc's table of contents to the given output stream.
1.146 + */
1.147 +void cdrom_disc_print_toc( FILE *f, cdrom_disc_t disc );
1.148 +
1.149 +#define cdrom_disc_ref(disc) sector_source_ref((sector_source_t)disc)
1.150 +#define cdrom_disc_unref(disc) sector_source_unref((sector_source_t)disc)
1.151 +
1.152 +#ifdef __cplusplus
1.153 +}
1.154 +#endif
1.155 +
1.156 +#endif /* !cdrom_cdrom_H */
.