static gboolean
cdplayer_iterate (GstBin * bin)
{
  CDPlayer *cdp = CDPLAYER (bin);
  gint current_track;

  switch (cd_status (CDPLAYER_CD (cdp))) {
    case CD_PLAYING:
      current_track = cd_current_track (CDPLAYER_CD (cdp));
      if (current_track > cdp->end_track && cdp->end_track != 0) {
        return FALSE;
      }

      if (current_track != -1 && current_track != cdp->current_track) {
        cdp->current_track = current_track;
        g_signal_emit (G_OBJECT (cdp), cdplayer_signals[TRACK_CHANGE], 0,
            cdp->current_track);
      }

      return TRUE;
      break;
    case CD_ERROR:
      gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
      return FALSE;
      break;
    case CD_COMPLETED:
      gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
      gst_element_set_eos (GST_ELEMENT (bin));
      return FALSE;
      break;
  }

  return FALSE;
}
示例#2
0
文件: jvlexample.c 项目: wangp/libcda
/*
 * Description: Pause or Resume the Current Track.
 */
static void open_close()
{
  if	( cd_is_paused ())
	{
          cd_resume ();
	}
  else
  if	( cd_current_track ())
	{
          cd_pause ();
	}
}
示例#3
0
文件: jvlexample.c 项目: wangp/libcda
/*
 * Description: Pause or Resume the Current Track.
 */
static void pause_resume ()
{
  if	( cd_is_paused ())
	{
          cd_eject() ;
	}
  else
  if	( cd_current_track ())
	{
          cd_close() ;
	}
}
示例#4
0
文件: jvlexample.c 项目: wangp/libcda
/*
 * Description: Plays the previous track from the CD.
 */
static void back_track ()
{
  int		  ct ;
  track_info	tInfo ;
    
  if	( get_track_info( &tInfo ) == false )
	{
	  return ;
	}

  ct	= ( cd_current_track() - 1 ) % tInfo.last_track ;

  if	( ct < 1 )
	{
	  ct =  tInfo.last_track ;
	}

  if	( cd_play_from( ct ) != 0 )
	{
  	  show_error( ERROR, cd_error ) ;
	}
}
示例#5
0
文件: jvlexample.c 项目: wangp/libcda
/*
 * Description: Displays minimal information regardin gthe current track.
 */
static void show_info ()
{
  int		i ;
  int		no ;
  track_info	tInfo ;
    
  if	( get_track_info( &tInfo ) == false )
	{
	  return ;
	}

  i	= cd_current_track() ;
  no	= tInfo.last_track - tInfo.first_track + 1 ;
    
  if	( i > 0 )
	{
          printf ("Playing track %d (%d tracks)\n", i, no ) ;
	}
  else
	{
          printf ("Not playing (%d tracks)\n", no ) ;
	}
}
示例#6
0
文件: example.c 项目: AlanDrake/ags
int main()
{
    char cmd[20];
    int done = 0;
    int ret, trk, a, b;

    if (cd_init() < 0) {
	printf("Error initialising libcda (%s)\n", cd_error);
	return 1;
    }
	
    show_cmds();

    do {  
	printf(">>> ");
	fflush(stdout);
	scanf("%s", cmd);

	switch (cmd[0]) {
	    case '?':
		show_cmds();
		break;

	    case 'p':
		trk = input_int("Track");
		ret = cd_play(trk);
		if (ret != 0)
		    printf("Error occurred (%s)\n", cd_error);
		break;

	    case 'r':
		a = input_int("First track");
		b = input_int("Last track");
		ret = cd_play_range(a, b);
		if (ret != 0)
		    printf("Error occurred (%s)\n", cd_error);
		break;

	    case 'f':
		trk = input_int("Start track");
		ret = cd_play_from(trk);
		if (ret != 0)
		    printf("Error occurred (%s)\n", cd_error);
		break;

	    case 'P':
		trk = cd_current_track();
		if (trk)
		    printf("Playing track %d\n", trk);
		else
		    printf("Not playing\n");
		break;

	    case 'w':
		cd_pause();
		break;

	    case 'W':
		cd_resume();
		break;

	    case 'S':
		ret = cd_is_paused();
		if (ret)
		    printf("Paused\n");
		else
		    printf("Not paused\n");
		break;

	    case 's':
		cd_stop();
		break;

	    case 'i':
		ret = cd_get_tracks(&a, &b);
		if (ret != 0)
		    printf("Error occurred (%s)\n", cd_error);
		else
		    printf("First track: %d\nLast track: %d\n", a, b);
		break;

	    case 'a':
		trk = input_int("Track");
		ret = cd_is_audio(trk);
		if (ret < 0)
		    printf("Error occurred (%s)\n", cd_error);
		else
		    printf("Track %d is %s\n", trk, (ret ? "audio" : "data"));
		break;

	    case 'v':
		a = input_int("Left (0-255)");
		b = input_int("Right (0-255)");
		cd_set_volume(a, b);
		break;

	    case 'V':
		cd_get_volume(&a, &b);
		printf("Left volume: %d\nRight volume: %d\n", a, b);
		break;

	    case 'e':
		cd_eject();
		break;

	    case 'c':
		cd_close();
		break;

	    case 'q':
		done = 1;
		break;

	    default:
		printf("Unrecognised command: `%c'\n", cmd[0]);
	}
    } while (!done);

    cd_exit();
    
    return 0;
}