Пример #1
0
/*
 * Play the CD from one position to another (both in frames.)
 */
int
gen_play( struct wm_drive *d, int start, int end )
{
    struct CD_PlayAddr msf;

    msf.addrmode			= CD_MSF;
    msf.addr.msf.startmsf.min	= start / (60*75);
    msf.addr.msf.startmsf.sec	= (start % (60*75)) / 75;
    msf.addr.msf.startmsf.frame	= start % 75;
    msf.addr.msf.endmsf.min		= end / (60*75);
    msf.addr.msf.endmsf.sec		= (end % (60*75)) / 75;
    msf.addr.msf.endmsf.frame	= end % 75;

    if (CD_Play(d->fd, &msf)) {
        wm_lib_message(WM_MSG_LEVEL_ERROR|WM_MSG_CLASS,
                       "wm_cd_play_chunk(%d,%d)\n",start,end);
        wm_lib_message(WM_MSG_LEVEL_ERROR|WM_MSG_CLASS,
                       "msf = %d:%d:%d %d:%d:%d\n",
                       msf.addr.msf.startmsf.min,
                       msf.addr.msf.startmsf.sec,
                       msf.addr.msf.startmsf.frame,
                       msf.addr.msf.endmsf.min,
                       msf.addr.msf.endmsf.sec,
                       msf.addr.msf.endmsf.frame);
        wm_lib_message(WM_MSG_LEVEL_ERROR|WM_MSG_CLASS,
                       "CD_Play");
        return -1;
    }

    return 0;
} /* gen_play() */
Пример #2
0
/*
 * Re-Open the device if it is open.
 */
int
wmcd_reopen( struct wm_drive *d )
{
  int status;
  
  do {
    wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "wmcd_reopen\n");
    status = gen_close( d );
    wm_susleep( 1000 );
    wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "calling wmcd_open()\n");
    status = wmcd_open( d ); /* open it as usual */
    wm_susleep( 1000 );
  } while ( status != 0 );
  return status;
} /* wmcd_reopen() */
Пример #3
0
/*
 * Open the CD device and figure out what kind of drive is attached.
 */
int
gen_open( struct wm_drive *d )
{
    if (d->fd > -1) {		/* Device already open? */
        wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "gen_open(): [device is open (fd=%d)]\n", d->fd);
        return 0;
    }

    intermittent_dev = 1;

    if ((d->fd = CD_Open(d->cd_device, 0)) < 0) {
        /* Solaris 2.2 volume manager moves links around */
        if (errno == ENOENT && intermittent_dev)
            return 0;

        if (errno == EACCES)
            return -EACCES;
        else if (errno != EIO)	/* defined at top */
            return -6;

        /* No CD in drive. */
        return 1;
    }

    return 0;
} /* gen_open() */
Пример #4
0
int
gen_close( struct wm_drive *d )
{
    if(d->fd != -1) {
        wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "closing the device\n");
        close(d->fd);
        d->fd = -1;
    }
    return 0;
}
Пример #5
0
int
gen_close( struct wm_drive *d )
{
    int ret = 0;
    if(d->fd != -1) {
        wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "closing the device.\n");
        ret = CD_Close(d->fd);
        d->fd = -1;
        wm_susleep(3000000);
    }
    return ret;
}
Пример #6
0
/*
 * Open the CD device and figure out what kind of drive is attached.
 */
int
wmcd_open(struct wm_drive *d)
{
  int		fd;
  static int	warned = 0;
  char vendor[32] = WM_STR_GENVENDOR;
  char  model[32] = WM_STR_GENMODEL;
  char    rev[32] = WM_STR_GENREV;
  int i;
  
  if (d->fd >= 0)		/* Device already open? */
    {
       wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "wmcd_open(): [device is open (fd=%d)]\n", d->fd);
       return (0);
    }
  
  if (d->cd_device == NULL)
    {
      for (i = 0; cds[i] != NULL; i++)
      {
      	  d->cd_device = cds[i];
	  d->fd = open(d->cd_device, O_RDONLY);
	  if (d->fd >= 0)
	    break;
      }
    }
  else
  	d->fd = open(d->cd_device, O_RDONLY);
  if (d->fd < 0)
    {
      if (errno == EIO)
      /* No CD in drive. */
      	return 1;
      else
      	return -errno;
    }
  
  /* Now fill in the relevant parts of the wm_drive structure. */
  fd = d->fd;
  
  find_drive_struct(vendor, model, rev);
  
  (d->init)(d);
  
  d->fd = fd;
  
  return (0);
} /* wmcd_open() */
Пример #7
0
/*
 * Open the CD device and figure out what kind of drive is attached.
 */
int
gen_open(struct wm_drive *d)
{
	if (d->fd >= 0) {		/* Device already open? */
       wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "gen_open(): [device is open (fd=%d)]\n", d->fd);
       return 0;
    }

	d->fd = open(d->cd_device, O_RDONLY);
  	if (d->fd < 0) {
      	if (errno == EIO) /* No CD in drive. */
      		return 1;
      	else
      		return -errno;
    }

  	return 0;
} /* gen_open() */
Пример #8
0
/*
 * Open the CD and figure out which kind of drive is attached.
 */
int
gen_open(struct wm_drive *d)
{
    if (d->fd > -1) {		/* Device already open? */
        wm_lib_message(WM_MSG_LEVEL_DEBUG|WM_MSG_CLASS, "gen_open(): [device is open (fd=%d)]\n", d->fd);
        return 0;
    }

    d->fd = create_cdrom_node(d->cd_device); /* this will do open */
    if (d->fd < 0) {
        if (errno == EACCES) {
        } else if (errno != EINTR) {
            perror(d->cd_device);
            return -6;
        }

        /* cannot access CDROM device */
        return -1;
    }

    return 0;
} /* gen_open */