2
$Id: read.hpp,v 1.2 2006/01/18 21:31:37 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 methods relating to reading blocks of Compact Discs. This file
24
* should not be #included directly.
28
Reposition read offset
29
Similar to (if not the same as) libc's lseek()
31
@param offset amount to seek
32
@param whence like corresponding parameter in libc's lseek, e.g.
34
@return (off_t) -1 on error.
37
off_t lseek(off_t offset, int whence)
39
return cdio_lseek(p_cdio, offset, whence);
43
Reads into buf the next size bytes.
44
Similar to (if not the same as) libc's read()
46
@param p_buf place to read data into. The caller should make sure
47
this location can store at least i_size bytes.
48
@param i_size number of bytes to read
50
@return (ssize_t) -1 on error.
52
ssize_t read(void *p_buf, size_t i_size)
54
return cdio_read(p_cdio, p_buf, i_size);
58
Reads a number of sectors (AKA blocks).
60
@param p_buf place to read data into. The caller should make sure
61
this location is large enough. See below for size information.
62
@param read_mode the kind of "mode" to use in reading.
63
@param i_lsn sector to read
64
@param i_blocks number of sectors to read
66
If read_mode is CDIO_MODE_AUDIO,
67
*p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.
69
If read_mode is CDIO_MODE_DATA,
70
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
71
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
72
sector getting read. If you don't know whether you have a Mode 1/2,
73
Form 1/ Form 2/Formless sector best to reserve space for the maximum
74
which is M2RAW_SECTOR_SIZE.
76
If read_mode is CDIO_MODE_M2F1,
77
*p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.
79
If read_mode is CDIO_MODE_M2F2,
80
*p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.
82
A DriverOpException is raised on error.
85
void readSectors(void *p_buf, lsn_t i_lsn, cdio_read_mode_t read_mode,
88
driver_return_code_t drc = cdio_read_sectors(p_cdio, p_buf, i_lsn, read_mode,
90
possible_throw_device_exception(drc);
94
Reads a number of data sectors (AKA blocks).
96
@param p_buf place to read data into. The caller should make sure
97
this location is large enough. See below for size information.
99
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
100
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
101
sector getting read. If you don't know whether you have a Mode 1/2,
102
Form 1/ Form 2/Formless sector best to reserve space for the maximum
103
which is M2RAW_SECTOR_SIZE.
105
@param i_lsn sector to read
107
@param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE,
108
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf.
110
@param i_blocks number of sectors to read
112
A DriverOpException is raised on error.
116
void readDataBlocks(void *p_buf, lsn_t i_lsn, uint16_t i_blocksize,
119
driver_return_code_t drc = cdio_read_data_sectors (p_cdio, p_buf, i_lsn,
120
i_blocksize, i_blocks);
121
possible_throw_device_exception(drc);