More paranoia removal
* Also some silencing of makefile operations
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,7 +21,6 @@
|
||||
/libcdio-*.sig
|
||||
/libcdio.pc
|
||||
/libcdio_cdda.pc
|
||||
/libcdio_paranoia.pc
|
||||
/libiso9660++.pc
|
||||
/libiso9660.pc
|
||||
/libtool
|
||||
|
||||
@@ -42,8 +42,7 @@ SUBDIRS = doc include lib src test example
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libcdio.pc \
|
||||
libiso9660.pc \
|
||||
libudf.pc \
|
||||
$(paranoiapcs)
|
||||
libudf.pc
|
||||
|
||||
if ENABLE_CXX_BINDINGS
|
||||
pkgconfig_DATA += \
|
||||
|
||||
2
example/.gitignore
vendored
2
example/.gitignore
vendored
@@ -24,8 +24,6 @@
|
||||
/mmc2
|
||||
/mmc2a
|
||||
/mmc3
|
||||
/paranoia
|
||||
/paranoia2
|
||||
/sample3
|
||||
/sample4
|
||||
/track-01.wav
|
||||
|
||||
@@ -10,6 +10,3 @@ isofile
|
||||
isofile2
|
||||
mmc1
|
||||
mmc2
|
||||
paranoia
|
||||
paranoia2
|
||||
|
||||
|
||||
2
example/C++/.gitignore
vendored
2
example/C++/.gitignore
vendored
@@ -13,5 +13,3 @@
|
||||
/main
|
||||
/mmc1
|
||||
/mmc2
|
||||
/paranoia
|
||||
/paranoia2
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
/*
|
||||
$Id: paranoia.cpp,v 1.3 2008/03/24 15:30:56 karl Exp $
|
||||
|
||||
Copyright (C) 2005, 2008, 2009 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Simple program to show using libcdio's version of the CD-DA paranoia.
|
||||
library. */
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#define __CDIO_CONFIG_H__ 1
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
using namespace std;
|
||||
|
||||
extern "C"{
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <cdio/paranoia.h>
|
||||
#include <cdio/cd_types.h>
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
cdrom_drive_t *d = NULL; /* Place to store handle given by cd-paranoia. */
|
||||
char **ppsz_cd_drives; /* List of all drives with a loaded CDDA in it. */
|
||||
|
||||
/* See if we can find a device with a loaded CD-DA in it. */
|
||||
ppsz_cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
|
||||
|
||||
if (ppsz_cd_drives) {
|
||||
/* Found such a CD-ROM with a CD-DA loaded. Use the first drive in
|
||||
the list. */
|
||||
d = cdda_identify(*ppsz_cd_drives, 1, NULL);
|
||||
} else {
|
||||
cerr << "Unable to access to a CD-ROM drive with audio CD in it";
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Don't need a list of CD's with CD-DA's any more. */
|
||||
cdio_free_device_list(ppsz_cd_drives);
|
||||
|
||||
if ( !d ) {
|
||||
cerr << "Unable to identify audio CD disc.\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We'll set for verbose paranoia messages. */
|
||||
cdda_verbose_set(d, CDDA_MESSAGE_PRINTIT, CDDA_MESSAGE_PRINTIT);
|
||||
|
||||
if ( 0 != cdda_open(d) ) {
|
||||
cerr << "Unable to open disc.\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Okay now set up to read up to the first 300 frames of the first
|
||||
audio track of the Audio CD. */
|
||||
{
|
||||
cdrom_paranoia_t *p = paranoia_init(d);
|
||||
lsn_t i_first_lsn = cdda_disc_firstsector(d);
|
||||
|
||||
if ( -1 == i_first_lsn ) {
|
||||
printf("Trouble getting starting LSN\n");
|
||||
} else {
|
||||
lsn_t i_cursor;
|
||||
track_t i_track = cdda_sector_gettrack(d, i_first_lsn);
|
||||
lsn_t i_last_lsn = cdda_track_lastsector(d, i_track);
|
||||
|
||||
/* For demo purposes we'll read only 300 frames (about 4
|
||||
seconds). We don't want this to take too long. On the other
|
||||
hand, I suppose it should be something close to a real test.
|
||||
*/
|
||||
if ( i_last_lsn - i_first_lsn > 300) i_last_lsn = i_first_lsn + 299;
|
||||
|
||||
printf("Reading track %d from LSN %ld to LSN %ld\n", i_track,
|
||||
(long int) i_first_lsn, (long int) i_last_lsn);
|
||||
|
||||
/* Set reading mode for full paranoia, but allow skipping sectors. */
|
||||
paranoia_modeset(p, PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP);
|
||||
|
||||
paranoia_seek(p, i_first_lsn, SEEK_SET);
|
||||
//Get the track size in bytes and conver it to string
|
||||
unsigned int byte_count =
|
||||
( i_last_lsn - i_first_lsn + 1 ) * CDIO_CD_FRAMESIZE_RAW;
|
||||
|
||||
// Open the output file
|
||||
ofstream outfile ("track01.wav",
|
||||
ofstream::binary | ofstream::app | ofstream::out);
|
||||
|
||||
// Write format header specification
|
||||
const int waweChunkLength = byte_count + 44 - 8;
|
||||
const int fmtChunkLength = 16;
|
||||
const int compressionCode = 1;
|
||||
const int numberOfChannels = 2;
|
||||
const int sampleRate = 44100; // Hz
|
||||
const int blockAlign = sampleRate*2*2;
|
||||
const int significantBps = 4;
|
||||
const int extraFormatBytes = 16;
|
||||
|
||||
#define writestr(str) outfile.write(str, sizeof(str)-1)
|
||||
writestr("RIFF");
|
||||
outfile.write((char*)&waweChunkLength, 4);
|
||||
writestr("WAVEfmt ");
|
||||
outfile.write((char*) &fmtChunkLength, 4);
|
||||
outfile.write((char*) &compressionCode, 2);
|
||||
outfile.write((char*) &numberOfChannels, 2);
|
||||
outfile.write((char*) &sampleRate, 4);
|
||||
outfile.write((char*) &blockAlign, 4);
|
||||
outfile.write((char*) &significantBps, 2);
|
||||
outfile.write((char*) &extraFormatBytes, 2);
|
||||
writestr("data");
|
||||
outfile.write((char*) &byte_count,4);
|
||||
|
||||
for ( i_cursor = i_first_lsn; i_cursor <= i_last_lsn; i_cursor ++) {
|
||||
/* read a sector */
|
||||
int16_t *p_readbuf=paranoia_read(p, NULL);
|
||||
char *psz_err=cdda_errors(d);
|
||||
char *psz_mes=cdda_messages(d);
|
||||
|
||||
if (psz_mes || psz_err)
|
||||
cerr << psz_err << psz_mes;
|
||||
|
||||
if (psz_err) free(psz_err);
|
||||
if (psz_mes) free(psz_mes);
|
||||
if( !p_readbuf ) {
|
||||
cerr << "paranoia read error. Stopping.\n";
|
||||
break;
|
||||
}
|
||||
|
||||
char *temp= (char*) p_readbuf;
|
||||
outfile.write(temp, CDIO_CD_FRAMESIZE_RAW);
|
||||
|
||||
}
|
||||
}
|
||||
paranoia_free(p);
|
||||
}
|
||||
|
||||
cdda_close(d);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2005, 2008, 2009 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Simple program to show using libcdio's version of the CD-DA
|
||||
paranoia library. But in this version, we'll open a cdio object before
|
||||
calling paranoia's open. I imagine in many cases such as media
|
||||
players this may be what will be done since, one may want to get
|
||||
CDDB/CD-Text info beforehand. */
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#define __CDIO_CONFIG_H__ 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <cdio/cdda.h>
|
||||
#include <cdio/cd_types.h>
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
cdrom_drive_t *d = NULL; /* Place to store handle given by cd-paranoia. */
|
||||
char **ppsz_cd_drives; /* List of all drives with a loaded CDDA in it. */
|
||||
CdIo_t *p_cdio = NULL;
|
||||
|
||||
/* See if we can find a device with a loaded CD-DA in it. */
|
||||
ppsz_cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
|
||||
|
||||
if (ppsz_cd_drives) {
|
||||
/* Found such a CD-ROM with a CD-DA loaded. Use the first drive in
|
||||
the list. */
|
||||
p_cdio = cdio_open(*ppsz_cd_drives, DRIVER_UNKNOWN);
|
||||
d=cdio_cddap_identify_cdio(p_cdio, 1, NULL);
|
||||
} else {
|
||||
printf("Unable find or access a CD-ROM drive with an audio CD in it.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Don't need a list of CD's with CD-DA's any more. */
|
||||
cdio_free_device_list(ppsz_cd_drives);
|
||||
|
||||
if ( !d ) {
|
||||
printf("Unable to identify audio CD disc.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* We'll set for verbose paranoia messages. */
|
||||
cdio_cddap_verbose_set(d, CDDA_MESSAGE_PRINTIT, CDDA_MESSAGE_PRINTIT);
|
||||
|
||||
if ( 0 != cdio_cddap_open(d) ) {
|
||||
printf("Unable to open disc.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* In the paranoia example was a reading. Here we are going to do
|
||||
something trivial (but I think neat any way - get the Endian-ness
|
||||
of the drive. */
|
||||
{
|
||||
const int i_endian = data_bigendianp(d);
|
||||
switch (i_endian) {
|
||||
case 0:
|
||||
printf("Drive returns audio data Little Endian."
|
||||
" Your drive is like most.\n");
|
||||
break;
|
||||
case 1:
|
||||
printf("Drive returns audio data Big Endian.\n");
|
||||
break;
|
||||
case -1:
|
||||
printf("Don't know whether drive is Big or Little Endian.\n");
|
||||
break;
|
||||
default:
|
||||
printf("Whoah - got a return result I'm not expecting %d.\n",
|
||||
i_endian);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cdio_cddap_close_no_free_cdio(d);
|
||||
cdio_destroy( p_cdio );
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ udffile_DEPENDENCIES = $(LIBUDF_LIBS) $(LIBCDIO_DEPS)
|
||||
udffile_LDADD = $(LIBUDF_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
|
||||
|
||||
check_PROGRAMS = cdtext device drives \
|
||||
mmc1 mmc2 mmc2a mmc3 $(paranoia_progs) sample4
|
||||
mmc1 mmc2 mmc2a mmc3 sample4
|
||||
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ dist_libcdioinclude_HEADERS = \
|
||||
mmc_hl_cmds.h \
|
||||
mmc_ll_cmds.h \
|
||||
mmc_util.h \
|
||||
paranoia.h \
|
||||
posix.h \
|
||||
read.h \
|
||||
rock.h \
|
||||
@@ -57,8 +56,7 @@ dist_libcdioinclude_HEADERS = \
|
||||
utf8.h \
|
||||
util.h \
|
||||
version.h \
|
||||
xa.h \
|
||||
$(paranoiaheaders)
|
||||
xa.h
|
||||
|
||||
nodist_libcdioinclude_HEADERS = cdio_config.h
|
||||
|
||||
|
||||
@@ -176,13 +176,13 @@ libcdio_la_LDFLAGS = $(libcdio_la_ldflags) -Wl,--version-script=libcdio.la.ver
|
||||
libcdio_la_DEPENDENCIES = libcdio.la.ver
|
||||
|
||||
libcdio.la.ver: $(libcdio_la_OBJECTS) $(srcdir)/libcdio.sym
|
||||
echo 'CDIO_$(libcdio_la_MAJOR) { ' > $@
|
||||
objs=`for obj in $(libcdio_la_OBJECTS); do sed -ne "s/^pic_object='\(.*\)'$$/\1/p" $$obj; done`; \
|
||||
@echo 'CDIO_$(libcdio_la_MAJOR) { ' > $@
|
||||
@objs=`for obj in $(libcdio_la_OBJECTS); do sed -ne "s/^pic_object='\(.*\)'$$/\1/p" $$obj; done`; \
|
||||
if test -n "$${objs}" ; then \
|
||||
nm $${objs} | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libcdio.sym; then if test $$first = true; then echo " global:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@; \
|
||||
nm $${objs} | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libcdio.sym; then :; else if test $$first = true; then echo " local:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@; \
|
||||
fi
|
||||
echo '};' >> $@
|
||||
@echo '};' >> $@
|
||||
else
|
||||
libcdio_la_LDFLAGS = $(libcdio_la_ldflags)
|
||||
endif
|
||||
|
||||
@@ -22,9 +22,15 @@
|
||||
# define __CDIO_CONFIG_H__ 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <cdio/logging.h>
|
||||
#include "cdio_assert.h"
|
||||
|
||||
2
test/.gitignore
vendored
2
test/.gitignore
vendored
@@ -35,9 +35,7 @@
|
||||
/testlinux
|
||||
/testnrg
|
||||
/testnrg.c
|
||||
/testparanoia
|
||||
/testpregap
|
||||
/testpregap.c
|
||||
/testsolaris
|
||||
/testtoc
|
||||
/testunconfig
|
||||
|
||||
@@ -26,7 +26,7 @@ SUBDIRS = data driver
|
||||
|
||||
hack = check_sizeof testassert testgetdevices testischar \
|
||||
testisocd testisocd2 testiso9660 test_lib_driver_util \
|
||||
$(testparanoia) testpregap
|
||||
testpregap
|
||||
|
||||
EXTRA_PROGRAMS = testdefault
|
||||
DATA_DIR = @abs_top_srcdir@/test/data
|
||||
@@ -61,7 +61,6 @@ check_DATA = vcd_demo.right vcd_demo_vcdinfo.right \
|
||||
videocd.right \
|
||||
cdda.right \
|
||||
isofs-m1.right isofs-m1-no-rr.right \
|
||||
cd-paranoia-log.right \
|
||||
check_opts0.right check_opts1.right check_opts2.right \
|
||||
check_opts3.right check_opts4.right check_opts5.right \
|
||||
check_opts6.right check_opts7.right \
|
||||
@@ -92,12 +91,12 @@ test: check-am
|
||||
# learning any more of this awful system than I need to.
|
||||
check-am: make-executable
|
||||
make-executable: check_nrg.sh check_cue.sh
|
||||
chmod +x *.sh
|
||||
if test ! -f cdda.bin ; then \
|
||||
@chmod +x *.sh
|
||||
@if test ! -f cdda.bin ; then \
|
||||
test -L cdda.bin && $(RM) cdda.bin ; \
|
||||
$(LN_S) $(abs_top_srcdir)/test/data/cdda.bin cdda.bin ; \
|
||||
fi
|
||||
if test ! -f isofs-m1.bin ; then \
|
||||
@if test ! -f isofs-m1.bin ; then \
|
||||
test -L cdda.bin && $(RM) isofs-m1.bin ; \
|
||||
$(LN_S) $(abs_top_srcdir)/test/data/isofs-m1.bin isofs-m1.bin ; \
|
||||
fi
|
||||
|
||||
@@ -1,191 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2005, 2006, 2008, 2011 Rocky Bernstein <rocky@gnu.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Simple program to show using libcdio's version of cdparanoia. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
# define __CDIO_CONFIG_H__ 1
|
||||
#endif
|
||||
|
||||
#include <cdio/paranoia.h>
|
||||
#include <cdio/cd_types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define BIGENDIAN 1
|
||||
#else
|
||||
#define BIGENDIAN 0
|
||||
#endif
|
||||
|
||||
#define SKIP_TEST_RC 77
|
||||
|
||||
#define MAX_SECTORS 50
|
||||
static uint8_t audio_buf[MAX_SECTORS][CDIO_CD_FRAMESIZE_RAW] = { {0}, };
|
||||
static paranoia_cb_mode_t audio_status[MAX_SECTORS];
|
||||
static unsigned int i = 0;
|
||||
|
||||
static void
|
||||
callback(long int inpos, paranoia_cb_mode_t function)
|
||||
{
|
||||
audio_status[i] = function;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
cdrom_drive_t *d = NULL; /* Place to store handle given by cd-parapnioa. */
|
||||
driver_id_t driver_id;
|
||||
char **ppsz_cd_drives; /* List of all drives with a loaded CDDA in it. */
|
||||
int i_rc=0;
|
||||
|
||||
/* See if we can find a device with a loaded CD-DA in it. If successful
|
||||
drive_id will be set. */
|
||||
ppsz_cd_drives = cdio_get_devices_with_cap_ret(NULL, CDIO_FS_AUDIO, false,
|
||||
&driver_id);
|
||||
|
||||
if (ppsz_cd_drives && *ppsz_cd_drives) {
|
||||
/* Found such a CD-ROM with a CD-DA loaded. Use the first drive in
|
||||
the list. */
|
||||
d=cdda_identify(*ppsz_cd_drives, 1, NULL);
|
||||
} else {
|
||||
printf("Unable find or access a CD-ROM drive with an audio CD in it.\n");
|
||||
exit(SKIP_TEST_RC);
|
||||
}
|
||||
|
||||
/** We had a bug in is_device when driver_id == DRIVER_UNKNOWN or
|
||||
DRIVER_DEVICE. Let's make sure we've fixed that problem. **/
|
||||
if (!cdio_is_device(*ppsz_cd_drives, DRIVER_UNKNOWN) ||
|
||||
!cdio_is_device(*ppsz_cd_drives, DRIVER_DEVICE))
|
||||
exit(99);
|
||||
|
||||
/* Don't need a list of CD's with CD-DA's any more. */
|
||||
cdio_free_device_list(ppsz_cd_drives);
|
||||
|
||||
/* We'll set for verbose paranoia messages. */
|
||||
cdda_verbose_set(d, CDDA_MESSAGE_PRINTIT, CDDA_MESSAGE_PRINTIT);
|
||||
|
||||
if ( 0 != cdio_cddap_open(d) ) {
|
||||
printf("Unable to open disc.\n");
|
||||
exit(SKIP_TEST_RC);
|
||||
}
|
||||
|
||||
/* Okay now set up to read up to the first 300 frames of the first
|
||||
audio track of the Audio CD. */
|
||||
{
|
||||
cdrom_paranoia_t *p = paranoia_init(d);
|
||||
lsn_t i_first_lsn = cdda_disc_firstsector(d);
|
||||
|
||||
if ( -1 == i_first_lsn ) {
|
||||
printf("Trouble getting starting LSN\n");
|
||||
} else {
|
||||
lsn_t i_lsn; /* Current LSN to read */
|
||||
lsn_t i_last_lsn = cdda_disc_lastsector(d);
|
||||
unsigned int i_sectors = i_last_lsn - i_first_lsn + 1;
|
||||
unsigned int j;
|
||||
unsigned int i_good = 0;
|
||||
unsigned int i_bad = 0;
|
||||
|
||||
/* Set reading mode for full paranoia, but allow skipping sectors. */
|
||||
paranoia_modeset(p, PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP);
|
||||
|
||||
for ( j=0; j<10; j++ ) {
|
||||
|
||||
/* Pick a place to start reading. */
|
||||
i_lsn = i_first_lsn + (rand() % i_sectors);
|
||||
paranoia_seek(p, i_lsn, SEEK_SET);
|
||||
|
||||
printf("Testing %d sectors starting at %ld\n",
|
||||
MAX_SECTORS, (long int) i_lsn);
|
||||
for ( i = 0;
|
||||
i < MAX_SECTORS && i_lsn <= i_last_lsn;
|
||||
i++, i_lsn++ ) {
|
||||
/* read a sector */
|
||||
int16_t *p_readbuf = paranoia_read(p, callback);
|
||||
char *psz_err=cdio_cddap_errors(d);
|
||||
char *psz_mes=cdio_cddap_messages(d);
|
||||
|
||||
memcpy(audio_buf[i], p_readbuf, CDIO_CD_FRAMESIZE_RAW);
|
||||
|
||||
if (psz_mes || psz_err)
|
||||
printf("%s%s\n", psz_mes ? psz_mes: "", psz_err ? psz_err: "");
|
||||
|
||||
free(psz_err);
|
||||
free(psz_mes);
|
||||
if( !p_readbuf ) {
|
||||
printf("paranoia read error. Stopping.\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compare with the sectors from paranoia. */
|
||||
i_lsn -= MAX_SECTORS;
|
||||
for ( i = 0; i < MAX_SECTORS; i++, i_lsn++ ) {
|
||||
uint8_t readbuf[CDIO_CD_FRAMESIZE_RAW] = {0,};
|
||||
if ( PARANOIA_CB_READ == audio_status[i] ||
|
||||
PARANOIA_CB_VERIFY == audio_status[i] ) {
|
||||
/* We read the block via paranoia without an error. */
|
||||
|
||||
if ( 0 == cdio_read_audio_sector(d->p_cdio, readbuf, i_lsn) ) {
|
||||
if ( BIGENDIAN != d->bigendianp ) {
|
||||
/* We will compare in the slow, pedantic way*/
|
||||
int j;
|
||||
for (j=0; j < CDIO_CD_FRAMESIZE_RAW ; j +=2) {
|
||||
if (audio_buf[i][j] != readbuf[j+1] &&
|
||||
audio_buf[i][j+1] != readbuf[j] ) {
|
||||
printf("LSN %ld doesn't match\n", (long int) i_lsn);
|
||||
i_bad++;
|
||||
} else {
|
||||
i_good++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( 0 != memcmp(audio_buf[i], readbuf,
|
||||
CDIO_CD_FRAMESIZE_RAW) ) {
|
||||
printf("LSN %ld doesn't match\n", (long int) i_lsn);
|
||||
i_bad++;
|
||||
} else {
|
||||
i_good++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printf("Skipping LSN %ld because of status: %s\n",
|
||||
(long int) i_lsn, paranoia_cb_mode2str[audio_status[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%u sectors compared okay %u sectors were different\n",
|
||||
i_good, i_bad);
|
||||
if (i_bad > i_good) i_rc = 1;
|
||||
}
|
||||
out: paranoia_free(p);
|
||||
}
|
||||
|
||||
cdio_cddap_close(d);
|
||||
|
||||
exit(i_rc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user