View | Details | Raw Unified | Return to bug 29292
Collapse All | Expand All

(-)burncd/Makefile (+1 lines)
Lines 1-6 Link Here
1
# $FreeBSD: src/usr.sbin/burncd/Makefile,v 1.2.2.1 2001/04/25 12:09:21 ru Exp $
1
# $FreeBSD: src/usr.sbin/burncd/Makefile,v 1.2.2.1 2001/04/25 12:09:21 ru Exp $
2
2
3
PROG=	burncd
3
PROG=	burncd
4
SRCS=	burncd.c readwav.c
4
MAN=	burncd.8
5
MAN=	burncd.8
5
6
6
.include <bsd.prog.mk>
7
.include <bsd.prog.mk>
(-)burncd/burncd.8 (+3 lines)
Lines 43-48 Link Here
43
.Op Fl p
43
.Op Fl p
44
.Op Fl q
44
.Op Fl q
45
.Op Fl t
45
.Op Fl t
46
.Op Fl w
46
.Op Ar command
47
.Op Ar command
47
.Op Ar command Ar
48
.Op Ar command Ar
48
.Sh DESCRIPTION
49
.Sh DESCRIPTION
Lines 70-75 Link Here
70
quiet, do not print progress messages.
71
quiet, do not print progress messages.
71
.It Fl t
72
.It Fl t
72
test write, do not actually write on the media.
73
test write, do not actually write on the media.
74
.It Fl w
75
audio images are treated as RIFF WAV format.
73
.El
76
.El
74
.Pp
77
.Pp
75
.Ar command
78
.Ar command
(-)burncd/burncd.c (-7 / +40 lines)
Lines 41-46 Link Here
41
#include <sys/cdrio.h>
41
#include <sys/cdrio.h>
42
#include <sys/param.h>
42
#include <sys/param.h>
43
43
44
#include "wavefmt.h"
45
44
#define BLOCKS	16
46
#define BLOCKS	16
45
47
46
void cleanup(int);
48
void cleanup(int);
Lines 49-54 Link Here
49
51
50
static int fd, quiet, saved_block_size;
52
static int fd, quiet, saved_block_size;
51
static struct cdr_track track;
53
static struct cdr_track track;
54
static int wav = 0;
52
55
53
int
56
int
54
main(int argc, char **argv)
57
main(int argc, char **argv)
Lines 59-65 Link Here
59
	int block_size = 0;
62
	int block_size = 0;
60
63
61
	prog_name = argv[0];
64
	prog_name = argv[0];
