Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 Oct 2003 14:23:34 +1100
From:      Peter Kostouros <kpeter@melbpc.org.au>
To:        ports@FreeBSD.ORG
Subject:   [patch] dagrab post new ATA code
Message-ID:  <3FA1D5B6.3040605@melbpc.org.au>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040005040005070008030001
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi

I have attached a patch that got dagrab working for me again after the 
new ATA code was imported into CURRENT. The patch may need further work, 
but for those interested ...

-- 

Regards

Peter

As always the organisation disavows knowledge of this email


--------------040005040005070008030001
Content-Type: text/plain;
 name="patch-cd_read_audio"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch-cd_read_audio"

--- dagrab.c.after.patch	Fri Oct 31 12:02:06 2003
+++ dagrab.c	Fri Oct 31 14:00:45 2003
@@ -106,6 +106,7 @@
 #include <sys/cdio.h>
 #include <sys/param.h>
 #include <sys/mount.h>
+#include <sys/cdrio.h>
 #define CDDEVICE "/dev/cdrom"
 #define N_BUF 12
 #define OVERLAP 2
@@ -203,7 +204,8 @@
   {"@DIS",KW_DISK,"Disk name (guessed)"}
 };
 
-
+int block_size = CD_FRAMESIZE_RAW;
+  
 struct Wavefile cd_newave(unsigned size)
 {
   struct Wavefile dummy={{'R','I','F','F'},		/* Rid */
@@ -242,27 +244,33 @@
   return ioctl(cdrom_fd,CDIOREADTOCENTRY,Te);
 }
 
-void cd_read_audio(int lba,int num,char *buf)
-	/* reads num CD_FRAMESIZE_RAW sized
-	   sectors in buf, starting from lba*/
-	/*NOTE: if num>CDROM_NBLOCKS_BUFFER as defined in ide_cd.c (8 in linux 2.0.32)
-	  jitter correction may be required inside the block. */					   
-{
-	struct ioc_read_audio ra;
-
-	ra.address.lba=lba;
-	ra.address_format=CD_LBA_FORMAT;
-	ra.nframes=num;
-	ra.buffer=buf;
-	if(ioctl(cdrom_fd,CDIOCREADAUDIO,&ra)){
-		/*fprintf(stderr,"%s: read raw ioctl failed \n",progname);*/
-		fprintf(stderr,"\n%s: read raw ioctl failed at lba %d length %d: %s\n",
-				progname,lba,num,strerror(errno));
-		exit(1);
-	}
+/* Original documentation for cd_read_audio:
+ * 
+ * reads num CD_FRAMESIZE_RAW sized sectors in buf, starting from lba
+ * 
+ * NOTE: if num > CDROM_NBLOCKS_BUFFER as defined in ide_cd.c (8 in linux 2.0.32)
+ * jitter correction may be required inside the block.
+ */
+void cd_read_audio(int lba, int num, char *buf)
+{  
+   if (lba >= 0)
+   {	
+     if (lseek(cdrom_fd, lba * block_size, SEEK_SET) == -1)
+     {
+	fprintf(stderr, "\n%s: read failed at lba %d: %s\n",
+	      progname, lba * block_size, strerror(errno));
+         exit (errno);	
+     }
+   }
+   	 
+   if (read(cdrom_fd, buf, num * block_size) == -1)
+   {
+      fprintf(stderr, "\n%s: read failed at lba %d length %d: %s\n",
+	      progname, lba, num, strerror(errno));
+      exit (errno);
+   }
 }
 
-
 // CDDB section
 static int cddb_sock;
 
@@ -655,7 +663,7 @@
 	if ((cdrom_fd=open(cd_dev,O_RDONLY))==-1){
 		fprintf(stderr,"%s: error opening device %s\n",progname,cd_dev);
 		exit(1);
-	}
+	}   
 	if(cd_get_tochdr(&Th)){
 		fprintf(stderr,"%s: read TOC ioctl failed: %s\n",progname,strerror(errno));
 		exit(1);
@@ -987,6 +995,7 @@
 	char path[500];
 	FILE *f;
 	progname=av[0];
+      
 	while((c=getopt(ac,av,"pshaivCSNd:f:n:o:k:r:t:m:e:H:P:D:"))!=-1){
 		switch(c){
 			case 'h':usage();break;
@@ -1064,9 +1073,7 @@
 		opt_chmod=0660; if(opt_verbose)
 			fprintf(stderr, "strange chmod value, setting to 0660\n");
 	}
-	opt_bufsize=CD_FRAMESIZE_RAW * opt_blocks;
-	opt_ibufsize=opt_bufsize/sizeof(int);
-	opt_bufstep=opt_blocks-opt_overlap;
+	
 	if((optind==ac)&&!all_tracks&&!opt_save) {
 		if(disp_TOC){
 			if(cd_getinfo(cd_dev,&tl))
@@ -1075,11 +1082,24 @@
 			exit(0);
 		}
 		else usage();
-	};
+	}
 
 	if(cd_getinfo(cd_dev,&tl)){
 	  exit(1);
 	}
+   
+        /* Initialise global variable block_size */
+        if (ioctl(cdrom_fd, CDRIOCGETBLOCKSIZE, &block_size) == -1)
+        {
+                fprintf(stderr, "\nioctl error: %s\n", strerror(errno));
+                exit (errno);
+        }
+   
+        /* Set opt_* variables now that block_size is found. */
+        opt_bufsize = block_size * opt_blocks;
+	opt_ibufsize = opt_bufsize / sizeof(int);
+        opt_bufstep = opt_blocks - opt_overlap;	   
+   
 	if(disp_TOC)cd_disp_TOC(&tl);
 	if(opt_save && (tl.cddb!=NULL)){
 	  if(tl.gnr==NULL) 

--------------040005040005070008030001--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FA1D5B6.3040605>