[51693] trunk/dports/audio/cdparanoia
jeremyhu at macports.org
jeremyhu at macports.org
Sun May 31 14:00:55 PDT 2009
Revision: 51693
http://trac.macports.org/changeset/51693
Author: jeremyhu at macports.org
Date: 2009-05-31 14:00:54 -0700 (Sun, 31 May 2009)
Log Message:
-----------
cdparanoia: Updated to version 10.2
I integrated the osx_interface changes that were in the osx version of paranoia (0.9.8) into 10.2 from upstream.
This version has but ignores the '-d' command line option since many rippers (eg abcde) expect that option.
*someone* should eventually add support for this option to choose which drive to rip from, but that someone is not me.
There is a ton of ifdef-fu based on __APPLE__ to determine if cdparanoia builds for linux or darwin.
Modified Paths:
--------------
trunk/dports/audio/cdparanoia/Portfile
Added Paths:
-----------
trunk/dports/audio/cdparanoia/files/osx_interface.patch
Removed Paths:
-------------
trunk/dports/audio/cdparanoia/files/patch-include-cdparanoia-paranoia-p_block.h
trunk/dports/audio/cdparanoia/files/patch-interface-osx_interface.c
Modified: trunk/dports/audio/cdparanoia/Portfile
===================================================================
--- trunk/dports/audio/cdparanoia/Portfile 2009-05-31 20:56:06 UTC (rev 51692)
+++ trunk/dports/audio/cdparanoia/Portfile 2009-05-31 21:00:54 UTC (rev 51693)
@@ -2,7 +2,7 @@
PortSystem 1.0
name cdparanoia
-version 0.9.8
+version 10.2
epoch 20050508
categories audio
maintainers nomaintainer
@@ -28,25 +28,21 @@
of the ripping process at runtime. A single binary can serve the \
diverse hardware of the do-it-yourself computer laboratory from Hell...
-homepage http://www.livejournal.com/users/strangehours/9698.html
+homepage http://www.xiph.org/paranoia
platforms darwin
-master_sites http://permuted.net/software/
-checksums md5 011e83fdedb536cf4dcabca7c4c0c5c2
+distname cdparanoia-III-${version}
+extract.suffix .src.tgz
+master_sites http://downloads.xiph.org/releases/cdparanoia
+checksums md5 b304bbe8ab63373924a744eac9ebc652 \
+ sha1 1901e20d3a370ca6afa4c76a9ef30d3f03044320 \
+ rmd160 d6c4ea9cc4aa4d5bcca4985e668ea6142d53cc55
-patchfiles patch-include-cdparanoia-paranoia-p_block.h \
- patch-interface-osx_interface.c
+patchfiles osx_interface.patch
+patch.args -p1
-destroot.destdir prefix=${destroot}${prefix}
+depends_build port:autoconf
-depends_build port:autoconf \
- port:automake \
- port:libtool
+use_autoconf yes
-post-extract {
- # Or automake will complain / exit 1
- system "touch ${worksrcpath}/{NEWS,AUTHORS,ChangeLog}"
-}
-
-use_autoreconf yes
-autoreconf.args -ifv
+destroot.destdir prefix=${destroot}${prefix}
Added: trunk/dports/audio/cdparanoia/files/osx_interface.patch
===================================================================
--- trunk/dports/audio/cdparanoia/files/osx_interface.patch (rev 0)
+++ trunk/dports/audio/cdparanoia/files/osx_interface.patch 2009-05-31 21:00:54 UTC (rev 51693)
@@ -0,0 +1,862 @@
+diff --git cdparanoia-III-10.2/Makefile.in cdparanoia-III-10.2/Makefile.in
+index 3d235ad..3435b88 100644
+--- cdparanoia-III-10.2/Makefile.in
++++ cdparanoia-III-10.2/Makefile.in
+@@ -32,11 +32,11 @@ export VERSION
+
+ ifeq ($(STATIC),TRUE)
+ LIBS = interface/libcdda_interface.a paranoia/libcdda_paranoia.a \
+- -static -lm -lrt
++ -static -lm
+ LIBDEP = interface/libcdda_interface.a paranoia/libcdda_paranoia.a
+ else
+- LIBS = -lcdda_interface -lcdda_paranoia -lm -lrt
+- LIBDEP = interface/libcdda_interface.so paranoia/libcdda_paranoia.so
++ LIBS = -lcdda_interface -lcdda_paranoia -lm
++ LIBDEP = interface/libcdda_interface.dylib paranoia/libcdda_paranoia.dylib
+ endif
+
+
+@@ -71,20 +71,20 @@ install:
+ $(INSTALL) -d -m 0755 $(INCLUDEDIR)
+ $(INSTALL) -m 0644 $(srcdir)/paranoia/cdda_paranoia.h $(INCLUDEDIR)
+ $(INSTALL) -d -m 0755 $(LIBDIR)
+- $(INSTALL) -m 0644 $(srcdir)/paranoia/libcdda_paranoia.so.0.$(VERSION) $(LIBDIR)
++ $(INSTALL) -m 0644 $(srcdir)/paranoia/libcdda_paranoia.0.$(VERSION).dylib $(LIBDIR)
+ $(INSTALL) -m 0644 $(srcdir)/paranoia/libcdda_paranoia.a $(LIBDIR)
+ $(INSTALL) -m 0644 $(srcdir)/interface/cdda_interface.h $(INCLUDEDIR)
+- $(INSTALL) -m 0644 $(srcdir)/interface/libcdda_interface.so.0.$(VERSION) $(LIBDIR)
++ $(INSTALL) -m 0644 $(srcdir)/interface/libcdda_interface.0.$(VERSION).dylib $(LIBDIR)
+ $(INSTALL) -m 0644 $(srcdir)/interface/libcdda_interface.a $(LIBDIR)
+ $(INSTALL) -m 0644 $(srcdir)/utils.h $(INCLUDEDIR)
+- ln -fs libcdda_interface.so.0.$(VERSION) \
+- $(LIBDIR)/libcdda_interface.so.0
+- ln -fs libcdda_interface.so.0.$(VERSION) \
+- $(LIBDIR)/libcdda_interface.so
+- ln -fs libcdda_paranoia.so.0.$(VERSION) \
+- $(LIBDIR)/libcdda_paranoia.so.0
+- ln -fs libcdda_paranoia.so.0.$(VERSION) \
+- $(LIBDIR)/libcdda_paranoia.so
++ ln -fs libcdda_interface.0.$(VERSION).dylib \
++ $(LIBDIR)/libcdda_interface.0.dylib
++ ln -fs libcdda_interface.0.$(VERSION).dylib \
++ $(LIBDIR)/libcdda_interface.dylib
++ ln -fs libcdda_paranoia.0.$(VERSION).dylib \
++ $(LIBDIR)/libcdda_paranoia.0.dylib
++ ln -fs libcdda_paranoia.0.$(VERSION).dylib \
++ $(LIBDIR)/libcdda_paranoia.dylib
+
+ cdparanoia: $(OFILES) $(LIBDEP)
+ $(LD) $(CFLAGS) $(LDFLAGS) $(OFILES) \
+diff --git cdparanoia-III-10.2/configure.in cdparanoia-III-10.2/configure.in
+index 3ad98ca..8fad378 100644
+--- cdparanoia-III-10.2/configure.in
++++ cdparanoia-III-10.2/configure.in
+@@ -5,9 +5,7 @@ cp $srcdir/configure.sub $srcdir/config.sub
+
+ AC_CANONICAL_HOST
+
+-if test -z "$CC"; then
+- AC_PROG_CC
+-fi
++AC_PROG_CC
+ AC_PROG_RANLIB
+ AC_CHECK_PROG(AR,ar,ar)
+ AC_CHECK_PROG(INSTALL,install,install)
+diff --git cdparanoia-III-10.2/interface/Makefile.in cdparanoia-III-10.2/interface/Makefile.in
+index 40c6098..01edd16 100644
+--- cdparanoia-III-10.2/interface/Makefile.in
++++ cdparanoia-III-10.2/interface/Makefile.in
+@@ -15,11 +15,15 @@ LD=@CC@
+ LDFLAGS=@LDFLAGS@ $(FLAGS)
+ AR=@AR@
+ RANLIB=@RANLIB@
+-LIBS = -lm -lrt
++LIBS = -lm -framework IOKit -framework Carbon
+ CPPFLAGS+=-D_REENTRANT
+
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++libdir=@libdir@
++
+ OFILES = scan_devices.o common_interface.o cooked_interface.o interface.o\
+- scsi_interface.o smallft.o toc.o test_interface.o
++ scsi_interface.o smallft.o toc.o test_interface.o osx_interface.o
+
+ export VERSION
+
+@@ -33,8 +37,7 @@ lib:
+
+ slib:
+ $(MAKE) lessmessy
+- $(MAKE) libcdda_interface.so CFLAGS="$(OPT) -fpic"
+- [ -e libcdda_interface.so.0 ] || ln -s libcdda_interface.so libcdda_interface.so.0
++ $(MAKE) libcdda_interface.dylib CFLAGS="$(OPT) -fpic"
+
+ test:
+ $(MAKE) libcdda_interface.a CFLAGS="$(DEBUG)"
+@@ -45,10 +48,10 @@ libcdda_interface.a: $(OFILES)
+ $(AR) -r libcdda_interface.a $(OFILES)
+ $(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) $(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
++libcdda_interface.dylib: $(OFILES)
++ $(CC) -dynamiclib -o libcdda_interface.0.$(VERSION).dylib $(OFILES) $(LIBS) -install_name $(libdir)/libcdda_interface.0.dylib
++ [ -e libcdda_interface.0.dylib ] || ln -s libcdda_interface.0.$(VERSION).dylib libcdda_interface.0.dylib
++ [ -e libcdda_interface.dylib ] || ln -s libcdda_interface.0.$(VERSION).dylib libcdda_interface.dylib
+
+ .c.o:
+ $(CC) $(CFLAGS) -c $<
+diff --git cdparanoia-III-10.2/interface/cdda_interface.h cdparanoia-III-10.2/interface/cdda_interface.h
+index 8487cb7..4731c82 100644
+--- cdparanoia-III-10.2/interface/cdda_interface.h
++++ cdparanoia-III-10.2/interface/cdda_interface.h
+@@ -18,6 +18,11 @@
+ #endif
+ #define CD_FRAMESAMPLES (CD_FRAMESIZE_RAW / 4)
+
++#ifdef __APPLE__
++#include <IOKit/IOKitLib.h>
++#include <IOKit/storage/IOCDTypes.h>
++#endif
++
+ #include <sys/types.h>
+ #include <signal.h>
+
+@@ -35,6 +40,7 @@ typedef struct TOC { /* structure of table of contents */
+ #define TEST_INTERFACE 2
+ #define SGIO_SCSI 3
+ #define SGIO_SCSI_BUGGY1 4
++#define IOKIT_INTERFACE 5
+
+ #define CDDA_MESSAGE_FORGETIT 0
+ #define CDDA_MESSAGE_PRINTIT 1
+@@ -100,6 +106,12 @@ typedef struct cdrom_drive{
+
+ sigset_t sigset;
+
++#ifdef __APPLE__
++ io_object_t io;
++
++ CDTOC *raw_toc;
++ int descriptor_count;
++#endif
+ } cdrom_drive;
+
+ #define IS_AUDIO(d,i) (!(d->disc_toc[i].bFlags & 0x04))
+diff --git cdparanoia-III-10.2/interface/common_interface.c cdparanoia-III-10.2/interface/common_interface.c
+index fb1d066..19e278b 100644
+--- cdparanoia-III-10.2/interface/common_interface.c
++++ cdparanoia-III-10.2/interface/common_interface.c
+@@ -9,12 +9,23 @@
+ ******************************************************************/
+
+ #include <math.h>
++#include <assert.h>
++#include <stdlib.h>
++#include <paths.h>
++#include <fcntl.h>
++#include <sys/syslimits.h>
++#include <stdio.h>
++
++#ifdef __APPLE__
++#include "cdda_interface.h"
++#include "utils.h"
++#else
+ #include "low_interface.h"
++#include <linux/hdreg.h>
++
+ #include "utils.h"
+ #include "smallft.h"
+
+-#include <linux/hdreg.h>
+-
+ /* Test for presence of a cdrom by pinging with the 'CDROMVOLREAD' ioctl() */
+ /* Also test using CDROM_GET_CAPABILITY (if available) as some newer DVDROMs will
+ reject CDROMVOLREAD ioctl for god-knows-what reason */
+@@ -50,6 +61,8 @@ char *atapi_drive_info(int fd){
+ return(ret);
+ }
+
++#endif /* !__APPLE__ */
++
+ int data_bigendianp(cdrom_drive *d){
+ float lsb_votes=0;
+ float msb_votes=0;
+@@ -174,7 +187,9 @@ int data_bigendianp(cdrom_drive *d){
+ knows the leadout/leadin size. */
+
+ int FixupTOC(cdrom_drive *d,int tracks){
++#ifndef __APPLE__
+ struct cdrom_multisession ms_str;
++#endif
+ int j;
+
+ /* First off, make sure the 'starting sector' is >=0 */
+@@ -208,6 +223,7 @@ int FixupTOC(cdrom_drive *d,int tracks){
+ }
+ }
+
++#ifndef __APPLE__
+ /* For a scsi device, the ioctl must go to the specialized SCSI
+ CDROM device, not the generic device. */
+
+@@ -235,6 +251,7 @@ int FixupTOC(cdrom_drive *d,int tracks){
+ return 1;
+ }
+ }
++#endif
+ return 0;
+ }
+
+diff --git cdparanoia-III-10.2/interface/common_interface.h cdparanoia-III-10.2/interface/common_interface.h
+index dd2dffb..85e050b 100644
+--- cdparanoia-III-10.2/interface/common_interface.h
++++ cdparanoia-III-10.2/interface/common_interface.h
+@@ -7,10 +7,15 @@
+ #ifndef _cdda_common_interface_h_
+ #define _cdda_common_interface_h_
+
++#ifdef __APPLE__
++#include "cdda_interface.h"
++#else
+ #include "low_interface.h"
+
+ extern int ioctl_ping_cdrom(int fd);
+ extern char *atapi_drive_info(int fd);
++#endif
++
+ extern int data_bigendianp(cdrom_drive *d);
+ extern int FixupTOC(cdrom_drive *d,int tracks);
+
+diff --git cdparanoia-III-10.2/interface/cooked_interface.c cdparanoia-III-10.2/interface/cooked_interface.c
+index de29055..0c97a3e 100644
+--- cdparanoia-III-10.2/interface/cooked_interface.c
++++ cdparanoia-III-10.2/interface/cooked_interface.c
+@@ -6,6 +6,8 @@
+ *
+ ******************************************************************/
+
++#ifndef __APPLE__
++
+ #include "low_interface.h"
+ #include "common_interface.h"
+ #include "utils.h"
+@@ -285,3 +287,4 @@ int cooked_init_drive (cdrom_drive *d){
+ return(0);
+ }
+
++#endif
+diff --git cdparanoia-III-10.2/interface/interface.c cdparanoia-III-10.2/interface/interface.c
+index e8a90cd..3adaf6a 100644
+--- cdparanoia-III-10.2/interface/interface.c
++++ cdparanoia-III-10.2/interface/interface.c
+@@ -9,7 +9,9 @@
+ *
+ ******************************************************************/
+
++#ifndef __APPLE__
+ #include "low_interface.h"
++#endif
+ #include "common_interface.h"
+ #include "utils.h"
+ #include "../version.h"
+@@ -39,10 +41,12 @@ int cdda_close(cdrom_drive *d){
+ 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);
++#ifndef __APPLE__
+ if(d->private){
+ if(d->private->sg_hd)free(d->private->sg_hd);
+ free(d->private);
+ }
++#endif
+
+ free(d);
+ }
+@@ -55,6 +59,7 @@ int cdda_open(cdrom_drive *d){
+ if(d->opened)return(0);
+
+ switch(d->interface){
++#ifndef __APPLE__
+ case SGIO_SCSI_BUGGY1:
+ case SGIO_SCSI:
+ case GENERIC_SCSI:
+@@ -65,6 +70,12 @@ int cdda_open(cdrom_drive *d){
+ if((ret=cooked_init_drive(d)))
+ return(ret);
+ break;
++#else
++ case IOKIT_INTERFACE:
++ if((ret=osx_init_drive(d)))
++ return(ret);
++ break;
++#endif
+ #ifdef CDDA_TEST
+ case TEST_INTERFACE:
+ if((ret=test_init_drive(d)))
+@@ -127,7 +138,9 @@ long cdda_read_timed(cdrom_drive *d, void *buffer, long beginsector, long sector
+ }
+ }
+ }
++#ifndef __APPLE__
+ if(ms)*ms=d->private->last_milliseconds;
++#endif
+ return(sectors);
+ }
+
+diff --git cdparanoia-III-10.2/interface/osx_interface.c cdparanoia-III-10.2/interface/osx_interface.c
+new file mode 100644
+index 0000000..f672316
+--- /dev/null
++++ cdparanoia-III-10.2/interface/osx_interface.c
+@@ -0,0 +1,249 @@
++/******************************************************************
++ * CopyPolicy: GNU Public License 2 applies
++ * Copyright (C) 1998 Monty xiphmont at mit.edu
++ ******************************************************************/
++
++#ifdef __APPLE__
++
++#include <math.h>
++#include <assert.h>
++#include <stdlib.h>
++#include <paths.h>
++#include <fcntl.h>
++#include <sys/syslimits.h>
++
++#include "cdda_interface.h"
++#include "osx_interface.h"
++#include "utils.h"
++#include "smallft.h"
++
++char *osx_bsd_device_for_media(io_object_t media) {
++ char buf[PATH_MAX];
++ size_t dev_path_length;
++ CFTypeRef str_bsd_path;
++ char *result;
++
++ str_bsd_path = IORegistryEntryCreateCFProperty(media, CFSTR(kIOBSDNameKey), kCFAllocatorDefault, 0);
++
++ if(str_bsd_path == NULL) {
++ return NULL;
++ }
++
++ snprintf(buf, sizeof(buf), "%s%c", _PATH_DEV, 'r' );
++ dev_path_length = strlen(buf);
++
++ if (CFStringGetCString(str_bsd_path,
++ buf + dev_path_length,
++ sizeof(buf) - dev_path_length,
++ kCFStringEncodingASCII)) {
++ result = strdup(buf);
++ } else {
++ result = NULL;
++ }
++ CFRelease(str_bsd_path);
++ return result;
++}
++
++int osx_enumerate_devices(cdrom_drive *d,
++ int (*device_found)(cdrom_drive *, io_object_t, void *),
++ void *data) {
++ kern_return_t ret;
++ mach_port_t port;
++ int drives = 0;
++ CFMutableDictionaryRef classes_to_match;
++ kern_return_t kern_result;
++ io_iterator_t media_iterator;
++ io_object_t next_media;
++
++ /* get port for IOKit communication */
++ if ((ret = IOMasterPort(MACH_PORT_NULL, &port)) != KERN_SUCCESS) {
++ cderror(d,"099: IOMasterPort fail\n");
++ return -1;
++ }
++
++ classes_to_match = IOServiceMatching(kIOCDMediaClass);
++ if(classes_to_match == NULL) {
++ cderror(d,"099: IOServiceMatching: NULL\n");
++ return -1;
++ }
++
++ CFDictionarySetValue(classes_to_match, CFSTR(kIOMediaEjectableKey), kCFBooleanTrue);
++
++ kern_result = IOServiceGetMatchingServices(port, classes_to_match, &media_iterator);
++ if (kern_result != KERN_SUCCESS) {
++ cderror(d,"099: IOServiceGetMatchingServices fail\n");
++ return -1;
++ }
++
++ while (1) {
++ drives++;
++ next_media = IOIteratorNext(media_iterator);
++ if (next_media == 0) {
++ break;
++ }
++
++ if (!device_found(d, next_media, data))
++ break;
++ IOObjectRelease(next_media);
++ }
++ if (next_media) IOObjectRelease(next_media);
++ IOObjectRelease(media_iterator);
++
++ return drives;
++}
++
++static int find_first_device(cdrom_drive *d, io_object_t io, void *data) {
++ io_object_t *dev = (io_object_t *)data;
++ *dev = io;
++ IOObjectRetain(io);
++ return 0;
++}
++
++io_object_t osx_default_device(cdrom_drive *d) {
++ io_object_t io;
++ osx_enumerate_devices(d, find_first_device, (void *)&io);
++ return io;
++}
++
++int osx_read_toc(cdrom_drive *d) {
++ kern_return_t ret;
++ char *devname;
++ CFRange range;
++ CFIndex buf_len;
++ int leadout;
++ CFMutableDictionaryRef properties;
++ CFDataRef data;
++ int i;
++
++ devname = strrchr(d->cdda_device_name, '/');
++
++ if (devname != NULL) {
++ devname++;
++ } else {
++ devname = d->cdda_device_name;
++ }
++
++ if (*devname == 'r') devname++;
++
++ /* create a CF dictionary containing the TOC */
++ ret = IORegistryEntryCreateCFProperties(d->io, &properties, kCFAllocatorDefault, kNilOptions);
++
++ if( ret != KERN_SUCCESS) {
++ cderror(d, "099: IORegistryEntryCreateCFProperties fail\n");
++ return -1;
++ }
++
++ /* get the TOC from the dictionary */
++ data = (CFDataRef)CFDictionaryGetValue(properties, CFSTR(kIOCDMediaTOCKey));
++ if(data == NULL) {
++ cderror(d, "099: CFDictionaryGetValue fail\n");
++ return -1;
++ }
++
++ buf_len = CFDataGetLength(data) + 1;
++ range = CFRangeMake(0, buf_len);
++
++ d->raw_toc = (CDTOC *)malloc(buf_len);
++ if (d->raw_toc == NULL) {
++ cderror(d, "099: toc malloc fail\n");
++ CFRelease(properties);
++ return -1;
++ }
++ CFDataGetBytes(data, range, (u_char *)d->raw_toc);
++
++ CFRelease(properties);
++
++ d->descriptor_count = CDTOCGetDescriptorCount(d->raw_toc);
++ d->tracks = 0;
++
++ for (i = 0; i < d->descriptor_count; i++) {
++ int track_num = d->raw_toc->descriptors[i].point;
++ CDMSF msf = d->raw_toc->descriptors[i].p;
++ int start_sector = CDConvertMSFToLBA(msf);
++ if (track_num == 0xa2) {
++ leadout = i;
++ }
++ fprintf(stderr,
++ "track_num = %d start sector %d msf: %d,%d,%d\n",
++ track_num, start_sector,
++ msf.minute, msf.second, msf.frame);
++ if (track_num > 99 || track_num < 1) {
++ // e.g.:
++ // track_num = 160 start sector 4350 msf: 1,0,0
++ // track_num = 161 start sector 67350 msf: 15,0,0
++ // track_num = 162 start sector 330645 msf: 73,30,45
++
++ continue; // XXX don't know what happens here. tracks 0xa0, 0xa1, 0xa2 (leadout)
++ }
++ d->disc_toc[d->tracks].bTrack = track_num;
++ d->disc_toc[d->tracks].bFlags =
++ (d->raw_toc->descriptors[i].adr << 4) | d->raw_toc->descriptors[i].control;
++ d->disc_toc[d->tracks].dwStartSector = start_sector;
++ d->tracks++;
++ }
++ d->disc_toc[d->tracks].bTrack = 0xaa;
++ d->disc_toc[d->tracks].bFlags =
++ (d->raw_toc->descriptors[i].adr << 4) | d->raw_toc->descriptors[leadout].control;
++ d->disc_toc[d->tracks].dwStartSector = CDConvertMSFToLBA(d->raw_toc->descriptors[leadout].p);
++
++ return d->tracks;
++}
++
++int osx_init_drive(cdrom_drive *d) {
++ d->io = osx_default_device(d);
++
++ d->enable_cdda = osx_enable_cdda;
++ d->read_audio = osx_read_audio;
++ d->read_toc = osx_read_toc;
++ d->set_speed = osx_set_speed;
++
++ d->cdda_device_name = osx_bsd_device_for_media(d->io);
++ if (!d->cdda_device_name) {
++ IOObjectRelease(d->io);
++ return -1;
++ }
++
++ d->cdda_fd = open(d->cdda_device_name, O_RDONLY | O_NONBLOCK, 0);
++
++ if (d->cdda_fd == -1) {
++ free(d->cdda_device_name);
++ IOObjectRelease(d->io);
++ return -1;
++ }
++
++ d->read_toc(d);
++
++ d->nsectors = 32;
++ d->opened = 1;
++ return 0;
++}
++
++int osx_set_speed(cdrom_drive *d, int speed) {
++ return 0;
++}
++
++int osx_enable_cdda(cdrom_drive *d, int enable) {
++ return 0;
++}
++
++long osx_read_audio(cdrom_drive *d, void *buf, long begin, long sectors) {
++ dk_cd_read_t cd_read;
++
++ // fprintf(stderr, "read_audio %p, %d, %d\n", buf, begin, sectors);
++
++ memset(&cd_read, 0, sizeof(cd_read));
++
++ cd_read.offset = begin * kCDSectorSizeCDDA;
++ cd_read.sectorArea = kCDSectorAreaUser;
++ cd_read.sectorType = kCDSectorTypeCDDA;
++
++ cd_read.buffer = buf;
++ cd_read.bufferLength = kCDSectorSizeCDDA * sectors;
++
++ if( ioctl(d->cdda_fd, DKIOCCDREAD, &cd_read) == -1) {
++ return 0;
++ }
++ return cd_read.bufferLength / kCDSectorSizeCDDA;
++}
++
++#endif /* __APPLE__ */
+diff --git cdparanoia-III-10.2/interface/osx_interface.h cdparanoia-III-10.2/interface/osx_interface.h
+new file mode 100644
+index 0000000..b4a18a4
+--- /dev/null
++++ cdparanoia-III-10.2/interface/osx_interface.h
+@@ -0,0 +1,29 @@
++/******************************************************************
++ * CopyPolicy: GNU Public License 2 applies
++ * Copyright (C) 1998 Monty xiphmont at mit.edu
++ *
++ ******************************************************************/
++
++#ifndef _cdda_osx_interface_h_
++#define _cdda_osx_interface_h_
++
++#include <CoreFoundation/CFBase.h>
++#include <CoreFoundation/CFString.h>
++#include <CoreFoundation/CFNumber.h>
++#include <IOKit/IOBSD.h>
++#include <IOKit/storage/IOMedia.h>
++#include <IOKit/storage/IOCDMedia.h>
++#include <IOKit/storage/IOCDMediaBSDClient.h>
++
++char *osx_bsd_device_for_media(io_object_t media);
++int osx_enumerate_devices(cdrom_drive *d,
++ int (*device_found)(cdrom_drive *, io_object_t, void *),
++ void *data);
++io_object_t osx_default_device(cdrom_drive *d);
++int osx_read_toc(cdrom_drive *d);
++int osx_init_drive(cdrom_drive *d);
++int osx_set_speed(cdrom_drive *d, int speed);
++int osx_enable_cdda(cdrom_drive *d, int enable);
++long osx_read_audio(cdrom_drive *d, void *buf, long begin, long sectors);
++
++#endif
+diff --git cdparanoia-III-10.2/interface/scan_devices.c cdparanoia-III-10.2/interface/scan_devices.c
+index fc58110..1294727 100644
+--- cdparanoia-III-10.2/interface/scan_devices.c
++++ cdparanoia-III-10.2/interface/scan_devices.c
+@@ -6,18 +6,30 @@
+ *
+ ******************************************************************/
+
++#include <stdlib.h>
++#include "cdda_interface.h"
++
++#ifdef __APPLE__
++cdrom_drive *cdda_find_a_cdrom(int messagedest,char **messages){
++ cdrom_drive *d = calloc(1, sizeof(cdrom_drive));
++ if(!d)
++ return NULL;
++ d->interface = IOKIT_INTERFACE;
++ return d;
++}
++
++#else
++
+ #define _GNU_SOURCE /* get cuserid */
+ #define _USE_XOPEN /* get cuserid */
+ #include <limits.h>
+ #include <stdio.h>
+ #include <unistd.h>
+-#include <stdlib.h>
+ #include <ctype.h>
+ #include <pwd.h>
+ #include <time.h>
+ #include <sys/stat.h>
+ #include <sys/types.h>
+-#include "cdda_interface.h"
+ #include "low_interface.h"
+ #include "common_interface.h"
+ #include "utils.h"
+@@ -781,6 +793,8 @@ cdda_identify_scsi_fail:
+ return(NULL);
+ }
+
++#endif /* __APPLE__ */
++
+ #ifdef CDDA_TEST
+
+ cdrom_drive *cdda_identify_test(const char *filename, int messagedest,
+diff --git cdparanoia-III-10.2/interface/scsi_interface.c cdparanoia-III-10.2/interface/scsi_interface.c
+index adbb9bf..2354115 100644
+--- cdparanoia-III-10.2/interface/scsi_interface.c
++++ cdparanoia-III-10.2/interface/scsi_interface.c
+@@ -8,6 +8,8 @@
+ *
+ ******************************************************************/
+
++#ifndef __APPLE__
++
+ #include "low_interface.h"
+ #include "common_interface.h"
+ #include "utils.h"
+@@ -1748,3 +1750,4 @@ int scsi_init_drive(cdrom_drive *d){
+ return(0);
+ }
+
++#endif /* !__APPLE__ */
+diff --git cdparanoia-III-10.2/interface/toc.c cdparanoia-III-10.2/interface/toc.c
+index 64bd776..b80cc2e 100644
+--- cdparanoia-III-10.2/interface/toc.c
++++ cdparanoia-III-10.2/interface/toc.c
+@@ -7,7 +7,11 @@
+ *
+ ******************************************************************/
+
++#ifdef __APPLE__
++#include "cdda_interface.h"
++#else
+ #include "low_interface.h"
++#endif
+ #include "utils.h"
+
+ long cdda_track_firstsector(cdrom_drive *d,int track){
+diff --git cdparanoia-III-10.2/interface/utils.h cdparanoia-III-10.2/interface/utils.h
+index c9647da..68c1a3a 100644
+--- cdparanoia-III-10.2/interface/utils.h
++++ cdparanoia-III-10.2/interface/utils.h
+@@ -1,4 +1,6 @@
+-#include <endian.h>
++#include <unistd.h>
++#include <stdint.h>
++#include <stdlib.h>
+ #include <stdio.h>
+ #include <errno.h>
+ #include <string.h>
+@@ -14,15 +16,15 @@ static inline int bigendianp(void){
+ }
+
+ static inline int32_t swap32(int32_t x){
+- return((((u_int32_t)x & 0x000000ffU) << 24) |
+- (((u_int32_t)x & 0x0000ff00U) << 8) |
+- (((u_int32_t)x & 0x00ff0000U) >> 8) |
+- (((u_int32_t)x & 0xff000000U) >> 24));
++ return((((uint32_t)x & 0x000000ffU) << 24) |
++ (((uint32_t)x & 0x0000ff00U) << 8) |
++ (((uint32_t)x & 0x00ff0000U) >> 8) |
++ (((uint32_t)x & 0xff000000U) >> 24));
+ }
+
+ static inline int16_t swap16(int16_t x){
+- return((((u_int16_t)x & 0x00ffU) << 8) |
+- (((u_int16_t)x & 0xff00U) >> 8));
++ return((((uint16_t)x & 0x00ffU) << 8) |
++ (((uint16_t)x & 0xff00U) >> 8));
+ }
+
+ #if BYTE_ORDER == LITTLE_ENDIAN
+diff --git cdparanoia-III-10.2/main.c cdparanoia-III-10.2/main.c
+index 664acac..ebb2e82 100644
+--- cdparanoia-III-10.2/main.c
++++ cdparanoia-III-10.2/main.c
+@@ -939,6 +939,9 @@ int main(int argc,char *argv[]){
+
+ /* Query the cdrom/disc; we may need to override some settings */
+
++#ifdef __APPLE__
++ d=cdda_find_a_cdrom(verbose,NULL);
++#else
+ if(force_cooked_device){
+ d=cdda_identify_cooked(force_cooked_device,verbose,NULL);
+ }else if(force_generic_device)
+@@ -971,7 +974,8 @@ int main(int argc,char *argv[]){
+ report(" ");
+ }
+ }
+-
++#endif
++
+ if(!d){
+ if(!verbose)
+ report("\nUnable to open cdrom drive; -v will give more information.");
+@@ -1362,7 +1366,11 @@ int main(int argc,char *argv[]){
+ if(err)free(err);
+ if(mes)free(mes);
+ if(readbuf==NULL){
+- if(errno==EBADF || errno==ENOMEDIUM){
++ if(errno==EBADF
++#ifndef __APPLE__
++ || errno==ENOMEDIUM
++#endif
++ ){
+ report("\nparanoia_read: CDROM drive unavailable, bailing.\n");
+ exit(1);
+ }
+diff --git cdparanoia-III-10.2/paranoia/Makefile.in cdparanoia-III-10.2/paranoia/Makefile.in
+index 89d0328..e693749 100644
+--- cdparanoia-III-10.2/paranoia/Makefile.in
++++ cdparanoia-III-10.2/paranoia/Makefile.in
+@@ -18,6 +18,10 @@ AR=@AR@
+ RANLIB=@RANLIB@
+ CPPFLAGS+=-D_REENTRANT
+
++prefix=@prefix@
++exec_prefix=@exec_prefix@
++libdir=@libdir@
++
+ OFILES = paranoia.o p_block.o overlap.o gap.o isort.o
+ #TFILES = isort.t gap.t p_block.t paranoia.t
+
+@@ -34,7 +38,7 @@ lib:
+
+ slib:
+ $(MAKE) lessmessy
+- $(MAKE) libcdda_paranoia.so CFLAGS="$(OPT) -fpic"
++ $(MAKE) libcdda_paranoia.dylib CFLAGS="$(OPT) -fpic"
+
+ #test: $(TFILES)
+ #
+@@ -43,10 +47,10 @@ libcdda_paranoia.a: $(OFILES)
+ $(AR) -r libcdda_paranoia.a $(OFILES)
+ $(RANLIB) libcdda_paranoia.a
+
+-libcdda_paranoia.so: $(OFILES)
+- $(CC) -fpic -shared -o libcdda_paranoia.so.0.$(VERSION) -Wl,-soname -Wl,libcdda_paranoia.so.0 $(OFILES) -L ../interface -lcdda_interface
+- [ -e libcdda_paranoia.so.0 ] || ln -s libcdda_paranoia.so.0.$(VERSION) libcdda_paranoia.so.0
+- [ -e libcdda_paranoia.so ] || ln -s libcdda_paranoia.so.0.$(VERSION) libcdda_paranoia.so
++libcdda_paranoia.dylib: $(OFILES)
++ $(CC) -dynamiclib -o libcdda_paranoia.0.$(VERSION).dylib $(OFILES) -L../interface -lcdda_interface -install_name $(libdir)/libcdda_paranoia.0.dylib
++ [ -e libcdda_paranoia.0.dylib ] || ln -s libcdda_paranoia.0.$(VERSION).dylib libcdda_paranoia.0.dylib
++ [ -e libcdda_paranoia.dylib ] || ln -s libcdda_paranoia.0.$(VERSION).dylib libcdda_paranoia.dylib
+
+ .c.o:
+ $(CC) $(CFLAGS) -c $<
+@@ -63,4 +67,3 @@ clean: lessmessy
+
+ distclean: clean
+ -rm -f Makefile
+-
+diff --git cdparanoia-III-10.2/paranoia/paranoia.c cdparanoia-III-10.2/paranoia/paranoia.c
+index 07b0322..9a382f5 100644
+--- cdparanoia-III-10.2/paranoia/paranoia.c
++++ cdparanoia-III-10.2/paranoia/paranoia.c
+@@ -2439,6 +2439,7 @@ c_block *i_read_c_block(cdrom_paranoia *p,long beginword,long endword,
+ secread))<secread){
+
+ if(thisread<0){
++#ifndef __APPLE__
+ if(errno==ENOMEDIUM){
+ /* the one error we bail on immediately */
+ if(new)free_c_block(new);
+@@ -2446,6 +2447,7 @@ c_block *i_read_c_block(cdrom_paranoia *p,long beginword,long endword,
+ if(flags)free(flags);
+ return NULL;
+ }
++#endif
+ thisread=0;
+ }
+
+@@ -2685,10 +2687,11 @@ int16_t *paranoia_read_limited(cdrom_paranoia *p, void(*callback)(long,int),
+ }
+ }else{
+
++#ifndef __APPLE__
+ /* Was the medium removed or the device closed out from
+ under us? */
+ if(errno==ENOMEDIUM) return NULL;
+-
++#endif
+ }
+ }
+
+diff --git cdparanoia-III-10.2/utils.h cdparanoia-III-10.2/utils.h
+index 10dce58..6211ce3 100644
+--- cdparanoia-III-10.2/utils.h
++++ cdparanoia-III-10.2/utils.h
+@@ -1,5 +1,6 @@
++#include <unistd.h>
++#include <stdint.h>
+ #include <stdlib.h>
+-#include <endian.h>
+ #include <stdio.h>
+ #include <errno.h>
+ #include <string.h>
+@@ -18,15 +19,15 @@ static inline int bigendianp(void){
+ }
+
+ static inline int32_t swap32(int32_t x){
+- return((((u_int32_t)x & 0x000000ffU) << 24) |
+- (((u_int32_t)x & 0x0000ff00U) << 8) |
+- (((u_int32_t)x & 0x00ff0000U) >> 8) |
+- (((u_int32_t)x & 0xff000000U) >> 24));
++ return((((uint32_t)x & 0x000000ffU) << 24) |
++ (((uint32_t)x & 0x0000ff00U) << 8) |
++ (((uint32_t)x & 0x00ff0000U) >> 8) |
++ (((uint32_t)x & 0xff000000U) >> 24));
+ }
+
+ static inline int16_t swap16(int16_t x){
+- return((((u_int16_t)x & 0x00ffU) << 8) |
+- (((u_int16_t)x & 0xff00U) >> 8));
++ return((((uint16_t)x & 0x00ffU) << 8) |
++ (((uint16_t)x & 0xff00U) >> 8));
+ }
+
+ #if BYTE_ORDER == LITTLE_ENDIAN
Deleted: trunk/dports/audio/cdparanoia/files/patch-include-cdparanoia-paranoia-p_block.h
===================================================================
--- trunk/dports/audio/cdparanoia/files/patch-include-cdparanoia-paranoia-p_block.h 2009-05-31 20:56:06 UTC (rev 51692)
+++ trunk/dports/audio/cdparanoia/files/patch-include-cdparanoia-paranoia-p_block.h 2009-05-31 21:00:54 UTC (rev 51693)
@@ -1,31 +0,0 @@
---- ../cdparanoia-0.9.8.orig/include/cdparanoia/paranoia/p_block.h Fri Apr 8 19:35:10 2005
-+++ include/cdparanoia/paranoia/p_block.h Fri Apr 8 19:35:18 2005
-@@ -128,7 +128,7 @@
-
- } offsets;
-
--typedef struct cdrom_paranoia{
-+struct cdrom_paranoia {
- cdrom_drive *d;
-
- root_block root; /* verified/reconstructed cached data */
-@@ -155,7 +155,7 @@
-
- /* statistics for verification */
-
--} cdrom_paranoia;
-+};
-
- extern c_block *c_alloc(int16_t *vector,long begin,long size);
- extern void c_set(c_block *v,long begin);
-@@ -171,8 +171,8 @@
-
- /* pos here is vector position from zero */
-
--extern void recover_cache(cdrom_paranoia *p);
--extern void i_paranoia_firstlast(cdrom_paranoia *p);
-+extern void recover_cache(struct cdrom_paranoia *p);
-+extern void i_paranoia_firstlast(struct cdrom_paranoia *p);
-
- #define cv(c) (c->vector)
-
Deleted: trunk/dports/audio/cdparanoia/files/patch-interface-osx_interface.c
===================================================================
--- trunk/dports/audio/cdparanoia/files/patch-interface-osx_interface.c 2009-05-31 20:56:06 UTC (rev 51692)
+++ trunk/dports/audio/cdparanoia/files/patch-interface-osx_interface.c 2009-05-31 21:00:54 UTC (rev 51693)
@@ -1,20 +0,0 @@
---- ../cdparanoia-0.9.8.orig/interface/osx_interface.c Fri Apr 8 19:35:10 2005
-+++ interface/osx_interface.c Fri Apr 8 19:35:18 2005
-@@ -26,7 +26,7 @@
- CFTypeRef str_bsd_path;
- char *result;
-
-- str_bsd_path = IORegistryEntryCreateCFProperty(media, CFSTR(kIOBSDName), kCFAllocatorDefault, 0);
-+ str_bsd_path = IORegistryEntryCreateCFProperty(media, CFSTR(kIOBSDNameKey), kCFAllocatorDefault, 0);
-
- if(str_bsd_path == NULL) {
- return NULL;
-@@ -70,7 +70,7 @@
- return -1;
- }
-
-- CFDictionarySetValue(classes_to_match, CFSTR(kIOMediaEjectable), kCFBooleanTrue);
-+ CFDictionarySetValue(classes_to_match, CFSTR(kIOMediaEjectableKey), kCFBooleanTrue);
-
- kern_result = IOServiceGetMatchingServices(port, classes_to_match, &media_iterator);
- if (kern_result != KERN_SUCCESS) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090531/9284a298/attachment-0001.html>
More information about the macports-changes
mailing list