~ubuntu-branches/ubuntu/maverick/libcdio/maverick

« back to all changes in this revision

Viewing changes to include/cdio++/read.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Nicolas Boullis
  • Date: 2007-10-04 00:52:35 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071004005235-4e3gdi4x2q2d14jx
Tags: 0.78.2+dfsg1-1
* Repack the source tarball to remove non-DFSG-free
  documentation. Thanks to Joerg Jaspert for pointing this.
* Also update debian/copyright to reflect the status of the removed
  documentation.
* Add libncurses5-dev | libncurses-dev to the build-dependencies, for
  cdda-player.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- C++ -*-
 
2
    $Id: read.hpp,v 1.2 2006/01/18 21:31:37 rocky Exp $
 
3
 
 
4
    Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
 
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
 
 
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
 
19
*/
 
20
 
 
21
/** \file read.hpp
 
22
 *
 
23
 *  \brief methods relating to reading blocks of Compact Discs. This file
 
24
 *  should not be #included directly.
 
25
 */
 
26
 
 
27
/*!
 
28
  Reposition read offset
 
29
  Similar to (if not the same as) libc's lseek()
 
30
  
 
31
  @param offset amount to seek
 
32
  @param whence  like corresponding parameter in libc's lseek, e.g. 
 
33
  SEEK_SET or SEEK_END.
 
34
  @return (off_t) -1 on error. 
 
35
*/
 
36
 
 
37
off_t lseek(off_t offset, int whence) 
 
38
{
 
39
  return cdio_lseek(p_cdio, offset, whence);
 
40
}
 
41
 
 
42
/*!
 
43
  Reads into buf the next size bytes.
 
44
  Similar to (if not the same as) libc's read()
 
45
  
 
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
 
49
  
 
50
  @return (ssize_t) -1 on error. 
 
51
*/
 
52
ssize_t read(void *p_buf, size_t i_size) 
 
53
{
 
54
  return cdio_read(p_cdio, p_buf, i_size);
 
55
}
 
56
 
 
57
/*!
 
58
  Reads a number of sectors (AKA blocks).
 
59
  
 
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
 
65
 
 
66
  If read_mode is CDIO_MODE_AUDIO,
 
67
    *p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.
 
68
 
 
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.
 
75
 
 
76
  If read_mode is CDIO_MODE_M2F1,
 
77
    *p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.
 
78
 
 
79
  If read_mode is CDIO_MODE_M2F2,
 
80
    *p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.
 
81
 
 
82
  A DriverOpException is raised on error.
 
83
*/
 
84
 
 
85
void readSectors(void *p_buf, lsn_t i_lsn, cdio_read_mode_t read_mode, 
 
86
                 uint32_t i_blocks=1)
 
87
{
 
88
  driver_return_code_t drc = cdio_read_sectors(p_cdio, p_buf, i_lsn, read_mode,
 
89
                                               i_blocks);
 
90
  possible_throw_device_exception(drc);
 
91
}
 
92
 
 
93
/*!
 
94
  Reads a number of data sectors (AKA blocks).
 
95
  
 
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.
 
98
 
 
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.
 
104
 
 
105
  @param i_lsn sector to read
 
106
 
 
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.
 
109
 
 
110
  @param i_blocks number of sectors to read
 
111
 
 
112
  A DriverOpException is raised on error.
 
113
  
 
114
*/
 
115
 
 
116
void readDataBlocks(void *p_buf, lsn_t i_lsn, uint16_t i_blocksize, 
 
117
                    uint32_t i_blocks=1) 
 
118
{
 
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);
 
122
}