FreeBSD Bugzilla – Attachment 15856 Details for
Bug 29292
[patch] addition to burncd(8) for specific handling of .wav files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 9.16 KB, created by
yshd
on 2001-07-29 07:00:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
yshd
Created:
2001-07-29 07:00:01 UTC
Size:
9.16 KB
patch
obsolete
>diff -uNr /usr/src/usr.sbin/burncd/Makefile burncd/Makefile >--- /usr/src/usr.sbin/burncd/Makefile Fri Apr 27 00:52:18 2001 >+++ burncd/Makefile Sun Jul 29 13:38:59 2001 >@@ -1,6 +1,7 @@ > # $FreeBSD: src/usr.sbin/burncd/Makefile,v 1.2.2.1 2001/04/25 12:09:21 ru Exp $ > > PROG= burncd >+SRCS= burncd.c readwav.c > MAN= burncd.8 > > .include <bsd.prog.mk> >diff -uNr /usr/src/usr.sbin/burncd/burncd.8 burncd/burncd.8 >--- /usr/src/usr.sbin/burncd/burncd.8 Tue Feb 27 00:13:33 2001 >+++ burncd/burncd.8 Sun Jul 29 13:13:42 2001 >@@ -43,6 +43,7 @@ > .Op Fl p > .Op Fl q > .Op Fl t >+.Op Fl w > .Op Ar command > .Op Ar command Ar > .Sh DESCRIPTION >@@ -70,6 +71,8 @@ > quiet, do not print progress messages. > .It Fl t > test write, do not actually write on the media. >+.It Fl w >+audio images are treated as RIFF WAV format. > .El > .Pp > .Ar command >diff -uNr /usr/src/usr.sbin/burncd/burncd.c burncd/burncd.c >--- /usr/src/usr.sbin/burncd/burncd.c Tue Feb 27 00:13:33 2001 >+++ burncd/burncd.c Sun Jul 29 13:12:20 2001 >@@ -41,6 +41,8 @@ > #include <sys/cdrio.h> > #include <sys/param.h> > >+#include "wavefmt.h" >+ > #define BLOCKS 16 > > void cleanup(int); >@@ -49,6 +51,7 @@ > > static int fd, quiet, saved_block_size; > static struct cdr_track track; >+static int wav = 0; > > int > main(int argc, char **argv) >@@ -59,7 +62,7 @@ > int block_size = 0; > > prog_name = argv[0]; >- while ((ch = getopt(argc, argv, "ef:lmpqs:t")) != -1) { >+ while ((ch = getopt(argc, argv, "ef:lmpqs:tw")) != -1) { > switch (ch) { > case 'e': > eject = 1; >@@ -94,6 +97,10 @@ > case 't': > test_write = 1; > break; >+ >+ case 'w': >+ wav = 1; >+ break; > > default: > usage(prog_name); >@@ -133,12 +140,12 @@ > err(EX_IOERR, "ioctl(CDIOREADTOCENTRY)"); > if (ioctl(fd, CDRIOCNEXTWRITEABLEADDR, &addr) < 0) > err(EX_IOERR, "ioctl(CDRIOCNEXTWRITEABLEADDR)"); >- fprintf(stderr, "%d, %d\n", >+ fprintf(stderr, "%ld, %d\n", > ntohl(entry.entry.addr.lba), addr); > break; > } > if (!strcmp(argv[arg], "erase") || !strcmp(argv[arg], "blank")){ >- int error, blank; >+ int blank; > if (!quiet) > fprintf(stderr, "%sing CD, please wait..\n", > argv[arg]); >@@ -227,7 +234,7 @@ > usage(const char *prog_name) > { > fprintf(stderr, "Usage: %s [-f device] [-s speed] [-e] [-l] [-m] [-p]\n" >- "\t[-q] [command] [command filename...]\n", prog_name); >+ "\t[-q] [-w] [command] [command filename...]\n", prog_name); > exit(EX_USAGE); > } > >@@ -238,6 +245,7 @@ > char buf[2352*BLOCKS]; > struct stat stat; > static int cdopen, done_stdin, tot_size = 0; >+ static size_t datasize; > > if (!strcmp(name, "-")) { > if (done_stdin) { >@@ -262,9 +270,26 @@ > if (ioctl(fd, CDRIOCNEXTWRITEABLEADDR, &addr) < 0) > err(EX_IOERR, "ioctl(CDRIOCNEXTWRITEABLEADDR)"); > >- if (fstat(file, &stat) < 0) >- err(EX_IOERR, "fstat(%s)", name); >- filesize = stat.st_size / 1024; >+ if (wav && track.datablock_type == CDR_DB_RAW) { >+ waveformat_t wf; >+ int ret; >+ >+ //fprintf(stderr, "checking wav header...\n"); >+ ret = read_wav_header(file, &wf, &datasize); >+ if (ret) >+ err(EX_IOERR, "read_wav_header(%d)", ret); >+ >+ if (wf.channels != 2 || wf.samples_per_sec != 44100 || >+ wf.bits_per_sample != 16) >+ err(EX_IOERR, "CD-DA must be 44100Hz, 16bits, stereo."); >+ >+ filesize = datasize / 1024; >+ } >+ else { >+ if (fstat(file, &stat) < 0) >+ err(EX_IOERR, "fstat(%s)", name); >+ filesize = stat.st_size / 1024; >+ } > > if (!quiet) { > fprintf(stderr, "next writeable LBA %d\n", addr); >@@ -283,6 +308,14 @@ > > while ((count = read(file, buf, block_size * BLOCKS)) > 0) { > int res; >+ >+ if (wav && track.datablock_type == CDR_DB_RAW) { >+ if ((datasize - size) < (block_size * BLOCKS)) >+ count = datasize - size; >+ else if (size == datasize) >+ break; >+ } >+ > if (count % block_size) { > /* pad file to % block_size */ > bzero(&buf[count], block_size * BLOCKS - count); >diff -uNr /usr/src/usr.sbin/burncd/readwav.c burncd/readwav.c >--- /usr/src/usr.sbin/burncd/readwav.c Thu Jan 1 09:00:00 1970 >+++ burncd/readwav.c Sun Mar 4 22:46:51 2001 >@@ -0,0 +1,80 @@ >+/* >+ * Copyright (c) 1999,2000,2001 Yoshihide SONODA >+ * All rights reserved. >+ * >+ * Last Modified: <2001/03/04 22:46:49> >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer, >+ * without modification, immediately at the beginning of the file. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. The name of the author may not be used to endorse or promote products >+ * derived from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR >+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES >+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. >+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, >+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT >+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ * >+ */ >+ >+#include <stdlib.h> >+#include <unistd.h> >+#include <fcntl.h> >+#include "wavefmt.h" >+ >+int read_wav_header(int fd, pwaveformat_t pwavefmt, size_t *datasize) >+{ >+ int header = 0; >+ int size = 0; >+ char *buff; >+ >+ lseek(fd, 0, SEEK_SET); >+ *datasize = 0; >+ read(fd, (void *)&header, sizeof(header)); >+ if (header != H_RIFF) { >+ return ERR_NOT_RIFF; >+ } >+ >+ read(fd, (void *)&size, sizeof(size)); >+ read(fd, (void *)&header, sizeof(header)); >+ if (header != H_WAVE) { >+ return ERR_NOT_WAVE; >+ } >+ >+ while(read(fd, (char *)&header, sizeof(int32_t)) == sizeof(int32_t)) { >+ read(fd, (char *)&size, sizeof(int32_t)); >+ >+ if (header == H_FMT_) { >+ if ((size_t)size < sizeof(waveformat_t)) { >+ return ERR_ILLEGAL_HEADER; >+ } >+ buff = alloca((size_t)size); >+ read(fd, buff, size); >+ memcpy((void *)pwavefmt, (void *)buff, sizeof(waveformat_t)); >+ if (pwavefmt->format_tag != 1) { >+ return ERR_UNKNOWN_FORMAT; >+ } >+ } >+ else if (header == H_DATA) { >+ *datasize = (size_t)size; >+ return 0; >+ } >+ else { >+ lseek(fd, size, SEEK_CUR); >+ } >+ } >+ >+ return ERR_DATA_NOT_FOUND; >+} >diff -uNr /usr/src/usr.sbin/burncd/wavefmt.h burncd/wavefmt.h >--- /usr/src/usr.sbin/burncd/wavefmt.h Thu Jan 1 09:00:00 1970 >+++ burncd/wavefmt.h Sun Mar 4 22:47:04 2001 >@@ -0,0 +1,61 @@ >+/* >+ * Copyright (c) 1999,2000,2001 Yoshihide SONODA >+ * All rights reserved. >+ * >+ * Last Modified: <2001/03/04 22:47:02> >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer, >+ * without modification, immediately at the beginning of the file. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * 3. The name of the author may not be used to endorse or promote products >+ * derived from this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR >+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES >+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. >+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, >+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT >+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF >+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ * >+ */ >+ >+#ifndef _WAVE_FMT_H_ >+#define _WAVE_FMT_H_ >+ >+#include <sys/types.h> >+ >+#define H_RIFF (*(int32_t *)"RIFF") >+#define H_WAVE (*(int32_t *)"WAVE") >+#define H_DATA (*(int32_t *)"data") >+#define H_FMT_ (*(int32_t *)"fmt ") >+ >+#define ERR_NONE 0 >+#define ERR_NOT_RIFF 1 >+#define ERR_NOT_WAVE 2 >+#define ERR_ILLEGAL_HEADER 3 >+#define ERR_UNKNOWN_FORMAT 4 >+#define ERR_DATA_NOT_FOUND 5 >+ >+typedef struct waveformat >+{ >+ u_int16_t format_tag; >+ u_int16_t channels; >+ u_int32_t samples_per_sec; >+ u_int32_t bytes_per_sec; >+ u_int16_t block_align; >+ u_int16_t bits_per_sample; >+} waveformat_t, *pwaveformat_t; >+ >+int read_wav_header(int fd, pwaveformat_t pwavefmt, size_t *datasize); >+ >+#endif /* _WAVE_FMT_H_ */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 29292
: 15856