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

« back to all changes in this revision

Viewing changes to lib/cdda_interface/cddap_interface.c

  • 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
1
/*
2
 
  $Id: cddap_interface.c,v 1.1 2005/02/05 16:25:51 rocky Exp $
 
2
  $Id: cddap_interface.c,v 1.5 2006/03/18 18:37:56 rocky Exp $
3
3
 
4
4
  Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
5
5
  Original interface.c Copyright (C) 1994-1997 
21
21
  along with this program; if not, write to the Free Software
22
22
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
23
*/
24
 
/******************************************************************
25
 
 *
26
 
 * CDROM code specific to the cooked ioctl interface
27
 
 *
28
 
 ******************************************************************/
29
 
 
 
24
/**
 
25
 
 
26
  CD-ROM code which interfaces between user-level visible CD paranoia
 
27
  routines and libddio routines. (There is some GNU/Linux-specific
 
28
  code here too that should probably be removed.
 
29
 
 
30
**/
 
31
 
 
32
#include "config.h"
30
33
#include "common_interface.h"
31
34
#include "low_interface.h"
32
35
#include "utils.h"
33
36
 
 
37
/** The below variables are trickery to force the above enum symbol
 
38
    values to be recorded in debug symbol tables. They are used to
 
39
    allow one to refer to the enumeration value names in the typedefs
 
40
    above in a debugger and debugger expressions
 
41
*/
 
42
 
 
43
paranoia_jitter_t     debug_paranoia_jitter;
 
44
paranoia_cdda_enums_t debug_paranoia_cdda_enums;
 
45
 
34
46
/*! reads TOC via libcdio and returns the number of tracks in the disc. 
35
47
    0 is returned if there was an error.
36
48
*/
141
153
  if (d->i_test_flags & CDDA_TEST_ALWAYS_JITTER)
142
154
    jitter_flag = 1;
143
155
  else 
 
156
#ifdef HAVE_DRAND48
144
157
    jitter_flag = (drand48() > .9) ? 1 : 0;
 
158
#else
 
159
    jitter_flag = (rand() > .9) ? 1 : 0;
 
160
#endif
145
161
  
146
162
  if (jitter_flag) {
147
163
    int i_coeff = 0;
153
169
    case JITTER_NONE   :
154
170
    default            : ;
155
171
    }
 
172
#ifdef HAVE_DRAND48
156
173
    i_jitter = i_coeff * (int)((drand48()-.5)*CDIO_CD_FRAMESIZE_RAW/8);
 
174
#else
 
175
    i_jitter = i_coeff * (int)((rand()-.5)*CDIO_CD_FRAMESIZE_RAW/8);
 
176
#endif
157
177
    
158
178
    /* We may need to add another sector to compensate for the bytes that
159
179
       will be dropped off when jittering, and the begin location may
171
191
    
172
192
    
173
193
    if (begin + i_jitter_sectors > 0) {
 
194
#if !TRACE_PARANOIA
174
195
      char buffer[256];
175
196
      sprintf(buffer, "jittering by %d, offset %ld\n", i_jitter, 
176
197
              i_jitter_offset);
177
198
      cdmessage(d,buffer); 
 
199
#endif
178
200
 
179
201
      begin += i_jitter_sectors;
180
202
      i_sectors ++; 
191
213
    /* Had to reduce # of sectors due to read errors. So give full amount,
192
214
       with no jittering. */
193
215
    memcpy(p, p_buf, i_sectors*CDIO_CD_FRAMESIZE_RAW);
194
 
  else 
 
216
  else {
195
217
    /* Got full amount, but now adjust size for jittering. */
196
218
    memcpy(p, p_buf+i_jitter_offset, i_sectors_orig*CDIO_CD_FRAMESIZE_RAW);
 
219
    i_sectors = i_sectors_orig;
 
220
  }
197
221
 
198
222
  free(p_buf);
199
223
  return(i_sectors);