[MPlayer-dev-eng] [PATCH] Fix for cdda://NN and cddb://NN on NetBSD

Frederick Bruckman fredb at immanent.net
Thu Dec 26 08:01:53 CET 2002


Hi,

The following patch allows the MPlayer "cdparanoia" support to work on
NetBSD-1.6_STABLE, both "cdda://NN" and "cddb://NN" URI's.

The CDROM ioctl's are actually more like OpenBSD's than FreeBSD's. I
went with the "/dev/cdrom" symlink as the default device, though, as
it otherwise gets messy fast... The first CDROM is "/dev/rcd0d" on
NetBSD/i386, but "/dev/rcd0c" on all other NetBSD ports, and only the
cdda_identify_scsi() form seems to work on NetBSD. (I searched the web
in vain for the Paranoia API, so I'm left to hacking. ;-))

The first part of the patch just quells warnings in the ".depends"
generation phase.

With this patch, I can play track 02 of an audio CD like so:

  mplayer cdda://02 -cache 1024

and with no skipping. With "cddb://", instead, it displays the name
of the CD and the song(s) before playing, and "-dumpaudio" works fine
with both.

Regards,

Frederick


Index: libmpdemux/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.43
diff -u -r1.43 Makefile
--- libmpdemux/Makefile	22 Dec 2002 21:01:01 -0000	1.43
+++ libmpdemux/Makefile	26 Dec 2002 04:54:26 -0000
@@ -23,7 +23,7 @@
 OBJS	= $(SRCS:.c=.o)
 OBJS   += $(CPLUSPLUSSRCS:.cpp=.o)
 INCLUDE = -I../loader $(CSS_INC) $(EXTRA_INC)
-CFLAGS  = $(OPTFLAGS) $(INCLUDE) $(XMMS_CFLAGS)
+CFLAGS  = $(OPTFLAGS) $(INCLUDE) $(XMMS_CFLAGS) $(CDPARANOIA_INC)
 CPLUSPLUSFLAGS  = $(CFLAGS) $(CPLUSPLUSINCLUDE)
 CPLUSPLUS = $(CC)

Index: libmpdemux/cdda.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cdda.c,v
retrieving revision 1.6
diff -u -r1.6 cdda.c
--- libmpdemux/cdda.c	24 Dec 2002 22:13:32 -0000	1.6
+++ libmpdemux/cdda.c	26 Dec 2002 04:54:28 -0000
@@ -12,7 +12,11 @@

 static int speed = -1;
 static int paranoia_mode = 1;
+#if defined(__NetBSD__)
+static char* generic_dev = "/dev/cdrom";
+#else
 static char* generic_dev = NULL;
+#endif
 static int sector_size = 0;
 static int search_overlap = -1;
 static int toc_bias = 0;
Index: libmpdemux/cddb.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cddb.c,v
retrieving revision 1.9
diff -u -r1.9 cddb.c
--- libmpdemux/cddb.c	24 Dec 2002 21:59:38 -0000	1.9
+++ libmpdemux/cddb.c	26 Dec 2002 04:54:29 -0000
@@ -28,10 +28,14 @@
 #include <sys/types.h>
 #include <sys/stat.h>

-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
+#if defined(__FreeBSD__) || defined(__bsdi__)
 	#define SYS_BSD 1
 #endif

+#if defined(__NetBSD__)
+	#define SYS_NBSD 1
+#endif
+
 #if defined(__OpenBSD__)
 	#define SYS_OBSD 1
 #endif
@@ -40,6 +44,8 @@
 	#include <linux/cdrom.h>
 #elif defined(SYS_BSD)
 	#include <sys/cdio.h>
+#elif defined(SYS_NBSD)
+	#include <sys/cdio.h>
 #elif defined(SYS_OBSD)
 	#include <util.h>
 	#include <sys/cdio.h>
@@ -113,6 +119,44 @@
 	cdtoc[tochdr.ending_track].min = tocentry.entry.addr.msf.minute;
 	cdtoc[tochdr.ending_track].sec = tocentry.entry.addr.msf.second;
 	cdtoc[tochdr.ending_track].frame = tocentry.entry.addr.msf.frame;
+	cdtoc[tochdr.ending_track].frame += cdtoc[tochdr.ending_track].min*60*75;
+	cdtoc[tochdr.ending_track].frame += cdtoc[tochdr.ending_track].sec*75;
+	close(drive);
+	return tochdr.ending_track;
+}
+
+#elif defined(SYS_NBSD)
+int
+read_toc(void) {
+	int drive;
+	struct ioc_toc_header tochdr;
+	struct ioc_read_toc_entry tocentry;
+	int i;
+	struct cd_toc_entry toc_buffer;
+
+	drive = open("/dev/cdrom", O_RDONLY | O_NONBLOCK);
+	if (!drive)
+		return -1;
+
+	ioctl(drive, CDIOREADTOCHEADER, &tochdr);
+	for (i = tochdr.starting_track; i <= tochdr.ending_track; i++) {
+		tocentry.starting_track = i;
+		tocentry.address_format = CD_MSF_FORMAT;
+		tocentry.data = &toc_buffer;
+		tocentry.data_len = sizeof(toc_buffer);
+		ioctl(drive, CDIOREADTOCENTRYS, &tocentry);
+		cdtoc[i-1].min = toc_buffer.addr.msf.minute;
+		cdtoc[i-1].sec = toc_buffer.addr.msf.second;
+		cdtoc[i-1].frame = toc_buffer.addr.msf.frame;
+		cdtoc[i-1].frame += cdtoc[i-1].min*60*75;
+		cdtoc[i-1].frame += cdtoc[i-1].sec*75;
+	}
+	tocentry.starting_track = 0xAA;
+	tocentry.address_format = CD_MSF_FORMAT;
+	ioctl(drive, CDIOREADTOCENTRYS, &tocentry);
+	cdtoc[tochdr.ending_track].min = toc_buffer.addr.msf.minute;
+	cdtoc[tochdr.ending_track].sec = toc_buffer.addr.msf.second;
+	cdtoc[tochdr.ending_track].frame = toc_buffer.addr.msf.frame;
 	cdtoc[tochdr.ending_track].frame += cdtoc[tochdr.ending_track].min*60*75;
 	cdtoc[tochdr.ending_track].frame += cdtoc[tochdr.ending_track].sec*75;
 	close(drive);






More information about the MPlayer-dev-eng mailing list