version 1.60, 2008/06/08 21:40:58 |
version 1.61, 2008/06/11 21:59:25 |
|
|
int play_track(int, int, int, int); |
int play_track(int, int, int, int); |
int get_vol(int *, int *); |
int get_vol(int *, int *); |
int status(int *, int *, int *, int *); |
int status(int *, int *, int *, int *); |
|
__dead void tao(int argc, char **argv); |
int play(char *arg); |
int play(char *arg); |
int info(char *arg); |
int info(char *arg); |
int cddbinfo(char *arg); |
int cddbinfo(char *arg); |
|
|
{ |
{ |
int ch, cmd; |
int ch, cmd; |
char *arg; |
char *arg; |
struct stat sb; |
|
struct track_info *cur_track; |
|
struct track_info *tr; |
|
off_t availblk, needblk = 0; |
|
u_int blklen; |
|
u_int ntracks = 0; |
|
char type; |
|
int cap; |
|
|
|
cdname = getenv("DISC"); |
cdname = getenv("DISC"); |
if (!cdname) |
if (!cdname) |
|
|
"No CD device name specified. Defaulting to %s.\n", cdname); |
"No CD device name specified. Defaulting to %s.\n", cdname); |
} |
} |
|
|
if (argc > 0 && ! strcasecmp(*argv, "tao")) { |
if (argc > 0 && !strcasecmp(*argv, "tao")) { |
if (argc == 1) |
tao(argc, argv); |
usage(); |
/* NOTREACHED */ |
SLIST_INIT(&tracks); |
|
type = 'd'; |
|
blklen = 2048; |
|
while (argc > 1) { |
|
tr = malloc(sizeof(struct track_info)); |
|
tr->type = type; |
|
optreset = 1; |
|
optind = 1; |
|
while ((ch = getopt(argc, argv, "ad")) != -1) { |
|
switch (ch) { |
|
case 'a': |
|
type = 'a'; |
|
blklen = 2352; |
|
break; |
|
case 'd': |
|
type = 'd'; |
|
blklen = 2048; |
|
break; |
|
default: |
|
usage(); |
|
} |
|
} |
|
tr->type = type; |
|
tr->blklen = blklen; |
|
argc -= optind; |
|
argv += optind; |
|
if (argv[0] == NULL) |
|
usage(); |
|
tr->file = argv[0]; |
|
tr->fd = open(tr->file, O_RDONLY, 0640); |
|
if (tr->fd == -1) |
|
err(1, "cannot open file %s", tr->file); |
|
if (fstat(tr->fd, &sb) == -1) |
|
err(1, "cannot stat file %s", tr->file); |
|
tr->sz = sb.st_size; |
|
if (tr->type == 'a') |
|
tr->sz -= WAVHDRLEN; |
|
if (SLIST_EMPTY(&tracks)) |
|
SLIST_INSERT_HEAD(&tracks, tr, track_list); |
|
else |
|
SLIST_INSERT_AFTER(cur_track, tr, track_list); |
|
cur_track = tr; |
|
} |
|
if (!open_cd(cdname, 1)) |
|
exit(1); |
|
|
|
if (get_media_capabilities(&cap) == -1) |
|
errx(1, "Can't determine media type"); |
|
if ((cap & MEDIACAP_TAO) == 0) |
|
errx(1, "The media can't be written in TAO mode"); |
|
|
|
get_disc_size(&availblk); |
|
SLIST_FOREACH(tr, &tracks, track_list) { |
|
needblk += tr->sz/tr->blklen; |
|
ntracks++; |
|
} |
|
needblk += (ntracks - 1) * 150; /* transition area between tracks */ |
|
if (needblk > availblk) |
|
errx(1, "Only %llu of the required %llu blocks available", |
|
availblk, needblk); |
|
if (writetao(&tracks) != 0) |
|
exit(1); |
|
else |
|
exit(0); |
|
} |
} |
if (argc > 0) { |
if (argc > 0) { |
char buf[80], *p; |
char buf[80], *p; |
|
|
return (0); |
return (0); |
|
|
} |
} |
|
} |
|
|
|
__dead void |
|
tao(int argc, char **argv) |
|
{ |
|
struct stat sb; |
|
struct track_info *cur_track; |
|
struct track_info *tr; |
|
off_t availblk, needblk = 0; |
|
u_int blklen; |
|
u_int ntracks = 0; |
|
char type; |
|
int ch, cap; |
|
|
|
if (argc == 1) |
|
usage(); |
|
|
|
SLIST_INIT(&tracks); |
|
type = 'd'; |
|
blklen = 2048; |
|
while (argc > 1) { |
|
tr = malloc(sizeof(struct track_info)); |
|
if (tr == NULL) |
|
err(1, "tao"); |
|
|
|
tr->type = type; |
|
optreset = 1; |
|
optind = 1; |
|
while ((ch = getopt(argc, argv, "ad")) != -1) { |
|
switch (ch) { |
|
case 'a': |
|
type = 'a'; |
|
blklen = 2352; |
|
break; |
|
case 'd': |
|
type = 'd'; |
|
blklen = 2048; |
|
break; |
|
default: |
|
usage(); |
|
/* NOTREACHED */ |
|
} |
|
} |
|
|
|
tr->type = type; |
|
tr->blklen = blklen; |
|
argc -= optind; |
|
argv += optind; |
|
if (argv[0] == NULL) |
|
usage(); |
|
tr->file = argv[0]; |
|
tr->fd = open(tr->file, O_RDONLY, 0640); |
|
if (tr->fd == -1) |
|
err(1, "cannot open file %s", tr->file); |
|
if (fstat(tr->fd, &sb) == -1) |
|
err(1, "cannot stat file %s", tr->file); |
|
tr->sz = sb.st_size; |
|
if (tr->type == 'a') |
|
tr->sz -= WAVHDRLEN; |
|
if (SLIST_EMPTY(&tracks)) |
|
SLIST_INSERT_HEAD(&tracks, tr, track_list); |
|
else |
|
SLIST_INSERT_AFTER(cur_track, tr, track_list); |
|
cur_track = tr; |
|
} |
|
|
|
if (!open_cd(cdname, 1)) |
|
exit(1); |
|
if (get_media_capabilities(&cap) == -1) |
|
errx(1, "Can't determine media type"); |
|
if ((cap & MEDIACAP_TAO) == 0) |
|
errx(1, "The media can't be written in TAO mode"); |
|
|
|
get_disc_size(&availblk); |
|
SLIST_FOREACH(tr, &tracks, track_list) { |
|
needblk += tr->sz/tr->blklen; |
|
ntracks++; |
|
} |
|
needblk += (ntracks - 1) * 150; /* transition area between tracks */ |
|
if (needblk > availblk) |
|
errx(1, "Only %llu of the required %llu blocks available", |
|
availblk, needblk); |
|
if (writetao(&tracks) != 0) |
|
exit(1); |
|
else |
|
exit(0); |
} |
} |
|
|
int |
int |