62
	while ((ch = getopt(argc, argv, "ef:lmpqs:t")) != -1) {
65
	while ((ch = getopt(argc, argv, "ef:lmpqs:tw")) != -1) {
63
		switch (ch) {
66
		switch (ch) {
64
		case 'e':
67
		case 'e':
65
			eject = 1;
68
			eject = 1;
Lines 94-99 Link Here
94
		case 't':
97
		case 't':
95
			test_write = 1;
98
			test_write = 1;
96
			break;
99
			break;
100
			
101
		case 'w':
102
			wav = 1;
103
		    break;
97
104
98
		default: 
105
		default: 
99
			usage(prog_name);
106
			usage(prog_name);
Lines 133-144 Link Here
133
				err(EX_IOERR, "ioctl(CDIOREADTOCENTRY)");
140
				err(EX_IOERR, "ioctl(CDIOREADTOCENTRY)");
134
			if (ioctl(fd, CDRIOCNEXTWRITEABLEADDR, &addr) < 0) 
141
			if (ioctl(fd, CDRIOCNEXTWRITEABLEADDR, &addr) < 0) 
135
				err(EX_IOERR, "ioctl(CDRIOCNEXTWRITEABLEADDR)");
142
				err(EX_IOERR, "ioctl(CDRIOCNEXTWRITEABLEADDR)");
136
			fprintf(stderr, "%d, %d\n", 
143
			fprintf(stderr, "%ld, %d\n", 
137
				ntohl(entry.entry.addr.lba), addr);
144
				ntohl(entry.entry.addr.lba), addr);
138
			break;
145
			break;
139
		}
146
		}
140
		if (!strcmp(argv[arg], "erase") || !strcmp(argv[arg], "blank")){
147
		if (!strcmp(argv[arg], "erase") || !strcmp(argv[arg], "blank")){
141
		    	int error, blank;
148
		    	int blank;
142
			if (!quiet)
149
			if (!quiet)
143
				fprintf(stderr, "%sing CD, please wait..\n",
150
				fprintf(stderr, "%sing CD, please wait..\n",
144
					argv[arg]);
151
					argv[arg]);
Lines 227-233 Link Here
227
usage(const char *prog_name)
234
usage(const char *prog_name)
228
{
235
{
229
	fprintf(stderr, "Usage: %s [-f device] [-s speed] [-e] [-l] [-m] [-p]\n"
236
	fprintf(stderr, "Usage: %s [-f device] [-s speed] [-e] [-l] [-m] [-p]\n"
230
		"\t[-q] [command] [command filename...]\n", prog_name);
237
		"\t[-q] [-w] [command] [command filename...]\n", prog_name);
231
	exit(EX_USAGE);
238
	exit(EX_USAGE);
232
}
239
}
233
240
Lines 238-243 Link Here
238
	char buf[2352*BLOCKS];
245
	char buf[2352*BLOCKS];
239
	struct stat stat;
246
	struct stat stat;
240
	static int cdopen, done_stdin, tot_size = 0;
247
	static int cdopen, done_stdin, tot_size = 0;
248
	static size_t datasize;
241
249
242
	if (!strcmp(name, "-")) {
250
	if (!strcmp(name, "-")) {
243
		if (done_stdin) {
251
		if (done_stdin) {
Lines 262-270 Link Here
262
	if (ioctl(fd, CDRIOCNEXTWRITEABLEADDR, &addr) < 0) 
270
	if (ioctl(fd, CDRIOCNEXTWRITEABLEADDR, &addr) < 0) 
263
       		err(EX_IOERR, "ioctl(CDRIOCNEXTWRITEABLEADDR)");
271
       		err(EX_IOERR, "ioctl(CDRIOCNEXTWRITEABLEADDR)");
264
272
265
	if (fstat(file, &stat) < 0)
273
	if (wav && track.datablock_type == CDR_DB_RAW) {
266
		err(EX_IOERR, "fstat(%s)", name);
274
		waveformat_t wf;
267
	filesize = stat.st_size / 1024;
275
		int ret;
276
277
		//fprintf(stderr, "checking wav header...\n");
278
		ret = read_wav_header(file, &wf, &datasize);
279
		if (ret)
280
			err(EX_IOERR, "read_wav_header(%d)", ret);
281
282
		if (wf.channels != 2 || wf.samples_per_sec != 44100 ||
283
			wf.bits_per_sample != 16)
284
			err(EX_IOERR, "CD-DA must be 44100Hz, 16bits, stereo.");
285
286
		filesize = datasize / 1024;
287
	}
288
	else {
289
		if (fstat(file, &stat) < 0)
290
			err(EX_IOERR, "fstat(%s)", name);
291
		filesize = stat.st_size / 1024;
292
	}
268
293
269
	if (!quiet) {
294
	if (!quiet) {
270
		fprintf(stderr, "next writeable LBA %d\n", addr);
295
		fprintf(stderr, "next writeable LBA %d\n", addr);
Lines 283-288 Link Here
283
308
284
	while ((count = read(file, buf, block_size * BLOCKS)) > 0) {	
309
	while ((count = read(file, buf, block_size * BLOCKS)) > 0) {	
285
		int res;
310
		int res;
311
312
		if (wav && track.datablock_type == CDR_DB_RAW) {
313
			if ((datasize - size) < (block_size * BLOCKS))
314
				count = datasize - size;
315
			else if (size == datasize)
316
				break;
317
		}
318
286
		if (count % block_size) {
319
		if (count % block_size) {
287
			/* pad file to % block_size */
320
			/* pad file to % block_size */
288
			bzero(&buf[count], block_size * BLOCKS - count);
321
			bzero(&buf[count], block_size * BLOCKS - count);
(-)burncd/readwav.c (+80 lines)
Line 0 Link Here
1
/*
2
 * Copyright (c) 1999,2000,2001 Yoshihide SONODA
3
 * All rights reserved.
4
 *
5
 * Last Modified: <2001/03/04 22:46:49>
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer,
12
 *    without modification, immediately at the beginning of the file.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 * 3. The name of the author may not be used to endorse or promote products
17
 *    derived from this software without specific prior written permission.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 * 
30
 */
31
32
#include <stdlib.h>
33
#include <unistd.h>
34
#include <fcntl.h>
35
#include "wavefmt.h"
36
37
int read_wav_header(int fd, pwaveformat_t pwavefmt, size_t *datasize)
38
{
39
    int header = 0;
40
    int size = 0;
41
    char *buff;
42
43
    lseek(fd, 0, SEEK_SET);
44
    *datasize = 0;
45
    read(fd, (void *)&header, sizeof(header));
46
    if (header != H_RIFF) {
47
		return ERR_NOT_RIFF;
48
    }
49
50
    read(fd, (void *)&size, sizeof(size));
51
    read(fd, (void *)&header, sizeof(header));
52
    if (header != H_WAVE) {
53
		return ERR_NOT_WAVE;
54
    }
55
56
    while(read(fd, (char *)&header, sizeof(int32_t)) == sizeof(int32_t)) {
57
		read(fd, (char *)&size, sizeof(int32_t));
58
59
		if (header == H_FMT_) {
60
			if ((size_t)size < sizeof(waveformat_t)) {
61
				return ERR_ILLEGAL_HEADER;
62
			}
63
			buff = alloca((size_t)size);
64
			read(fd, buff, size);
65
			memcpy((void *)pwavefmt, (void *)buff, sizeof(waveformat_t));
66
			if (pwavefmt->format_tag != 1) {
67
				return ERR_UNKNOWN_FORMAT;
68
			}
69
		}
70
		else if (header == H_DATA) {
71
			*datasize = (size_t)size;
72
			return 0;
73
		}
74
		else {
75
			lseek(fd, size, SEEK_CUR);
76
		}
77
    }
78
    
79
    return ERR_DATA_NOT_FOUND;
80
}
(-)burncd/wavefmt.h (+61 lines)
Line 0 Link Here
1
/*
2
 * Copyright (c) 1999,2000,2001 Yoshihide SONODA
3
 * All rights reserved.
4
 *
5
 * Last Modified: <2001/03/04 22:47:02>
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer,
12
 *    without modification, immediately at the beginning of the file.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 * 3. The name of the author may not be used to endorse or promote products
17
 *    derived from this software without specific prior written permission.
18
 *
19
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 * 
30
 */
31
32
#ifndef _WAVE_FMT_H_
33
#define _WAVE_FMT_H_
34
35
#include <sys/types.h>
36
37
#define H_RIFF (*(int32_t *)"RIFF")
38
#define H_WAVE (*(int32_t *)"WAVE")
39
#define H_DATA (*(int32_t *)"data")
40
#define H_FMT_ (*(int32_t *)"fmt ")
41
42
#define ERR_NONE     0
43
#define ERR_NOT_RIFF 1
44
#define ERR_NOT_WAVE 2
45
#define ERR_ILLEGAL_HEADER 3
46
#define ERR_UNKNOWN_FORMAT 4
47
#define ERR_DATA_NOT_FOUND 5
48
49
typedef struct waveformat
50
{
51
    u_int16_t format_tag;
52
    u_int16_t channels;
53
    u_int32_t samples_per_sec;
54
    u_int32_t bytes_per_sec;
55
    u_int16_t block_align;
56
    u_int16_t bits_per_sample;
57
} waveformat_t, *pwaveformat_t;
58
59
int read_wav_header(int fd, pwaveformat_t pwavefmt, size_t *datasize);
60
61
#endif /* _WAVE_FMT_H_ */

Return to bug 29292