aboutsummaryrefslogtreecommitdiffstats
path: root/audio/cdparanoia
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-01-10 09:06:33 +0800
committermdodd <mdodd@FreeBSD.org>2003-01-10 09:06:33 +0800
commit0c26d1a43d60b0d4d115683ed00365210ac0465a (patch)
tree2fb45e04a7d7a43b51971214a66f23b87208083f /audio/cdparanoia
parent1732549ee0de2d7cbba6b68d5c0bc6cd4a374f4b (diff)
downloadfreebsd-ports-graphics-0c26d1a43d60b0d4d115683ed00365210ac0465a.tar.gz
freebsd-ports-graphics-0c26d1a43d60b0d4d115683ed00365210ac0465a.tar.zst
freebsd-ports-graphics-0c26d1a43d60b0d4d115683ed00365210ac0465a.zip
A CDDA extraction tool (also known as ripper)
Submitted by: Simon 'corecode' Schubert <corecode@corecode.ath.cx>
Diffstat (limited to 'audio/cdparanoia')
-rw-r--r--audio/cdparanoia/Makefile30
-rw-r--r--audio/cdparanoia/distinfo1
-rw-r--r--audio/cdparanoia/files/patch-Makefile.in26
-rw-r--r--audio/cdparanoia/files/patch-configure16
-rw-r--r--audio/cdparanoia/files/patch-interface-Makefile.in33
-rw-r--r--audio/cdparanoia/files/patch-interface-cdda_interface.h57
-rw-r--r--audio/cdparanoia/files/patch-interface-common_interface.c71
-rw-r--r--audio/cdparanoia/files/patch-interface-cooked_interface.c172
-rw-r--r--audio/cdparanoia/files/patch-interface-interface.c34
-rw-r--r--audio/cdparanoia/files/patch-interface-low_interface.h55
-rw-r--r--audio/cdparanoia/files/patch-interface-scan_devices.c242
-rw-r--r--audio/cdparanoia/files/patch-interface-scsi_interface.c297
-rw-r--r--audio/cdparanoia/files/patch-interface-utils.h18
-rw-r--r--audio/cdparanoia/files/patch-paranoia-cdda_paranoia.h17
-rw-r--r--audio/cdparanoia/files/patch-utils.h18
-rw-r--r--audio/cdparanoia/pkg-comment1
-rw-r--r--audio/cdparanoia/pkg-descr13
-rw-r--r--audio/cdparanoia/pkg-plist12
18 files changed, 1113 insertions, 0 deletions
diff --git a/audio/cdparanoia/Makefile b/audio/cdparanoia/Makefile
new file mode 100644
index 00000000000..9fe60385f50
--- /dev/null
+++ b/audio/cdparanoia/Makefile
@@ -0,0 +1,30 @@
+# New ports collection makefile for: cdparanoia
+# Date created: 5 Jan 2003
+# Whom: Simon 'corecode' Schubert <corecode@corecode.ath.cx>
+#
+# $FreeBSD$
+#
+
+PORTNAME= cdparanoia
+PORTVERSION= 3.9.8
+CATEGORIES= audio sysutils
+MASTER_SITES= http://www.xiph.org/paranoia/download/
+DISTNAME= ${PORTNAME}-${PORTVERSION:C/^3\./III-alpha/}
+EXTRACT_SUFX= .src.tgz
+
+MAINTAINER= corecode@corecode.ath.cx
+
+CONFIGURE_ENV= CFLAGS="${CFLAGS} -I${LOCALBASE}/include" \
+ LDFLAGS="-L${LOCALBASE}/lib -lgnugetopt"
+
+.include <bsd.port.pre.mk>
+
+.if ${OSVERSION} < 500041
+LIB_DEPENDS= gnugetopt.1:${PORTSDIR}/devel/libgnugetopt
+.endif
+
+INSTALLS_SHLIB= yes
+GNU_CONFIGURE= yes
+USE_GMAKE= yes
+
+.include <bsd.port.post.mk>
diff --git a/audio/cdparanoia/distinfo b/audio/cdparanoia/distinfo
new file mode 100644
index 00000000000..a93b4e223b6
--- /dev/null
+++ b/audio/cdparanoia/distinfo
@@ -0,0 +1 @@
+MD5 (cdparanoia-III-alpha9.8.src.tgz) = 7218e778b5970a86c958e597f952f193
diff --git a/audio/cdparanoia/files/patch-Makefile.in b/audio/cdparanoia/files/patch-Makefile.in
new file mode 100644
index 00000000000..0d8f861bbeb
--- /dev/null
+++ b/audio/cdparanoia/files/patch-Makefile.in
@@ -0,0 +1,26 @@
+Index: Makefile.in
+===================================================================
+RCS file: /home/cvs/cdparanoia/Makefile.in,v
+retrieving revision 1.1.1.1
+retrieving revision 1.6
+diff -u -r1.1.1.1 -r1.6
+--- Makefile.in 2003/01/05 09:46:26 1.1.1.1
++++ Makefile.in 2003/01/05 13:15:44 1.6
+@@ -8,7 +8,7 @@
+ srcdir=@srcdir@
+
+ @SET_MAKE@
+-FLAGS=@TYPESIZES@ @CFLAGS@
++FLAGS=@TYPESIZES@ @CFLAGS@ -I./interface
+ OPT=@OPT@ $(FLAGS)
+ DEBUG=@DEBUG@ $(FLAGS)
+ CC=@CC@
+@@ -32,7 +32,7 @@
+
+ ifeq ($(STATIC),TRUE)
+ LIBS = interface/libcdda_interface.a paranoia/libcdda_paranoia.a \
+- -static -lm
++ -lm -lcam
+ LIBDEP = interface/libcdda_interface.a paranoia/libcdda_paranoia.a
+ else
+ LIBS = -lcdda_interface -lcdda_paranoia -lm
diff --git a/audio/cdparanoia/files/patch-configure b/audio/cdparanoia/files/patch-configure
new file mode 100644
index 00000000000..5b35c542df0
--- /dev/null
+++ b/audio/cdparanoia/files/patch-configure
@@ -0,0 +1,16 @@
+Index: configure
+===================================================================
+RCS file: /home/cvs/cdparanoia/configure,v
+retrieving revision 1.1.1.1
+retrieving revision 1.2
+diff -u -r1.1.1.1 -r1.2
+--- configure 2003/01/05 09:46:26 1.1.1.1
++++ configure 2003/01/05 12:41:47 1.2
+@@ -1084,7 +1084,6 @@
+ fi
+
+
+-CFLAGS=""
+
+ TYPESIZES=""
+
diff --git a/audio/cdparanoia/files/patch-interface-Makefile.in b/audio/cdparanoia/files/patch-interface-Makefile.in
new file mode 100644
index 00000000000..fa4badc07e7
--- /dev/null
+++ b/audio/cdparanoia/files/patch-interface-Makefile.in
@@ -0,0 +1,33 @@
+Index: interface/Makefile.in
+===================================================================
+RCS file: /home/cvs/cdparanoia/interface/Makefile.in,v
+retrieving revision 1.1.1.1
+retrieving revision 1.3
+diff -u -r1.1.1.1 -r1.3
+--- interface/Makefile.in 2003/01/05 09:46:26 1.1.1.1
++++ interface/Makefile.in 2003/01/05 12:03:46 1.3
+@@ -9,13 +9,13 @@
+ @SET_MAKE@
+ FLAGS=@SBPCD_H@ @UCDROM_H@ @TYPESIZES@ @CFLAGS@
+ OPT=@OPT@ $(FLAGS)
+-DEBUG=@DEBUG@ $(FLAGS) -DCDDA_TEST
++DEBUG=@DEBUG@ $(FLAGS)
+ CC=@CC@
+ LD=@CC@
+ LDFLAGS=@LDFLAGS@ $(FLAGS)
+ AR=@AR@
+ RANLIB=@RANLIB@
+-LIBS = -lm
++LIBS = -lm -lcam
+ CPPFLAGS+=-D_REENTRANT
+
+ OFILES = scan_devices.o common_interface.o cooked_interface.o interface.o\
+@@ -46,7 +46,7 @@
+ $(RANLIB) libcdda_interface.a
+
+ libcdda_interface.so: $(OFILES)
+- $(CC) -fpic -shared -o libcdda_interface.so.0.$(VERSION) -Wl,-soname -Wl,libcdda_interface.so.0 $(OFILES)
++ $(CC) -fpic -shared -o libcdda_interface.so.0.$(VERSION) -Wl,-soname -Wl,libcdda_interface.so.0 $(OFILES) ${LIBS}
+ [ -e libcdda_interface.so.0 ] || ln -s libcdda_interface.so.0.$(VERSION) libcdda_interface.so.0
+ [ -e libcdda_interface.so ] || ln -s libcdda_interface.so.0.$(VERSION) libcdda_interface.so
+
diff --git a/audio/cdparanoia/files/patch-interface-cdda_interface.h b/audio/cdparanoia/files/patch-interface-cdda_interface.h
new file mode 100644
index 00000000000..6dc527af7ff
--- /dev/null
+++ b/audio/cdparanoia/files/patch-interface-cdda_interface.h
@@ -0,0 +1,57 @@
+Index: interface/cdda_interface.h
+===================================================================
+RCS file: /home/cvs/cdparanoia/interface/cdda_interface.h,v
+retrieving revision 1.1.1.1
+retrieving revision 1.3
+diff -u -r1.1.1.1 -r1.3
+--- interface/cdda_interface.h 2003/01/05 09:46:26 1.1.1.1
++++ interface/cdda_interface.h 2003/01/06 21:26:23 1.3
+@@ -21,6 +21,11 @@
+ #include <sys/types.h>
+ #include <signal.h>
+
++#ifdef __FreeBSD__
++#include <stdio.h>
++#include <camlib.h>
++#endif
++
+ #define MAXTRK 100
+
+ typedef struct TOC { /* structure of table of contents */
+@@ -46,14 +51,20 @@
+
+ int opened; /* This struct may just represent a candidate for opening */
+
++#ifdef Linux
+ char *cdda_device_name;
+ char *ioctl_device_name;
+
+ int cdda_fd;
+- int ioctl_fd;
+
+- char *drive_model;
+ int drive_type;
++#elif defined(__FreeBSD__)
++ struct cam_device *dev;
++ union ccb *ccb;
++#endif
++
++ int ioctl_fd;
++ char *drive_model;
+ int interface;
+ int bigendianp;
+ int nsectors;
+@@ -83,9 +94,13 @@
+ int is_mmc;
+
+ /* SCSI command buffer and offset pointers */
++#ifdef Linux
+ unsigned char *sg;
+ unsigned char *sg_buffer;
+ unsigned char inqbytes[4];
++#elif defined(__FreeBSD__)
++ unsigned char *sg_buffer;
++#endif
+
+ /* Scsi parameters and state */
+ unsigned char density;
diff --git a/audio/cdparanoia/files/patch-interface-common_interface.c b/audio/cdparanoia/files/patch-interface-common_interface.c
new file mode 100644
index 00000000000..1248487506d
--- /dev/null
+++ b/audio/cdparanoia/files/patch-interface-common_interface.c
@@ -0,0 +1,71 @@
+Index: interface/common_interface.c
+===================================================================
+RCS file: /home/cvs/cdparanoia/interface/common_interface.c,v
+retrieving revision 1.1.1.1
+retrieving revision 1.5
+diff -u -r1.1.1.1 -r1.5
+--- interface/common_interface.c 2003/01/05 09:46:26 1.1.1.1
++++ interface/common_interface.c 2003/01/06 21:39:53 1.5
+@@ -13,12 +13,19 @@
+ #include "utils.h"
+ #include "smallft.h"
+
++#ifdef Linux
+ #include <linux/hdreg.h>
++#endif
+
+ /* Test for presence of a cdrom by pinging with the 'CDROMVOLREAD' ioctl() */
+ int ioctl_ping_cdrom(int fd){
++#ifdef Linux
+ struct cdrom_volctrl volctl;
+ if (ioctl(fd, CDROMVOLREAD, &volctl))
++#elif defined(__FreeBSD__)
++ struct ioc_vol volctl;
++ if (ioctl(fd, CDIOCGETVOL, &volctl))
++#endif
+ return(1); /* failure */
+
+ return(0);
+@@ -26,6 +33,7 @@
+ }
+
+
++#ifdef Linux
+ /* Use the ioctl thingy above ping the cdrom; this will get model info */
+ char *atapi_drive_info(int fd){
+ /* Work around the fact that the struct grew without warning in
+@@ -46,6 +54,7 @@
+ free(id);
+ return(ret);
+ }
++#endif
+
+ int data_bigendianp(cdrom_drive *d){
+ float lsb_votes=0;
+@@ -171,7 +180,9 @@
+ knows the leasoud/leadin size. */
+
+ int FixupTOC(cdrom_drive *d,int tracks){
++#ifdef Linux
+ struct cdrom_multisession ms_str;
++#endif
+ int j;
+
+ /* First off, make sure the 'starting sector' is >=0 */
+@@ -208,6 +219,8 @@
+ /* For a scsi device, the ioctl must go to the specialized SCSI
+ CDROM device, not the generic device. */
+
++ /* XXX */
++#ifdef Linux
+ if (d->ioctl_fd != -1) {
+ int result;
+
+@@ -231,6 +244,7 @@
+ return 1;
+ }
+ }
++#endif
+ return 0;
+ }
+
diff --git a/audio/cdparanoia/files/patch-interface-cooked_interface.c b/audio/cdparanoia/files/patch-interface-cooked_interface.c
new file mode 100644
index 00000000000..38066a31b55
--- /dev/null
+++ b/audio/cdparanoia/files/patch-interface-cooked_interface.c
@@ -0,0 +1,172 @@
+Index: interface/cooked_interface.c
+===================================================================
+RCS file: /home/cvs/cdparanoia/interface/cooked_interface.c,v
+retrieving revision 1.1.1.1
+retrieving revision 1.7
+diff -u -r1.1.1.1 -r1.7
+--- interface/cooked_interface.c 2003/01/05 09:46:26 1.1.1.1
++++ interface/cooked_interface.c 2003/01/07 00:49:01 1.7
+@@ -1,6 +1,8 @@
+ /******************************************************************
+ * CopyPolicy: GNU Public License 2 applies
+ * Copyright (C) Monty xiphmont@mit.edu
++ * FreeBSD porting (c) 2003
++ * Simon 'corecode' Schubert <corecode@corecode.ath.cx>
+ *
+ * CDROM code specific to the cooked ioctl interface
+ *
+@@ -10,6 +12,7 @@
+ #include "common_interface.h"
+ #include "utils.h"
+
++#ifdef Linux
+ static int cooked_readtoc (cdrom_drive *d){
+ int i;
+ int tracks;
+@@ -129,6 +132,128 @@
+ return(sectors);
+ }
+
++#elif defined(__FreeBSD__)
++static int
++cooked_readtoc(cdrom_drive *d)
++{
++ int i;
++ struct ioc_toc_header hdr;
++ struct ioc_read_toc_single_entry entry;
++
++ if (ioctl(d->ioctl_fd, CDIOREADTOCHEADER, &hdr) == -1) {
++ int ret;
++
++ if (errno == EPERM) {
++ ret = -102;
++ cderror(d, "102: ");
++ } else {
++ ret = -4;
++ cderror(d, "004: Unable to read table of contents header: ");
++ }
++ cderror(d, strerror(errno));
++ cderror(d, "\n");
++ return ret;
++ }
++
++ entry.address_format = CD_LBA_FORMAT;
++ for (i = hdr.starting_track; i <= hdr.ending_track; ++i) {
++ entry.track = i;
++
++ if (ioctl(d->ioctl_fd, CDIOREADTOCENTRY, &entry) == -1) {
++ cderror(d, "005: Unable to read table of contents entry\n");
++ return -5;
++ }
++
++ d->disc_toc[i - hdr.starting_track].bFlags = entry.entry.control;
++ d->disc_toc[i - hdr.starting_track].bTrack = entry.entry.track;
++ d->disc_toc[i - hdr.starting_track].dwStartSector = be32_to_cpu(entry.entry.addr.lba);
++ }
++
++ entry.track = 0xaa; /* leadout */
++
++ if (ioctl(d->ioctl_fd, CDIOREADTOCENTRY, &entry) == -1) {
++ cderror(d, "005: Unable to read table of contents entry\n");
++ return -5;
++ }
++
++ d->disc_toc[i - hdr.starting_track].bFlags = entry.entry.control;
++ d->disc_toc[i - hdr.starting_track].bTrack = entry.entry.track;
++ d->disc_toc[i - hdr.starting_track].dwStartSector = be32_to_cpu(entry.entry.addr.lba);
++
++ d->cd_extra = FixupTOC(d, hdr.ending_track - hdr.starting_track + 1);
++
++ return hdr.ending_track - hdr.starting_track;;
++}
++
++static int
++cooked_setspeed(cdrom_drive *d, int speed)
++{
++#ifdef CDRIOCREADSPEED
++ speed *= 177;
++ return ioctl(d->ioctl_fd, CDRIOCREADSPEED, &speed);
++#else
++ return -1;
++#endif
++}
++
++
++static long
++cooked_read(cdrom_drive *d, void *p, long begin, long sectors)
++{
++ int retry_count = 0;
++ struct ioc_read_audio arg;
++
++ if (sectors > d->nsectors)
++ sectors = d->nsectors;
++
++ arg.address_format = CD_LBA_FORMAT;
++ arg.address.lba = begin;
++ arg.buffer = p;
++
++ for (;;) {
++ arg.nframes = sectors;
++ if (ioctl(d->ioctl_fd, CDIOCREADAUDIO, &arg) == -1) {
++ if (!d->error_retry)
++ return -7;
++
++ switch (errno) {
++ case ENOMEM:
++ if (sectors == 1) {
++ cderror(d, "300: Kernel memory error\n");
++ return -300;
++ }
++ /* FALLTHROUGH */
++ default:
++ if (sectors == 1) {
++ if (retry_count > MAX_RETRIES - 1) {
++ char b[256];
++ snprintf(b, sizeof(b),
++ "010: Unable to access sector %ld; "
++ "skipping...\n", begin);
++ cderror(d, b);
++ return -10;
++ }
++ break;
++ }
++ }
++
++ if (retry_count > 4 && sectors > 1)
++ sectors = sectors * 3 / 4;
++
++ ++retry_count;
++
++ if (retry_count > MAX_RETRIES) {
++ cderror(d, "007: Unknown, unrecoverable error reading data\n");
++ return -7;
++ }
++ } else
++ break;
++ }
++
++ return sectors;
++}
++#endif
++
+ /* hook */
+ static int Dummy (cdrom_drive *d,int Switch){
+ return(0);
+@@ -193,6 +318,7 @@
+ int cooked_init_drive (cdrom_drive *d){
+ int ret;
+
++#ifdef Linux
+ switch(d->drive_type){
+ case MATSUSHITA_CDROM_MAJOR: /* sbpcd 1 */
+ case MATSUSHITA_CDROM2_MAJOR: /* sbpcd 2 */
+@@ -243,6 +369,9 @@
+ default:
+ d->nsectors=40;
+ }
++#elif defined(__FreeBSD__)
++ d->nsectors = 26; /* FreeBSD only support 64K I/O transfer size */
++#endif
+ d->enable_cdda = Dummy;
+ d->read_audio = cooked_read;
+ d->set_speed = cooked_setspeed;
diff --git a/audio/cdparanoia/files/patch-interface-interface.c b/audio/cdparanoia/files/patch-interface-interface.c
new file mode 100644
index 00000000000..f1f4cdf72a2
--- /dev/null
+++ b/audio/cdparanoia/files/patch-interface-interface.c
@@ -0,0 +1,34 @@
+Index: interface/interface.c
+===================================================================
+RCS file: /home/cvs/cdparanoia/interface/interface.c,v
+retrieving revision 1.1.1.1
+retrieving revision 1.3
+diff -u -r1.1.1.1 -r1.3
+--- interface/interface.c 2003/01/05 09:46:26 1.1.1.1
++++ interface/interface.c 2003/01/06 21:26:23 1.3
+@@ -29,12 +29,25 @@
+ d->enable_cdda(d,0);
+
+ _clean_messages(d);
++#ifdef Linux
+ if(d->cdda_device_name)free(d->cdda_device_name);
+ if(d->ioctl_device_name)free(d->ioctl_device_name);
+ if(d->drive_model)free(d->drive_model);
+ if(d->cdda_fd!=-1)close(d->cdda_fd);
+ if(d->ioctl_fd!=-1 && d->ioctl_fd!=d->cdda_fd)close(d->ioctl_fd);
+ if(d->sg)free(d->sg);
++#elif defined(__FreeBSD__)
++ if (d->drive_model)
++ free(d->drive_model);
++ if (d->ccb)
++ cam_freeccb(d->ccb);
++ if (d->dev)
++ cam_close_device(d->dev);
++ if (d->sg_buffer)
++ free(d->sg_buffer);
++ if (d->ioctl_fd != -1)
++ close(d->ioctl_fd);
++#endif
+
+ free(d);
+ }
diff --git a/audio/cdparanoia/files/patch-interface-low_interface.h b/audio/cdparanoia/files/patch-interface-low_interface.h
new file mode 100644
index 00000000000..1ad09f12b69
--- /dev/null
+++ b/audio/cdparanoia/files/patch-interface-low_interface.h
@@ -0,0 +1,55 @@
+Index: interface/low_interface.h
+===================================================================
+RCS file: /home/cvs/cdparanoia/interface/low_interface.h,v
+retrieving revision 1.1.1.1
+retrieving revision 1.3
+diff -u -r1.1.1.1 -r1.3
+--- interface/low_interface.h 2003/01/05 09:46:26 1.1.1.1
++++ interface/low_interface.h 2003/01/06 21:26:23 1.3
+@@ -25,6 +25,8 @@
+ #include <sys/time.h>
+ #include <sys/types.h>
+
++#ifdef Linux
++
+ #include <linux/major.h>
+ #include <linux/version.h>
+
+@@ -48,12 +50,27 @@
+ #include <linux/cdrom.h>
+ #include <linux/major.h>
+
++#elif defined(__FreeBSD__)
++
++#include <sys/cdio.h>
++#include <sys/cdrio.h>
++
++#include <cam/scsi/scsi_message.h>
++#include <camlib.h>
++
++#endif
++
+ #include "cdda_interface.h"
+
+ #define MAX_RETRIES 8
+ #define MAX_BIG_BUFF_SIZE 65536
+ #define MIN_BIG_BUFF_SIZE 4096
++
++#ifdef Linux
+ #define SG_OFF sizeof(struct sg_header)
++#else
++#define SG_OFF (0)
++#endif
+
+ #ifndef SG_EMULATED_HOST
+ /* old kernel version; the check for the ioctl is still runtime, this
+@@ -64,7 +81,9 @@
+ #endif
+
+ extern int cooked_init_drive (cdrom_drive *d);
++#ifdef Linux
+ extern unsigned char *scsi_inquiry (cdrom_drive *d);
++#endif
+ extern int scsi_init_drive (cdrom_drive *d);
+ #ifdef CDDA_TEST
+ extern int test_init_drive (cdrom_drive *d);
diff --git a/audio/cdparanoia/files/patch-interface-scan_devices.c b/audio/cdparanoia/files/patch-interface-scan_devices.c
new file mode 100644
index 00000000000..e90699d6bf0
--- /dev/null
+++ b/audio/cdparanoia/files/patch-interface-scan_devices.c
@@ -0,0 +1,242 @@
+Index: interface/scan_devices.c
+===================================================================
+RCS file: /home/cvs/cdparanoia/interface/scan_devices.c,v
+retrieving revision 1.1.1.1
+retrieving revision 1.10
+diff -u -r1.1.1.1 -r1.10
+--- interface/scan_devices.c 2003/01/05 09:46:26 1.1.1.1
++++ interface/scan_devices.c 2003/01/07 00:49:01 1.10
+@@ -1,6 +1,8 @@
+ /******************************************************************
+ * CopyPolicy: GNU Public License 2 applies
+ * Copyright (C) 1998 Monty xiphmont@mit.edu
++ * FreeBSD porting (c) 2003
++ * Simon 'corecode' Schubert <corecode@corecode.ath.cx>
+ *
+ * Autoscan for or verify presence of a cdrom device
+ *
+@@ -21,6 +23,8 @@
+
+ #define MAX_DEV_LEN 20 /* Safe because strings only come from below */
+ /* must be absolute paths! */
++
++#ifdef Linux
+ static char *scsi_cdrom_prefixes[]={
+ "/dev/scd",
+ "/dev/sr",
+@@ -49,6 +53,13 @@
+ "/dev/cm206cd",
+ "/dev/gscd",
+ "/dev/optcd",NULL};
++#elif defined(__FreeBSD__)
++static char *cdrom_devices[] = {
++ "/dev/cd?c",
++ "/dev/acd?c",
++ "/dev/wcd?c",
++ "/dev/mcd?c", NULL};
++#endif
+
+ /* Functions here look for a cdrom drive; full init of a drive type
+ happens in interface.c */
+@@ -75,10 +86,12 @@
+ if((d=cdda_identify(buffer,messagedest,messages)))
+ return(d);
+ idmessage(messagedest,messages,"",NULL);
++#ifdef Linux
+ buffer[pos-(cdrom_devices[i])]=j+97;
+ if((d=cdda_identify(buffer,messagedest,messages)))
+ return(d);
+ idmessage(messagedest,messages,"",NULL);
++#endif
+ }
+ }else{
+ /* Name. Go for it. */
+@@ -117,8 +130,14 @@
+ }
+ #endif
+
++#ifdef Linux /* is order of checks important? */
+ d=cdda_identify_cooked(device,messagedest,messages);
+ if(!d)d=cdda_identify_scsi(device,NULL,messagedest,messages);
++#elif defined(__FreeBSD__)
++ d = cdda_identify_scsi(device, NULL, messagedest, messages);
++ if (d == NULL)
++ d = cdda_identify_cooked(device, messagedest, messages);
++#endif
+
+ #ifdef CDDA_TEST
+ if(!d)d=cdda_identify_test(device,messagedest,messages);
+@@ -143,6 +162,7 @@
+
+ }
+
++#ifdef Linux
+ cdrom_drive *cdda_identify_cooked(const char *dev, int messagedest,
+ char **messages){
+
+@@ -275,6 +295,60 @@
+ return(d);
+ }
+
++#elif defined(__FreeBSD__)
++cdrom_drive *
++cdda_identify_cooked(const char *dev, int messagedest, char **messages)
++{
++ cdrom_drive *d;
++ struct stat st;
++
++ if (stat(dev, &st)) {
++ idperror(messagedest, messages, "\t\tCould not stat %s", dev);
++ return NULL;
++ }
++
++ if (!S_ISCHR(st.st_mode)) {
++ idmessage(messagedest, messages, "\t\t%s is no block device", dev);
++ return NULL;
++ }
++
++ if ((d = calloc(1, sizeof(*d))) == NULL) {
++ idperror(messagedest, messages, "\t\tCould not allocate memory", NULL);
++ return NULL;
++ }
++ d->ioctl_fd = -1;
++
++ if ((d->ioctl_fd = open(dev, O_RDONLY)) == -1) {
++ idperror(messagedest, messages, "\t\tCould not open %s", dev);
++ goto cdda_identify_cooked_fail;
++ }
++
++ if (ioctl_ping_cdrom(d->ioctl_fd)) {
++ idmessage(messagedest, messages, "\t\tDevice %s is not a CDROM", dev);
++ goto cdda_identify_cooked_fail;
++ }
++
++ d->drive_model = copystring("Generic cooked ioctl CDROM");
++ d->interface = COOKED_IOCTL;
++ d->bigendianp = -1;
++ d->nsectors = -1;
++
++ idmessage(messagedest, messages, "\t\tCDROM sensed: %s\n", d->drive_model);
++
++ return d;
++
++cdda_identify_cooked_fail:
++ if (d != NULL) {
++ if (d->ioctl_fd != -1)
++ close(d->ioctl_fd);
++ free(d);
++ }
++ return NULL;
++}
++#endif
++
++
++#ifdef Linux
+ struct sg_id {
+ long l1; /* target | lun << 8 | channel << 16 | low_ino << 24 */
+ long l2; /* Unique id */
+@@ -390,6 +464,7 @@
+ if(dev!=-1)close(dev);
+ return(NULL);
+ }
++#endif
+
+ void strscat(char *a,char *b,int n){
+ int i;
+@@ -401,6 +476,7 @@
+ strcat(a," ");
+ }
+
++#ifdef Linux
+ /* At this point, we're going to punt compatability before SG2, and
+ allow only SG2 and SG3 */
+ static int verify_SG_version(cdrom_drive *d,int messagedest,
+@@ -653,6 +729,88 @@
+ if(g_fd!=-1)close(g_fd);
+ return(NULL);
+ }
++#elif defined(__FreeBSD__)
++
++cdrom_drive *cdda_identify_scsi(const char *device,
++ const char *dummy,
++ int messagedest,
++ char **messages)
++{
++ char *devname;
++ cdrom_drive *d = NULL;
++
++ if (device == NULL) {
++ idperror(messagedest, messages, "\t\tNo device specified", NULL);
++ return NULL;
++ }
++
++ if ((devname = test_resolve_symlink(device, messagedest, messages)) == NULL)
++ return NULL;
++
++ if ((d = calloc(1, sizeof(*d))) == NULL) {
++ idperror(messagedest, messages, "\t\tCould not allocate memory", NULL);
++ free(devname);
++ return NULL;
++ }
++
++ if ((d->dev = cam_open_device(devname, O_RDWR)) == NULL) {
++ idperror(messagedest, messages, "\t\tCould not open SCSI device: %s", cam_errbuf);
++ goto cdda_identify_scsi_fail;
++ }
++
++ if ((d->ccb = cam_getccb(d->dev)) == NULL) {
++ idperror(messagedest, messages, "\t\tCould not allocate ccb", NULL);
++ goto cdda_identify_scsi_fail;
++ }
++
++ if (strncmp(d->dev->inq_data.vendor, "TOSHIBA", 7) == 0 &&
++ strncmp(d->dev->inq_data.product, "CD_ROM", 6) == 0 &&
++ SID_TYPE(&d->dev->inq_data) == T_DIRECT) {
++ d->dev->inq_data.device = T_CDROM;
++ d->dev->inq_data.dev_qual2 |= 0x80;
++ }
++
++ if (SID_TYPE(&d->dev->inq_data) != T_CDROM &&
++ SID_TYPE(&d->dev->inq_data) != T_WORM) {
++ idmessage(messagedest, messages,
++ "\t\tDevice is neither a CDROM nor a WORM device\n", NULL);
++ goto cdda_identify_scsi_fail;
++ }
++
++ d->ioctl_fd = -1;
++ d->bigendianp = -1;
++ d->nsectors = -1;
++ d->lun = d->dev->target_lun;
++ d->interface = GENERIC_SCSI;
++
++ if ((d->sg_buffer = malloc(MAX_BIG_BUFF_SIZE)) == NULL) {
++ idperror(messagedest, messages, "Could not allocate buffer memory", NULL);
++ goto cdda_identify_scsi_fail;
++ }
++
++ if ((d->drive_model = calloc(36,1)) == NULL) {
++ }
++
++ strscat(d->drive_model, d->dev->inq_data.vendor, SID_VENDOR_SIZE);
++ strscat(d->drive_model, d->dev->inq_data.product, SID_PRODUCT_SIZE);
++ strscat(d->drive_model, d->dev->inq_data.revision, SID_REVISION_SIZE);
++
++ idmessage(messagedest, messages, "\nCDROM model sensed: %s", d->drive_model);
++
++ return d;
++
++cdda_identify_scsi_fail:
++ free(devname);
++ if (d) {
++ if (d->ccb)
++ cam_freeccb(d->ccb);
++ if (d->dev)
++ cam_close_device(d->dev);
++ free(d);
++ }
++ return NULL;
++}
++#endif
+
+ #ifdef CDDA_TEST
+
diff --git a/audio/cdparanoia/files/patch-interface-scsi_interface.c b/audio/cdparanoia/files/patch-interface-scsi_interface.c
new file mode 100644
index 00000000000..146552e3c76
--- /dev/null
+++ b/audio/cdparanoia/files/patch-interface-scsi_interface.c
@@ -0,0 +1,297 @@
+Index: interface/scsi_interface.c
+===================================================================
+RCS file: /home/cvs/cdparanoia/interface/scsi_interface.c,v
+retrieving revision 1.1.1.1
+retrieving revision 1.6
+diff -u -r1.1.1.1 -r1.6
+--- interface/scsi_interface.c 2003/01/05 09:46:26 1.1.1.1
++++ interface/scsi_interface.c 2003/01/07 00:49:01 1.6
+@@ -3,6 +3,8 @@
+ * Original interface.c Copyright (C) 1994-1997
+ * Eissfeldt heiko@colossus.escape.de
+ * Current blenderization Copyright (C) 1998-1999 Monty xiphmont@mit.edu
++ * FreeBSD porting (c) 2003
++ * Simon 'corecode' Schubert <corecode@corecode.ath.cx>
+ *
+ * Generic SCSI interface specific code.
+ *
+@@ -23,6 +25,7 @@
+ int table,reserved;
+ char buffer[256];
+
++#ifdef Linux
+ /* maximum transfer size? */
+ if(ioctl(d->cdda_fd,SG_GET_RESERVED_SIZE,&reserved)){
+ /* Up, guess not. */
+@@ -59,8 +62,17 @@
+ cdmessage(d,"\tCouldn't disable command queue! Continuing anyway...\n");
+ }
+
++#elif defined(__FreeBSD__)
++ d->nsectors = 26; /* FreeBSD only supports 64K I/O transfer size */
++ d->bigbuff = d->nsectors * CD_FRAMESIZE_RAW;
++
++ sprintf(buffer,"\tSetting default read size to %d sectors (%d bytes).\n\n",
++ d->nsectors,d->nsectors*CD_FRAMESIZE_RAW);
++ cdmessage(d,buffer);
++#endif
+ }
+
++#ifdef Linux
+ static void reset_scsi(cdrom_drive *d){
+ int arg;
+ d->enable_cdda(d,0);
+@@ -74,6 +86,30 @@
+ d->enable_cdda(d,1);
+ }
+
++#elif defined(__FreeBSD__)
++static void reset_scsi(cdrom_drive *d) {
++ d->enable_cdda(d,0);
++
++ d->ccb->ccb_h.func_code = XPT_RESET_DEV;
++ d->ccb->ccb_h.timeout = 5000;
++
++ cdmessage(d, "sending SCSI reset... ");
++ if (cam_send_ccb(d->dev, d->ccb)) {
++ cdmessage(d, "error sending XPT_RESET_DEV CCB");
++ } else {
++
++ if (((d->ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) ||
++ ((d->ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_BDR_SENT))
++ cdmessage(d,"OK\n");
++ else
++ cdmessage(d,"FAILED\n");
++ }
++
++ d->enable_cdda(d,1);
++}
++#endif
++
++#ifdef Linux
+ static void clear_garbage(cdrom_drive *d){
+ fd_set fdset;
+ struct timeval tv;
+@@ -104,8 +140,10 @@
+ flag=1;
+ }
+ }
++#endif
+
+ /* process a complete scsi command. */
++#ifdef Linux
+ static int handle_scsi_cmd(cdrom_drive *d,
+ unsigned int cmd_len,
+ unsigned int in_size,
+@@ -284,6 +322,83 @@
+ return(0);
+ }
+
++#elif defined(__FreeBSD__)
++static int handle_scsi_cmd(cdrom_drive *d,
++ unsigned int cmd_len,
++ unsigned int out_size,
++ unsigned int in_size,
++
++ unsigned char bytefill,
++ int bytecheck) {
++ int result;
++
++ bzero(&d->ccb->csio, sizeof(d->ccb->csio));
++
++ memcpy(d->ccb->csio.cdb_io.cdb_bytes, d->sg_buffer, cmd_len);
++ cam_fill_csio(&d->ccb->csio,
++ /* retries */ 3, /* XXX */
++ /* cbfcnp */ NULL,
++ /* flags */ CAM_PASS_ERR_RECOVER | CAM_DEV_QFRZDIS |
++ (out_size ? CAM_DIR_OUT : CAM_DIR_IN),
++ /* tag_action */ MSG_SIMPLE_Q_TAG,
++ /* data_ptr */ out_size ? d->sg_buffer + cmd_len : d->sg_buffer,
++ /* dxfer_len */ out_size ? out_size : in_size,
++ /* sense_len */ SSD_FULL_SIZE,
++ /* cdb_len */ cmd_len,
++ /* timeout */ 60000); /* XXX */
++
++ if ((result = cam_send_ccb(d->dev, d->ccb)) < 0)
++ return TR_EREAD;
++
++ if ((d->ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
++ fprintf (stderr, "error returned from SCSI command:\n");
++ if ((d->ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_SCSI_STATUS_ERROR)
++ scsi_sense_print (d->dev, &d->ccb->csio, stderr);
++ else
++ fprintf (stderr, "ccb->ccb_h.status == %d\n", d->ccb->ccb_h.status);
++ errno = EIO;
++ return TR_UNKNOWN;
++ }
++
++ if (d->ccb->csio.dxfer_len != in_size) {
++ errno = EIO;
++ return TR_EREAD;
++ }
++
++ if (d->ccb->csio.sense_data.error_code & SSD_ERRCODE) {
++ switch (d->ccb->csio.sense_data.flags & SSD_KEY) {
++ case SSD_KEY_NO_SENSE:
++ errno = EIO;
++ return TR_UNKNOWN;
++ case SSD_KEY_RECOVERED_ERROR:
++ break;
++ case SSD_KEY_NOT_READY:
++ errno = EBUSY;
++ return TR_BUSY;
++ case SSD_KEY_MEDIUM_ERROR:
++ errno = EIO;
++ if (d->ccb->csio.sense_data.add_sense_code == 0x0c &&
++ d->ccb->csio.sense_data.add_sense_code_qual == 0x09)
++ return TR_STREAMING;
++ else
++ return TR_MEDIUM;
++ case SSD_KEY_HARDWARE_ERROR:
++ errno = EIO;
++ return TR_FAULT;
++ case SSD_KEY_ILLEGAL_REQUEST:
++ errno = EINVAL;
++ return TR_ILLEGAL;
++ default:
++ errno = EIO;
++ return TR_UNKNOWN;
++ }
++ }
++
++ return 0;
++}
++#endif
++
++
+ /* Group 1 (10b) command */
+
+ static int mode_sense_atapi(cdrom_drive *d,int size,int page){
+@@ -833,30 +948,33 @@
+ while(1) {
+ if((err=map(d,(p?buffer:NULL),begin,sectors))){
+ if(d->report_all){
++#ifdef Linux
+ struct sg_header *sg_hd=(struct sg_header *)d->sg;
++#endif
+ char b[256];
+
+ sprintf(b,"scsi_read error: sector=%ld length=%ld retry=%d\n",
+ begin,sectors,retry_count);
++ fputs(b, stderr);
+ cdmessage(d,b);
+ sprintf(b," Sense key: %x ASC: %x ASCQ: %x\n",
++#ifdef Linux
+ (int)(sg_hd->sense_buffer[2]&0xf),
+ (int)(sg_hd->sense_buffer[12]),
+ (int)(sg_hd->sense_buffer[13]));
++#elif defined(__FreeBSD__)
++ d->ccb->csio.sense_data.flags & SSD_KEY,
++ d->ccb->csio.sense_data.add_sense_code,
++ d->ccb->csio.sense_data.add_sense_code_qual);
++#endif
++ fputs(b, stderr);
+ cdmessage(d,b);
+ sprintf(b," Transport error: %s\n",strerror_tr[err]);
++ fputs(b, stderr);
+ cdmessage(d,b);
+ sprintf(b," System error: %s\n",strerror(errno));
++ fputs(b, stderr);
+ cdmessage(d,b);
+-
+- fprintf(stderr,"scsi_read error: sector=%ld length=%ld retry=%d\n",
+- begin,sectors,retry_count);
+- fprintf(stderr," Sense key: %x ASC: %x ASCQ: %x\n",
+- (int)(sg_hd->sense_buffer[2]&0xf),
+- (int)(sg_hd->sense_buffer[12]),
+- (int)(sg_hd->sense_buffer[13]));
+- fprintf(stderr," Transport error: %s\n",strerror_tr[err]);
+- fprintf(stderr," System error: %s\n",strerror(errno));
+ }
+
+ if(!d->error_retry)return(-7);
+@@ -1307,6 +1425,7 @@
+ return;
+ }
+
++#ifdef Linux
+ static int check_atapi(cdrom_drive *d){
+ int atapiret=-1;
+ int fd = d->cdda_fd; /* this is the correct fd (not ioctl_fd), as the
+@@ -1333,6 +1452,47 @@
+ }
+ }
+
++#elif defined(__FreeBSD__)
++static int
++check_atapi(cdrom_drive *d)
++{
++ bzero(&(&d->ccb->ccb_h)[1], sizeof(d->ccb->cpi) - sizeof(d->ccb->ccb_h));
++
++ d->ccb->ccb_h.func_code = XPT_PATH_INQ;
++
++ cdmessage(d, "\nChecking for ATAPICAM...\n");
++
++ if (cam_send_ccb(d->dev, d->ccb) < 0) {
++ cderror(d, "\terror sending XPT_PATH_INQ CCB: ");
++ cderror(d, cam_errbuf);
++ cderror(d, "\n");
++ return -1;
++ }
++
++ if ((d->ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
++ cderror(d, "\tXPT_PATH_INQ CCB failed: ");
++ cderror(d, cam_errbuf);
++ cderror(d, "\n");
++ return -1;
++ }
++
++ /*
++ * if the bus device name is `ata', we're (obviously)
++ * running ATAPICAM.
++ */
++
++ if (strncmp(d->ccb->cpi.dev_name, "ata", 3) == 0) {
++ cdmessage(d, "\tDrive is ATAPI (using ATAPICAM)\n");
++ d->is_atapi = 1;
++ } else {
++ cdmessage(d, "\tDrive is SCSI\n");
++ d->is_atapi = 0;
++ }
++
++ return d->is_atapi;
++}
++#endif
++
+ static int check_mmc(cdrom_drive *d){
+ char *b;
+ cdmessage(d,"\nChecking for MMC style command set...\n");
+@@ -1379,6 +1539,7 @@
+ }
+ }
+
++#ifdef Linux
+ /* request vendor brand and model */
+ unsigned char *scsi_inquiry(cdrom_drive *d){
+ memcpy(d->sg_buffer,(char[]){ 0x12,0,0,0,56,0},6);
+@@ -1389,6 +1550,7 @@
+ }
+ return (d->sg_buffer);
+ }
++#endif
+
+
+ int scsi_init_drive(cdrom_drive *d){
+@@ -1458,8 +1620,12 @@
+ check_fua_bit(d);
+
+ d->error_retry=1;
++#ifdef Linux
+ d->sg=realloc(d->sg,d->nsectors*CD_FRAMESIZE_RAW + SG_OFF + 128);
+ d->sg_buffer=d->sg+SG_OFF;
++#elif defined(__FreeBSD__)
++ d->sg_buffer = realloc(d->sg_buffer, d->nsectors * CD_FRAMESIZE_RAW);
++#endif
+ d->report_all=1;
+ return(0);
+ }
diff --git a/audio/cdparanoia/files/patch-interface-utils.h b/audio/cdparanoia/files/patch-interface-utils.h
new file mode 100644
index 00000000000..49b0b57289c
--- /dev/null
+++ b/audio/cdparanoia/files/patch-interface-utils.h
@@ -0,0 +1,18 @@
+Index: interface/utils.h
+===================================================================
+RCS file: /home/cvs/cdparanoia/interface/utils.h,v
+retrieving revision 1.1.1.1
+retrieving revision 1.3
+diff -u -r1.1.1.1 -r1.3
+--- interface/utils.h 2003/01/05 09:46:26 1.1.1.1
++++ interface/utils.h 2003/01/06 23:34:21 1.3
+@@ -1,4 +1,9 @@
++#ifdef LINUX
+ #include <endian.h>
++#elif defined(__FreeBSD__)
++#include <machine/endian.h>
++#endif
++
+ #include <stdio.h>
+ #include <errno.h>
+ #include <string.h>
diff --git a/audio/cdparanoia/files/patch-paranoia-cdda_paranoia.h b/audio/cdparanoia/files/patch-paranoia-cdda_paranoia.h
new file mode 100644
index 00000000000..3d32c9f6982
--- /dev/null
+++ b/audio/cdparanoia/files/patch-paranoia-cdda_paranoia.h
@@ -0,0 +1,17 @@
+Index: paranoia/cdda_paranoia.h
+===================================================================
+RCS file: /home/cvs/cdparanoia/paranoia/cdda_paranoia.h,v
+retrieving revision 1.1.1.1
+retrieving revision 1.2
+diff -u -r1.1.1.1 -r1.2
+--- paranoia/cdda_paranoia.h 2003/01/05 09:46:26 1.1.1.1
++++ paranoia/cdda_paranoia.h 2003/01/05 12:55:20 1.2
+@@ -34,6 +34,8 @@
+ #define PARANOIA_MODE_NEVERSKIP 32
+
+ #ifndef CDP_COMPILE
++#include <cdda_interface.h>
++
+ typedef void cdrom_paranoia;
+ #endif
+
diff --git a/audio/cdparanoia/files/patch-utils.h b/audio/cdparanoia/files/patch-utils.h
new file mode 100644
index 00000000000..3a1f6796814
--- /dev/null
+++ b/audio/cdparanoia/files/patch-utils.h
@@ -0,0 +1,18 @@
+Index: utils.h
+===================================================================
+RCS file: /home/cvs/cdparanoia/utils.h,v
+retrieving revision 1.1.1.1
+retrieving revision 1.3
+diff -u -r1.1.1.1 -r1.3
+--- utils.h 2003/01/05 09:46:26 1.1.1.1
++++ utils.h 2003/01/06 23:34:21 1.3
+@@ -1,5 +1,9 @@
+ #include <stdlib.h>
++#ifdef Linux
+ #include <endian.h>
++#elif defined(__FreeBSD__)
++#include <machine/endian.h>
++#endif
+ #include <stdio.h>
+ #include <errno.h>
+ #include <string.h>
diff --git a/audio/cdparanoia/pkg-comment b/audio/cdparanoia/pkg-comment
new file mode 100644
index 00000000000..105d9a44000
--- /dev/null
+++ b/audio/cdparanoia/pkg-comment
@@ -0,0 +1 @@
+A CDDA extraction tool (also known as ripper)
diff --git a/audio/cdparanoia/pkg-descr b/audio/cdparanoia/pkg-descr
new file mode 100644
index 00000000000..28d0cbb4a4a
--- /dev/null
+++ b/audio/cdparanoia/pkg-descr
@@ -0,0 +1,13 @@
+Cdparanoia is a Compact Disc Digital Audio (CDDA) extraction tool,
+commonly known on the net as a 'ripper'.
+Cdparanoia is a bit different than most other CDDA extration tools. It
+contains few-to-no 'extra' features, concentrating only on the ripping
+process and knowing as much as possible about the hardware performing
+it. Cdparanoia will read correct, rock-solid audio data from inexpensive
+drives prone to misalignment, frame jitter and loss of streaming during
+atomic reads. Cdparanoia will also read and repair data from CDs that
+have been damaged in some way.
+
+WWW: http://www.xiph.org/paranoia/
+
+- Simon 'corecode' Schubert
diff --git a/audio/cdparanoia/pkg-plist b/audio/cdparanoia/pkg-plist
new file mode 100644
index 00000000000..ec36e1f91f4
--- /dev/null
+++ b/audio/cdparanoia/pkg-plist
@@ -0,0 +1,12 @@
+bin/cdparanoia
+include/cdda_interface.h
+include/cdda_paranoia.h
+include/utils.h
+lib/libcdda_interface.a
+lib/libcdda_interface.so
+lib/libcdda_interface.so.0
+lib/libcdda_interface.so.0.9.8
+lib/libcdda_paranoia.a
+lib/libcdda_paranoia.so
+lib/libcdda_paranoia.so.0
+lib/libcdda_paranoia.so.0.9.8