Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Nov 2002 17:12:07 -0800
From:      david parsons <orc@pell.portland.or.us>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/45547: a patch to make burncd handle .wav files.
Message-ID:  <200211210112.RAA22252@pell.portland.or.us>

next in thread | raw e-mail | index | archive | help

>Number:         45547
>Category:       bin
>Synopsis:       a patch to make burncd handle .wav files.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 20 18:30:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     david parsons
>Release:        FreeBSD 4.7-RELEASE i386
>Organization:
n/a
>Environment:
System: FreeBSD india.pell.portland.or.us 4.7-RELEASE FreeBSD 4.7-RELEASE #2: Thu Oct 24 14:43:00 PDT 2002 root@india.pell.portland.or.us:/usr/src/sys/compile/PACIFIC i386


>Description:
	burncd writes out .wav headers when recording audio, creating
	annoying clicks at the start of each track.
>How-To-Repeat:
	burn an audio cd.
>Fix:
Apply this patch (i386 only, I guess)

*** burncd.c~	Mon Nov 18 17:46:37 2002
--- burncd.c	Wed Nov 20 00:36:13 2002
***************
*** 48,53 ****
--- 48,54 ----
  	int	file;
  	char	*file_name;
  	u_int	file_size;
+ 	off_t	file_start;
  	int	block_size;
  	int	block_type;
  	int	pregap;
***************
*** 283,288 ****
--- 284,326 ----
  }
  
  void
+ get_info(int fd, int block_type, struct stat *sb, struct track_info *trk)
+ {
+ 	off_t pos = lseek(fd, 0, SEEK_CUR);
+ 
+ 	struct riff_hdr {
+ 		char magic[4];
+ 		unsigned long size;
+ 	} header;
+ 	char wave[4];
+ 
+ #define RD_HDR()	(read(fd, &header, sizeof header) == sizeof header)
+ #define GETHDR(s)	(RD_HDR() && memcmp(header.magic, s, 4) == 0)
+ 
+ 	/* special handling for .wav audio files */
+ 
+ 	if (block_type == CDR_DB_RAW && GETHDR("RIFF")
+                                      && read(fd, wave, 4) == 4
+                                      && memcmp(wave, "WAVE", 4) == 0 ) {
+ 
+ 		while (RD_HDR()) {
+ 			/* return a pointer to the first "data" chunk */
+ 			if (memcmp(header.magic, "data", 4) == 0) {
+ 				trk->file_start = lseek(fd, 0, SEEK_CUR);
+ 				trk->file_size = header.size;
+ 				return;
+ 			}
+ 			else
+ 				lseek(fd, header.size, SEEK_CUR);
+ 		}
+ 	}
+ 	/* everything else is just a bytestream */
+ 	trk->file_size = sb->st_size;
+ 	trk->file_start = 0;
+ 	lseek(fd, pos, SEEK_SET);
+ }
+ 
+ void
  add_track(char *name, int block_size, int block_type, int nogap)
  {
  	struct stat sb;
***************
*** 299,312 ****
  	}
  	else if ((file = open(name, O_RDONLY, 0)) < 0)
  		err(EX_NOINPUT, "open(%s)", name);
  	if (fstat(file, &sb) < 0)
  		err(EX_IOERR, "fstat(%s)", name);
  	tracks[notracks].file = file;
  	tracks[notracks].file_name = name;
! 	if (file == STDIN_FILENO)
  		tracks[notracks].file_size = -1;
  	else
! 		tracks[notracks].file_size = sb.st_size;
  	tracks[notracks].block_size = block_size;
  	tracks[notracks].block_type = block_type;
  
--- 337,353 ----
  	}
  	else if ((file = open(name, O_RDONLY, 0)) < 0)
  		err(EX_NOINPUT, "open(%s)", name);
+ 
  	if (fstat(file, &sb) < 0)
  		err(EX_IOERR, "fstat(%s)", name);
+ 
  	tracks[notracks].file = file;
  	tracks[notracks].file_name = name;
! 	if (isatty(file))
  		tracks[notracks].file_size = -1;
  	else
! 		get_info(file, block_type, &sb, &tracks[notracks]);
! 
  	tracks[notracks].block_size = block_size;
  	tracks[notracks].block_type = block_type;
  
***************
*** 466,471 ****
--- 507,513 ----
  	char buf[2352*BLOCKS];
  	static int tot_size = 0;
  
+ 	lseek(track_info->file, track_info->file_start, SEEK_SET);
  	filesize = track_info->file_size / 1024;
  
  	if (ioctl(fd, CDRIOCSETBLOCKSIZE, &track_info->block_size) < 0)
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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