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

  
/* CD Player */
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/cdrom.h>
#include <stdio.h>

struct cdrom_msf msf;
int main(void)
{
   int TR_SIZE=50;
   int start=0, end=0;
   int fd = open("/dev/hdd", O_RDONLY | O_NONBLOCK);
   struct cdrom_msf0 track[TR_SIZE+2];
        
        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);

   if (start==0)
      start=1;
   
   msf.cdmsf_min0=track[start].minute;   /* x minutes + track y */
   msf.cdmsf_sec0=track[start].second;   /* x seconds + track y */
   msf.cdmsf_frame0=track[start].frame; 

   msf.cdmsf_min1=track[end].minute;   /* x minutes + track y */
   msf.cdmsf_sec1=track[end].second;  /* x seconds + track y */
   msf.cdmsf_frame1=track[end].frame;
   
   if (msf.cdmsf_frame1 > 0)
      msf.cdmsf_frame1--;
   else {
      if (msf.cdmsf_sec1 > 0) {
         msf.cdmsf_sec1--;
         msf.cdmsf_frame1=74;
      }
      else {
         msf.cdmsf_min1--;
         msf.cdmsf_sec1=59;
         msf.cdmsf_frame1=74;
      }
   }
     
   if ((ioctl(fd, CDROMPLAYMSF, &msf)) == -1)
       return 1;

   return 0;
}

Reply via email to