Subject: is CDIOCPLAYTRACKS broken?
To: None <current-users@NetBSD.ORG>
From: Kent Vander Velden <graphix@iastate.edu>
List: current-users
Date: 12/01/1995 16:27:08
The subject says it all. I can not seem to get CDIOCPLAYTRACKS to
actually start playing an audio cd. CDIOCPLAYBLOCKS works fine though
I have yet to find a way to determine the number of tracks on the disk.
The error that is returned by perror() is "Invalid Argument". The
error that is sent to the console is:
cd6(aha0:2:6): illegal request. data = 00 00 00 00 20 00 00 00 00 00
Perhaps there is something more that needs to be done before using
CDIOCPLAYTRACKS. Here is the code in question:
#include <sys/ioctl.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/cdio.h>
int
main(void) {
char *device="/dev/cd6a";
int fd;
if( (fd=open(device, O_RDONLY)) == -1) {
perror("open");
exit(EXIT_FAILURE);
}
{
struct ioc_toc_header th;
if( ioctl(fd, CDIOREADTOCHEADER, &th) == -1) {
perror("ioctl(CDIOREADTOCHEADER)");
exit(EXIT_FAILURE);
}
printf("start: %d end: %d len: %d\n", th.starting_track, th.ending_track, th.len);
}
{
struct ioc_play_track pt;
pt.start_track=1;
pt.start_index=1;
pt.end_track=2;
pt.end_index=1;
if( ioctl(fd, CDIOCPLAYTRACKS, &pt) == -1) {
perror("ioctl(CDIOCPLAYTRACKS)");
}
}
{
struct ioc_play_blocks pb;
pb.blk=1;
pb.len=100000;
if( ioctl(fd, CDIOCPLAYBLOCKS, &pb) == -1) {
perror("ioctl(CDIOCPLAYBLOCKS)");
}
}
/*
if( ioctl(fd, CDIOCALLOW) == -1) {
perror("ioctl(CDIOCALLOW)");
exit(EXIT_FAILURE);
}
if( ioctl(fd, CDIOCEJECT) == -1) {
perror("ioctl");
exit(EXIT_FAILURE);
}
*/
close(fd);
return 0;
}
---
Kent Vander Velden
graphix@iastate.edu