Exemple #1
0
int
main(int argc, const char *argv[])
{
  char **ppsz_cd_drives=NULL, **c;
  
  cdio_log_set_handler (log_handler);

  /* Print out a list of CD-drives */
  ppsz_cd_drives = cdio_get_devices(DRIVER_DEVICE);
  if (NULL != ppsz_cd_drives) 
    for( c = ppsz_cd_drives; *c != NULL; c++ ) {
      printf("Drive %s\n", *c);
    }

  cdio_free_device_list(ppsz_cd_drives);
  ppsz_cd_drives = NULL;
  
  printf("-----\n");

  /* Print out a list of CD-drives the harder way. */
  ppsz_cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_MATCH_ALL, false);

  if (NULL != ppsz_cd_drives) {
    for( c = ppsz_cd_drives; *c != NULL; c++ ) {
      printf("Drive %s\n", *c);
    }
    
  }
  cdio_free_device_list(ppsz_cd_drives);

  printf("-----\n");
  printf("CD-DA drives...\n");
  ppsz_cd_drives = NULL;
  /* Print out a list of CD-drives with CD-DA's in them. */
  ppsz_cd_drives = cdio_get_devices_with_cap(NULL,  CDIO_FS_AUDIO, false);

  if (NULL != ppsz_cd_drives) {
    for( c = ppsz_cd_drives; *c != NULL; c++ ) {
      printf("drive: %s\n", *c);
    }
  }
  cdio_free_device_list(ppsz_cd_drives);
    
  printf("-----\n");
  ppsz_cd_drives = NULL;
  printf("VCD drives...\n");
  /* Print out a list of CD-drives with VCD's in them. */
  ppsz_cd_drives = cdio_get_devices_with_cap(NULL, 
(CDIO_FS_ANAL_SVCD|CDIO_FS_ANAL_CVD|CDIO_FS_ANAL_VIDEOCD|CDIO_FS_UNKNOWN),
					true);
  if (NULL != ppsz_cd_drives) {
    for( c = ppsz_cd_drives; *c != NULL; c++ ) {
      printf("drive: %s\n", *c);
    }
  }

  cdio_free_device_list(ppsz_cd_drives);
  return 0;
  
}
static char *
cdio_detect_device(void)
{
	char **devices = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
	if (devices == NULL)
		return NULL;

	char *device = g_strdup(devices[0]);
	cdio_free_device_list(devices);

	return device;
}
Exemple #3
0
static void 
print_drive_class(const char *psz_msg, cdio_fs_anal_t bitmask, bool b_any) {
  char **ppsz_cd_drives=NULL, **c;

  printf("-- %s...\n", psz_msg);
  ppsz_cd_drives = cdio_get_devices_with_cap(NULL, bitmask, b_any);
  if (NULL != ppsz_cd_drives) 
    for( c = ppsz_cd_drives; *c != NULL; c++ ) {
      printf("-- Drive %s\n", *c);
    }

  cdio_free_device_list(ppsz_cd_drives);
  printf("-----\n");
}
Exemple #4
0
static int
cda_action_add_cd (DB_plugin_action_t *act, int ctx)
{
    /* Get all devices containg CD audio media */
    cdio_close_tray(NULL, NULL);
    char **device_list = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
    if (!device_list) {
        return 0;
    }

    char *drive_device = NULL;
    if (device_list[0] && device_list[1]) {
        /* Multiple devices, ask the user to pick one */
        size_t device_count;
        size_t device_combo_length = sizeof(DRIVE_COMBO_SCRIPT);
        for (device_count = 0; device_list[device_count]; device_count++) {
            device_combo_length += strlen(device_list[device_count]) + 1;
        }

        char *layout = malloc(device_combo_length);
        if (layout) {
            sprintf(layout, DRIVE_COMBO_SCRIPT, device_count);
            for (char **device = device_list; *device; device++) {
                strcat(layout, " ");
                strcat(layout, *device);
            }
            strcat(layout, ";");

            ddb_dialog_t conf = {
                .title = "Audio CD Drive",
                .layout = layout,
                .set_param = set_param,
                .get_param = get_param,
                .parent = NULL
            };

            struct DB_plugin_s **plugin_list;
            for (plugin_list = deadbeef->plug_get_list(); *plugin_list && (*plugin_list)->type != DB_PLUGIN_GUI; plugin_list++);
            if (*plugin_list) {
                DB_gui_t *gui_plugin = (DB_gui_t *)*plugin_list;
                if (gui_plugin->run_dialog(&conf, 1<<ddb_button_ok|1<<ddb_button_cancel, NULL, NULL) == ddb_button_ok) {
                    drive_device = device_list[dialog_combo_index];
                }
            }
            free(layout);
        }
    }
    else if (device_list[0]) {
/* mutex must be locked */
static void open_cd (void)
{
    AUDDBG ("Opening CD drive.\n");
    g_return_if_fail (pcdrom_drive == NULL);

    /* find an available, audio capable, cd drive  */
    if (cdng_cfg.device != NULL && strlen (cdng_cfg.device) > 0)
    {
        pcdrom_drive = cdda_identify (cdng_cfg.device, 1, NULL);
        if (pcdrom_drive == NULL)
        {
            cdaudio_error ("Failed to open CD device \"%s\".", cdng_cfg.device);
            return;
        }
    }
    else
    {
        gchar **ppcd_drives =
            cdio_get_devices_with_cap (NULL, CDIO_FS_AUDIO, false);

        if (ppcd_drives != NULL && *ppcd_drives != NULL)
        {                       /* we have at least one audio capable cd drive */
            pcdrom_drive = cdda_identify (*ppcd_drives, 1, NULL);
            if (pcdrom_drive == NULL)
            {
                cdaudio_error ("Failed to open CD.");
                return;
            }
            AUDDBG ("found cd drive \"%s\" with audio capable media\n",
                   *ppcd_drives);
        }
        else
        {
            cdaudio_error ("No audio capable CD drive found.");
            return;
        }

        if (ppcd_drives != NULL && *ppcd_drives != NULL)
            cdio_free_device_list (ppcd_drives);
    }
}
		cdio() {
			/* See if we can find a device with a loaded CD-DA in it. */
			ppsz_cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);

			if (ppsz_cd_drives) {
				/* Found such a CD-ROM with a CD-DA loaded. Use the first drive in the list. */
				d = cdio_cddap_identify(*ppsz_cd_drives, 1, NULL);
			} else {
				printf("Unable find or access a CD-ROM drive with an audio CD in it.\n");
			}

			/* Don't need a list of CD's with CD-DA's any more. */
			if (ppsz_cd_drives) cdio_free_device_list(ppsz_cd_drives);

			/* We'll set for verbose paranoia messages. */
			if (d) cdio_cddap_verbose_set(d, CDDA_MESSAGE_PRINTIT, CDDA_MESSAGE_PRINTIT);

			if ( d && cdio_cddap_open(d) != 0 ) {
				printf("Unable to open disc.\n");
			}
		}
Exemple #7
0
int
main(int argc, char *argv[])
{
  int  c;
  char *h;
  int  i_rc = 0;
  int  i_volume_level = -1;
  cd_operation_t todo = NO_OP; /* operation to do in non-interactive mode */

  psz_program = strrchr(argv[0],'/');
  psz_program = psz_program ? psz_program+1 : argv[0];

  /* parse options */
  while ( 1 ) {
    if (-1 == (c = getopt(argc, argv, "aCdehkpL:sSt:vx")))
      break;
    switch (c) {
    case 'v':
      b_verbose = true;
      break;
    case 'd':
      debug = 1;
      break;
    case 'a':
      auto_mode = 1;
      break;
    case 'L':
      if (NULL != strchr(optarg,'-')) {
	i_volume_level = atoi(optarg);
	todo = SET_VOLUME;
      }
      break;
    case 't':
      if (NULL != (h = strchr(optarg,'-'))) {
	*h = 0;
	start_track = atoi(optarg);
	stop_track = atoi(h+1)+1;
	if (0 == start_track) start_track = 1;
	if (1 == stop_track)  stop_track  = CDIO_CDROM_LEADOUT_TRACK;
      } else {
	start_track = atoi(optarg);
	stop_track = start_track+1;
	one_track = 1;
      }
      todo = PLAY_TRACK;
      break;
    case 'p':
      todo = PLAY_CD;
      break;
    case 'C':
      todo = CLOSE_CD;
      break;
      break;
    case 's':
      todo = STOP_PLAYING;
      break;
    case 'S':
      todo = LIST_SUBCHANNEL;
      break;
    case 'e':
      todo = EJECT_CD;
      break;
    case 'h':
      usage(psz_program);
      exit(1);
    default:
      usage(psz_program);
      exit(1);
    }
  }

  if (argc > optind) {
    psz_device = strdup(argv[optind]);
  } else {
    char **ppsz_cdda_drives=NULL;
    char **ppsz_all_cd_drives = cdio_get_devices_ret(&driver_id);

    if (!ppsz_all_cd_drives) {
      fprintf(stderr, "Can't find a CD-ROM drive\n");
      exit(2);
    }
    ppsz_cdda_drives = cdio_get_devices_with_cap(ppsz_all_cd_drives,
						 CDIO_FS_AUDIO, false);
    if (!ppsz_cdda_drives || !ppsz_cdda_drives[0]) {
      fprintf(stderr, "Can't find a CD-ROM drive with a CD-DA in it\n");
      exit(3);
    }
    psz_device = strdup(ppsz_cdda_drives[0]);
    cdio_free_device_list(ppsz_all_cd_drives);
    cdio_free_device_list(ppsz_cdda_drives);
  }

  if (!b_cd && todo != EJECT_CD) {
    cd_close(psz_device);
  }

  /* open device */
  if (b_verbose)
    fprintf(stderr,"open %s... ", psz_device);

  p_cdio = cdio_open (psz_device, driver_id);

  if (!p_cdio) {
    if (b_verbose)
      fprintf(stderr, "error: %s\n", strerror(errno));
    else
      fprintf(stderr, "open %s: %s\n", psz_device, strerror(errno));
    exit(1);
  } else
    if (b_verbose) fprintf(stderr,"ok\n");

  if (EJECT_CD == todo) {
    i_rc = cd_eject() ? 0 : 1;
  } else {
    read_toc(p_cdio);
    if (!b_cd) {
      cd_close(psz_device);
      read_toc(p_cdio);
    }
    if (b_cd)
      switch (todo) {
      case NO_OP:
	break;
      case STOP_PLAYING:
	i_rc = cd_stop(p_cdio) ? 0 : 1;
	break;
      case EJECT_CD:
	/* Should have been handled above before case statement. gcc
	   warns if we don't include this. And with this Coverty
	   complains when we do - we can't win, so go with gcc. */
	cd_eject();
	break;
	case PLAY_TRACK:
	  /* play just this one track */
	  play_track(start_track, stop_track);
	  break;
	case PLAY_CD:
	  play_track(1,CDIO_CDROM_LEADOUT_TRACK);
	  break;
	case CLOSE_CD:
	  i_rc = cdio_close_tray(psz_device, NULL) ? 0 : 1;
	  break;
	case SET_VOLUME:
	  {
	    cdio_audio_volume_t volume;
	    volume.level[0] = i_volume_level;
	    i_rc = (DRIVER_OP_SUCCESS == cdio_audio_set_volume(p_cdio,
							       &volume))
	      ? 0 : 1;
	    break;
	  }
	case LIST_SUBCHANNEL:
	  if (read_subchannel(p_cdio)) {
	    if (sub.audio_status == CDIO_MMC_READ_SUB_ST_PAUSED ||
		sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY) {
	      {
		printf("track %2d - %02x:%02x (%02x:%02x abs) ",
		       sub.track, sub.rel_addr.m, sub.rel_addr.s,
		       sub.abs_addr.m, sub.abs_addr.s);
	      }
	    }
	    printf("drive state: %s\n",
		   mmc_audio_state2str(sub.audio_status));
	  } else {
	    i_rc = 1;
	  }
	  break;
      }
      else {
	fprintf(stderr,"no CD in drive (%s)\n", psz_device);
      }
  }

  oops("bye", i_rc);

  return 0; /* keep compiler happy */
}
Exemple #8
0
/*****************************************************************************
 * VCDParse: parse command line
 *****************************************************************************/
static char *
VCDParse( access_t * p_access, /*out*/ vcdinfo_itemid_t * p_itemid,
          /*out*/ bool *play_single_item )
{
    vcdplayer_t *p_vcdplayer = (vcdplayer_t *)p_access->p_sys;
    char        *psz_parser;
    char        *psz_source;
    char        *psz_next;

    if( var_InheritBool( p_access, MODULE_STRING "-PBC" ) ) {
      p_itemid->type = VCDINFO_ITEM_TYPE_LID;
      p_itemid->num = 1;
      *play_single_item = false;
    }
    else
    {
      p_itemid->type = VCDINFO_ITEM_TYPE_ENTRY;
      p_itemid->num = 0;
    }

#ifdef _WIN32
    /* On Win32 we want the VCD access plugin to be explicitly requested,
     * we end up with lots of problems otherwise */
    if( !p_access->psz_access || !*p_access->psz_access ) return NULL;
#endif

    if( !p_access->psz_location )
    {
        return NULL;
    }

    psz_parser = psz_source = strdup( p_access->psz_location );

    /* Parse input string :
     * [device][@[type][title]] */
    while( *psz_parser && *psz_parser != '@' )
    {
        psz_parser++;
    }

    if( *psz_parser == '@' )
    {
      /* Found the divide between the source name and the
         type+entry number. */
      unsigned int num;

        *psz_parser = '\0';
        ++psz_parser;
        if( *psz_parser )
        switch(*psz_parser) {
        case 'E':
            p_itemid->type = VCDINFO_ITEM_TYPE_ENTRY;
            ++psz_parser;
            *play_single_item = true;
            break;
        case 'P':
            p_itemid->type = VCDINFO_ITEM_TYPE_LID;
            ++psz_parser;
            *play_single_item = false;
            break;
        case 'S':
            p_itemid->type = VCDINFO_ITEM_TYPE_SEGMENT;
            ++psz_parser;
            *play_single_item = true;
            break;
        case 'T':
            p_itemid->type = VCDINFO_ITEM_TYPE_TRACK;
            ++psz_parser;
            *play_single_item = true;
            break;
        default:
            break;
        }

        num = strtol( psz_parser, &psz_next, 10 );
        if ( *psz_parser != '\0' && *psz_next == '\0')
        {
            p_itemid->num = num;
        }

    } else {
        *play_single_item = ( VCDINFO_ITEM_TYPE_LID == p_itemid->type );
    }


    if( !*psz_source )
    {

        /* No source specified, so figure it out. */
        if( !p_access->psz_access ) return NULL;

        psz_source = var_InheritString( p_access, "vcd" );

        if( !psz_source )
        {
            /* Scan for a CD-ROM drive with a VCD in it. */
            char **cd_drives = cdio_get_devices_with_cap(NULL,
                                       (CDIO_FS_ANAL_SVCD|CDIO_FS_ANAL_CVD
                                       |CDIO_FS_ANAL_VIDEOCD|CDIO_FS_UNKNOWN),
                                       true);
            if( NULL == cd_drives ) return NULL;
            if( cd_drives[0] == NULL )
            {
                cdio_free_device_list( cd_drives );
                return NULL;
            }
            psz_source = strdup( cd_drives[0] );
            cdio_free_device_list( cd_drives );
        }
    }

    dbg_print( (INPUT_DBG_CALL|INPUT_DBG_MRL),
               "source=%s entry=%d type=%d",
               psz_source, p_itemid->num, p_itemid->type);

    return psz_source;
}
int
main(int argc, char *argv[])
{    
  int  c, nostop=0;
  char *h;
  int  i_rc = 0;
  cd_operation_t cd_op = NO_OP; /* operation to do in non-interactive mode */
  
  
  psz_program = strrchr(argv[0],'/');
  psz_program = psz_program ? psz_program+1 : argv[0];

  memset(&cddb_opts, 0, sizeof(cddb_opts));
  
  cdio_loglevel_default = CDIO_LOG_WARN;
  /* parse options */
  while ( 1 ) {
    if (-1 == (c = getopt(argc, argv, "acCdehkplL:sSt:vx")))
      break;
    switch (c) {
    case 'v':
      b_verbose = true;
      if (cdio_loglevel_default > CDIO_LOG_INFO) 
        cdio_loglevel_default = CDIO_LOG_INFO;
      break;
    case 'd':
      debug = 1;
      if (cdio_loglevel_default > CDIO_LOG_DEBUG) 
      cdio_loglevel_default = CDIO_LOG_DEBUG;
      break;
    case 'a':
      auto_mode = 1;
      break;

    case 'L':
      i_volume_level = atoi(optarg);
      cd_op = SET_VOLUME;
      b_interactive = false;
      break;

    case 't':
      if (NULL != (h = strchr(optarg,'-'))) {
        *h = 0;
        start_track = atoi(optarg);
        stop_track = atoi(h+1)+1;
        if (0 == start_track) start_track = 1;
        if (1 == stop_track)  stop_track  = CDIO_CDROM_LEADOUT_TRACK;
      } else {
        start_track = atoi(optarg);
        stop_track = start_track+1;
        one_track = 1;
      }
      b_interactive = false;
      cd_op = PLAY_TRACK;
      break;
    case 'p':
      b_interactive = false;
      cd_op = PLAY_CD;
      break;
    case 'l':
      b_interactive = false;
      cd_op = LIST_TRACKS;
      break;
    case 'C':
      b_interactive = false;
      cd_op = CLOSE_CD;
      break;
    case 'c':
      b_interactive = false;
      cd_op = PS_LIST_TRACKS;
      break;
    case 's':
      b_interactive = false;
      cd_op = STOP_PLAYING;
      break;
    case 'S':
      b_interactive = false;
      cd_op = LIST_SUBCHANNEL;
      break;
    case 'e':
      b_interactive = false;
      cd_op = EJECT_CD;
      break;
    case 'k':
      print_keys();
      exit(1);
    case 'h':
      usage(psz_program);
      exit(1);
    default:
      usage(psz_program);
      exit(1);
    }
  }
  
  if (argc > optind) {
    psz_device = strdup(argv[optind]);
  } else {
    char **ppsz_cdda_drives=NULL;
    char **ppsz_all_cd_drives = cdio_get_devices_ret(&driver_id);

    if (!ppsz_all_cd_drives) {
      fprintf(stderr, "Can't find a CD-ROM drive\n");
      exit(2);
    }
    ppsz_cdda_drives = cdio_get_devices_with_cap(ppsz_all_cd_drives, 
                                                 CDIO_FS_AUDIO, false);
    if (!ppsz_cdda_drives || !ppsz_cdda_drives[0]) {
      fprintf(stderr, "Can't find a CD-ROM drive with a CD-DA in it\n");
      exit(3);
    }
    psz_device = strdup(ppsz_cdda_drives[0]);
    cdio_free_device_list(ppsz_all_cd_drives);
    cdio_free_device_list(ppsz_cdda_drives);
  }
  
  if (!b_interactive) {
    b_sig = true;
    nostop=1;
  }

  tty_raw();
  signal(SIGINT,ctrlc);
  signal(SIGQUIT,ctrlc);
  signal(SIGTERM,ctrlc);
  signal(SIGHUP,ctrlc);
  signal(SIGWINCH, sigwinch);

  if (CLOSE_CD != cd_op) {
    /* open device */
    if (b_verbose)
      fprintf(stderr, "open %s... ", psz_device);
    p_cdio = cdio_open (psz_device, driver_id);
    if (!p_cdio && cd_op != EJECT_CD) {
      cd_close(psz_device);
      p_cdio = cdio_open (psz_device, driver_id);
    }
    
    if (p_cdio && b_verbose)
      fprintf(stderr,"ok\n");
  }
  
  if (b_interactive) {
#ifdef HAVE_CDDB
    cddb_log_set_handler (cddb_log_handler);
#else
    ;
#endif
  }  else {
    b_sig = true;
    nostop=1;
    if (EJECT_CD == cd_op) {
      i_rc = cd_eject() ? 0 : 1;
    } else {
      switch (cd_op) {
      case PS_LIST_TRACKS:
      case LIST_TRACKS:
      case PLAY_TRACK:
        read_toc(p_cdio);
      default:
        break;
      }
      if (p_cdio)
        switch (cd_op) {
        case STOP_PLAYING:
          b_cd = true;
          i_rc = cd_stop(p_cdio) ? 0 : 1;
          break;
        case EJECT_CD:
          /* Should have been handled above. */
          cd_eject();
          break;
        case LIST_TRACKS:
          list_tracks();
          break;
        case PS_LIST_TRACKS:
          ps_list_tracks();
          break;

        case PLAY_TRACK:
          /* play just this one track */
          if (b_record) {
            printf("%s / %s\n", artist, title);
            if (one_track)
              printf("%s\n", cd_info[start_track].title);
          }
          i_rc = play_track(start_track, stop_track) ? 0 : 1;
          break;

        case PLAY_CD:
          if (b_record)
            printf("%s / %s\n", artist, title);
          play_track(1,CDIO_CDROM_LEADOUT_TRACK);
          break;

        case SET_VOLUME:
          i_rc = set_volume_level(p_cdio, i_volume_level);
          break;

        case LIST_SUBCHANNEL: 
          if (read_subchannel(p_cdio)) {
            if (sub.audio_status == CDIO_MMC_READ_SUB_ST_PAUSED ||
                sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY) {
              {
                printf("track %2d - %02x:%02x (%02x:%02x abs) ",
                       sub.track, sub.rel_addr.m, sub.rel_addr.s,
                       sub.abs_addr.m, sub.abs_addr.s);
              }
            }
            printf("drive state: %s\n", 
                   mmc_audio_state2str(sub.audio_status));
          } else {
            i_rc = 1;
          }
          break;
        case CLOSE_CD: /* Handled below */
        case LIST_KEYS:
        case TOGGLE_PAUSE:
        case EXIT_PROGRAM:
        case NO_OP:
          break;
        }
      else if (CLOSE_CD == cd_op) {
        i_rc = (DRIVER_OP_SUCCESS == cdio_close_tray(psz_device, NULL))
                ? 0 : 1;
      } else {
        fprintf(stderr,"no CD in drive (%s)\n", psz_device);
      }
    }
  }

  /* Play all tracks *unless* we have a play or paused status
     already. */

  read_subchannel(p_cdio);
  if (sub.audio_status != CDIO_MMC_READ_SUB_ST_PAUSED &&
      sub.audio_status != CDIO_MMC_READ_SUB_ST_PLAY)
    play_track(1, CDIO_CDROM_LEADOUT_TRACK);

  while ( !b_sig ) {
    int key;
    if (!b_cd) read_toc(p_cdio);
    read_subchannel(p_cdio);
    display_status(false);
    
    if (1 == select_wait(b_cd ? 1 : 5)) {
      switch (key = getch()) {
      case '-':
        decrease_volume_level(p_cdio);
        break;
      case '+':
        increase_volume_level(p_cdio);
        break;
      case 'A':
      case 'a':
        auto_mode = !auto_mode;
        break;
      case 'X':
      case 'x':
        nostop=1;
        /* fall through */
      case 'Q':
      case 'q':
        b_sig = true;
        break;
      case 'E':
      case 'e':
        cd_eject();
        break;
      case 's':
        cd_stop(p_cdio);
        break;
      case 'C':
      case 'c':
        cd_close(psz_device);
        break;
      case 'L':
      case 'l':
        b_all_tracks = !b_all_tracks;
        if (b_all_tracks)
          display_tracks();
        else {
          i_last_display_track = CDIO_INVALID_TRACK;
          display_cdinfo(p_cdio, i_tracks, i_first_track);
        }
        
        break;
      case 'K':
      case 'k':
      case 'h':
      case 'H':
      case '?':
        list_keys();
        break;
      case ' ':
      case 'P':
      case 'p':
        toggle_pause();
        break;
      case KEY_RIGHT:
        if (b_cd &&
            (sub.audio_status == CDIO_MMC_READ_SUB_ST_PAUSED ||
             sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY)) 
          play_track(sub.track+1, CDIO_CDROM_LEADOUT_TRACK);
        else
          play_track(1,CDIO_CDROM_LEADOUT_TRACK);
        break;
      case KEY_LEFT:
        if (b_cd &&
            (sub.audio_status == CDIO_MMC_READ_SUB_ST_PAUSED ||
             sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY))
          play_track(sub.track-1,CDIO_CDROM_LEADOUT_TRACK);
        break;
      case KEY_UP:
        if (b_cd && sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY)
          skip(10);
        break;
      case KEY_DOWN:
        if (b_cd && sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY)
          skip(-10);
        break;
      case '1':
      case '2':
      case '3':
      case '4':
      case '5':
      case '6':
      case '7':
      case '8':
      case '9':
        play_track(key - '0', CDIO_CDROM_LEADOUT_TRACK);
        break;
      case '0':
        play_track(10, CDIO_CDROM_LEADOUT_TRACK);
        break;
      case KEY_F(1):
      case KEY_F(2):
      case KEY_F(3):
      case KEY_F(4):
      case KEY_F(5):
      case KEY_F(6):
      case KEY_F(7):
      case KEY_F(8):
      case KEY_F(9):
      case KEY_F(10):
      case KEY_F(11):
      case KEY_F(12):
      case KEY_F(13):
      case KEY_F(14):
      case KEY_F(15):
      case KEY_F(16):
      case KEY_F(17):
      case KEY_F(18):
      case KEY_F(19):
      case KEY_F(20):
        play_track(key - KEY_F(1) + 11, CDIO_CDROM_LEADOUT_TRACK);
        break;
      }
    }
  }
  if (!nostop) cd_stop(p_cdio);
  tty_restore();
  finish("bye", i_rc);
  
  return 0; /* keep compiler happy */
}
Exemple #10
0
int
main(int argc, const char *argv[])
{
  char **nrg_images=NULL;
  char **bincue_images=NULL;
  char **imgs;
  char **c;
  unsigned int i;
  int ret=0;

  const char *cue_files[2] = {"cdda.cue", "isofs-m1.cue"};
  const char *nrg_files[1] = {"videocd.nrg"};
  
  cdio_log_set_handler (log_handler);

  if (cdio_have_driver(-1) != false) 
    {
      printf("Bogus driver number -1 should be regexted\n");
      return 5;
    }
  

  if (! (cdio_have_driver(DRIVER_NRG) && cdio_have_driver(DRIVER_BINCUE)) )  {
    printf("You don't have enough drivers for this test\n");
    exit(77);
  }

  nrg_images = cdio_get_devices(DRIVER_NRG);

  for (imgs=nrg_images; *imgs != NULL; imgs++) {
    printf("NRG image %s\n", *imgs);
  }

  if (!is_in(nrg_images, nrg_files[0])) {
    cdio_free_device_list(nrg_images);
    return 10;
  }
      
  bincue_images = cdio_get_devices(DRIVER_BINCUE);
  
  for (imgs=bincue_images; *imgs != NULL; imgs++) {
    printf("bincue image %s\n", *imgs);
  }
  
  for (i=0; i<2; i++) {
    if (is_in(bincue_images, cue_files[i])) {
      printf("%s parses as a CDRWIN BIN/CUE csheet.\n", cue_files[i]);
    } else {
      printf("%s doesn't parse as a CDRWIN BIN/CUE csheet.\n", cue_files[i]);
      ret = i+1;
    }
  }

  if (ret != 0) return ret;
    
  printf("-----\n");
  printf("ISO 9660 images...\n");
  imgs = NULL;
  /* Print out a list of CDDA-drives. */
  imgs = cdio_get_devices_with_cap(bincue_images, CDIO_FS_ISO_9660, false);

  if (NULL == imgs || *imgs == NULL) {
    printf("Failed to find an ISO 9660 image\n");
    return 11;
  }
    
  for( c = imgs; *c != NULL; c++ ) {
    printf("%s\n", *c);
  }
    
  cdio_free_device_list(imgs);
  free(imgs);
  
  
  printf("-----\n");
  printf("CD-DA images...\n");
  imgs = NULL;
  /* Print out a list of CDDA-drives. */
  imgs = cdio_get_devices_with_cap(bincue_images, CDIO_FS_AUDIO, false);

  if (NULL == imgs || *imgs == NULL) {
    printf("Failed to find CDDA image\n");
    return 12;
  }
    
  for( c = imgs; *c != NULL; c++ ) {
    printf("%s\n", *c);
  }
    
  cdio_free_device_list(imgs);
  free(imgs);
  
  
  printf("-----\n");
  imgs = NULL;
  printf("VCD images...\n");
  /* Print out a list of CD-drives with VCD's in them. */
  imgs = cdio_get_devices_with_cap(nrg_images, 
(CDIO_FS_ANAL_SVCD|CDIO_FS_ANAL_CVD|CDIO_FS_ANAL_VIDEOCD|CDIO_FS_UNKNOWN),
					true);
  if (NULL == imgs || *imgs == NULL) {
    printf("Failed to find VCD image\n");
    return 13;
  }
    
  for( c = imgs; *c != NULL; c++ ) {
    printf("image: %s\n", *c);
  }

  cdio_free_device_list(imgs);
  free(imgs);

  imgs = NULL;
  /* Print out a list of CDDA-drives. */
  imgs = cdio_get_devices_with_cap(bincue_images, CDIO_FS_HIGH_SIERRA, false);

  if (NULL != imgs && *imgs != NULL) {
    printf("Found erroneous High Sierra image\n");
    return 14;
  }
    
  imgs = NULL;
  /* Print out a list of CDDA-drives. */
  imgs = cdio_get_devices_with_cap(bincue_images, CDIO_FS_UFS, true);

  if (NULL != imgs && *imgs != NULL) {
    printf("Found erroneous UFS image\n");
    return 15;
  }
    
  cdio_free_device_list(nrg_images);
  cdio_free_device_list(bincue_images);
  cdio_free_device_list(imgs);
  return 0;
  
}