2
$Id: device.hpp,v 1.6 2006/03/05 06:52:15 rocky Exp $
4
Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
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.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
* \brief C++ header for driver- or device-related libcdio calls.
24
* ("device" includes CD-image reading devices.)
28
Free resources associated with CD-ROM Device/Image. After this we
29
must do another open before any more reading.
35
p_cdio = (CdIo_t *) NULL;
40
Eject media in CD drive if there is a routine to do so.
42
If the CD is ejected, object is destroyed.
47
driver_return_code_t drc = cdio_eject_media(&p_cdio);
48
possible_throw_device_exception(drc);
52
Free device list returned by GetDevices
54
@param device_list list returned by GetDevices
60
freeDeviceList (char * device_list[])
62
cdio_free_device_list(device_list);
66
Get the value associatied with key.
68
@param key the key to retrieve
69
@return the value associatd with "key" or NULL if p_cdio is NULL
70
or "key" does not exist.
73
getArg (const char key[])
75
return cdio_get_arg (p_cdio, key);
79
Return an opaque CdIo_t pointer for the given track object.
87
Return an opaque CdIo_t pointer for the given track object.
89
cdtext_t *getCdtext(track_t i_track)
91
return cdio_get_cdtext (p_cdio, i_track);
95
Get the CD device name for the object.
97
@return a string containing the CD device for this object or NULL is
98
if we couldn't get a device anme.
100
In some situations of drivers or OS's we can't find a CD device if
101
there is no media in it and it is possible for this routine to return
102
NULL even though there may be a hardware CD-ROM.
107
return cdio_get_default_device(p_cdio);
111
Get the what kind of device we've got.
113
@param p_read_cap pointer to return read capabilities
114
@param p_write_cap pointer to return write capabilities
115
@param p_misc_cap pointer to return miscellaneous other capabilities
117
In some situations of drivers or OS's we can't find a CD device if
118
there is no media in it and it is possible for this routine to return
119
NULL even though there may be a hardware CD-ROM.
122
getDriveCap (cdio_drive_read_cap_t &read_cap,
123
cdio_drive_write_cap_t &write_cap,
124
cdio_drive_misc_cap_t &misc_cap)
126
cdio_get_drive_cap(p_cdio, &read_cap, &write_cap, &misc_cap);
130
Get a string containing the name of the driver in use.
132
@return a string with driver name or NULL if CdIo_t is NULL (we
133
haven't initialized a specific device.
138
return cdio_get_driver_name(p_cdio);
143
if CdIo_t is NULL (we haven't initialized a specific device driver),
144
then return DRIVER_UNKNOWN.
146
@return the driver id..
151
return cdio_get_driver_id(p_cdio);
155
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
156
False is returned if we had an error getting the information.
159
getHWinfo ( /*out*/ cdio_hwinfo_t &hw_info )
161
return cdio_get_hwinfo(p_cdio, &hw_info);
164
/*! Get the LSN of the first track of the last session of
167
@param i_last_session pointer to the session number to be returned.
170
getLastSession (/*out*/ lsn_t &i_last_session)
172
driver_return_code_t drc = cdio_get_last_session(p_cdio, &i_last_session);
173
possible_throw_device_exception(drc);
177
Find out if media has changed since the last call.
178
@return 1 if media has changed since last call, 0 if not. Error
179
return codes are the same as driver_return_code_t
184
return cdio_get_media_changed(p_cdio);
187
/*! True if CD-ROM understand ATAPI commands. */
191
return cdio_have_atapi(p_cdio);
196
Sets up to read from the device specified by psz_source. An open
197
routine should be called before using any read routine. If device
198
object was previously opened it is closed first.
200
@return true if open succeeded or false if error.
204
open(const char *psz_source)
206
if (p_cdio) cdio_destroy(p_cdio);
207
p_cdio = cdio_open_cd(psz_source);
208
return NULL != p_cdio ;
213
Sets up to read from the device specified by psz_source and access
214
mode. An open routine should be called before using any read
215
routine. If device object was previously opened it is "closed".
217
@return true if open succeeded or false if error.
220
open (const char *psz_source, driver_id_t driver_id,
221
const char *psz_access_mode = (const char *) NULL)
223
if (p_cdio) cdio_destroy(p_cdio);
225
p_cdio = cdio_open_am(psz_source, driver_id, psz_access_mode);
227
p_cdio = cdio_open(psz_source, driver_id);
228
return NULL != p_cdio ;
232
Set the blocksize for subsequent reads.
235
setBlocksize ( int i_blocksize )
237
driver_return_code_t drc = cdio_set_blocksize ( p_cdio, i_blocksize );
238
possible_throw_device_exception(drc);
245
setSpeed ( int i_speed )
247
driver_return_code_t drc = cdio_set_speed ( p_cdio, i_speed );
248
possible_throw_device_exception(drc);
252
Set the arg "key" with "value" in "p_cdio".
254
@param key the key to set
255
@param value the value to assocaiate with key
258
setArg (const char key[], const char value[])
260
driver_return_code_t drc = cdio_set_arg (p_cdio, key, value);
261
possible_throw_device_exception(drc);