I've never programmed the CD before, so this was very enlightening. My main question is: Why use the msf structs? The attached program is simpler and seems to do exactly what you are looking for. Torbjørn Kristoffersen wrote: > > Hello, > > I've attached a small CD-Player program which can't seem to work properly. > > When I compile and run it. I type: > > Start > 0 > End > 1 > > This works. It should then start playing Track 1. However, it stops > when it has played in about 1 minute. > > Now that's one problem, the other one occurs when I try to play other > tracks. Typing '2' and '3' instead of '0' and '1' doesn't work at all. > The program dumps a bunch of errors all over the screen and stops. > (The error message contains this and more: > "The failed "Play Audio MSF" packet command was:" > "Error: Illegal request -- (Sense key=0x05)" > > Can someone look at my program and try to figure out what's wrong? > > Thanks in advance! > Torbjørn S. Kristoffersen > > > > ------------------------------------------------------------------------ > Name: cd.c > cd.c Type: Plain Text (TEXT/PLAIN) > Encoding: BASE64
/* CD Player */ #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/cdrom.h> #include <stdio.h> struct cdrom_ti ti; int main(void) { int start=0, end=0; int fd = open("/dev/cdrom", O_RDONLY | O_NONBLOCK); if (fd < 0) { perror("open(\"/dev/cdrom\") failed"); return 1; } printf("Start at track > "); scanf("%d", &start); printf("End at track > "); scanf("%d", &end); ioctl(fd, CDROMSTOP); ioctl(fd, CDROMSTART); ti.cdti_trk0 = start; ti.cdti_ind0 = 0; ti.cdti_trk1 = end; ti.cdti_ind1 = 0; if ((ioctl(fd, CDROMPLAYTRKIND, &ti)) == -1) return 1; return 0; }