Beispiel #1
0
static int nextSong(const char* next) {
  fprintf(stderr,"PATH: %s",next);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  struct stat buf;
  if(stat(next,&buf)!=0) {
    write(STDOUT_FILENO,"!",1);
    selectNext();
    playerPlay();
    return 1;
  } else {
    g_object_set (src, "location", next, NULL);
    gst_element_set_state (pipeline, GST_STATE_PLAYING);
    return 0;
  }
}
Beispiel #2
0
// zwraca 1, gdy ok, 0 gdy koniec
int playOneFrame() {
	size_t size;
	if (decoderRead(playBuf, &size) != DECODER_CODE_OK) {
		GOC_ERROR("Bad decoder read");
		closeAudioFile();
		return 0;
	}
	if ( size == 0 ) {
		closeAudioFile();
		return 0;
	}
	if (playerPlay(playBuf, size) != PLAYER_CODE_OK) {
		GOC_ERROR("Error play");
		closeAudioFile();
		return 0;
	}
	return 1;
}
Beispiel #3
0
int playPlaylistOrderNumber(FILE * fp, int orderNum) {

	if(playerStop(fp)<0) return -1;

	playlist_state = PLAYLIST_STATE_PLAY;
	playlist_noGoToNext = 0;
	playlist.queued = -1;
	playlist_queueError = 0;

	DEBUG("playlist: play %i:\"%s\"\n",orderNum,
			getSongUrl(playlist.songs[playlist.order[orderNum]]));

	if(playerPlay(fp,(playlist.songs[playlist.order[orderNum]])) < 0) {
		stopPlaylist(fp);
		return -1;
	}
	else playlist.current++;

	playlist.current = orderNum;

	return 0;
}
Beispiel #4
0
static gboolean on_input (GIOChannel *source,
                   GIOCondition condition,
                   gpointer data) {
  gchar buf[0x100];
  GError* error = NULL;
  gsize amt;
  uint8_t ready = 0;
  for(;;) {
    GIOStatus status =  g_io_channel_read_chars (source,
                                                 buf,
                                                 0x100,
                                                 &amt,
                                                 &error);
    if(amt < 0x100) break;
    switch(status) {
    case G_IO_STATUS_NORMAL:
      continue;
    case G_IO_STATUS_AGAIN:
      ready = 1;
      break;
    case G_IO_STATUS_EOF:
      {
        GMainLoop* loop = (GMainLoop*) data;
        g_main_loop_quit (loop);
        return FALSE;
      }
    case G_IO_STATUS_ERROR:
      g_printerr("%s",error->message);
      exit(error->code);
    };
    if(ready) break;
  }
  selectNext();
  playerPlay();
  return TRUE;
}
Beispiel #5
0
static void restartPlayer(int signal) {
  // this should execute in the main GTK thread (see signals.c)
    queueInterrupted = 1;
    playerPlay();
}
Beispiel #6
0
static void signalNext(int signal) {
  // this should execute in the main GTK thread (see signals.c)
  queueInterrupted = 1;
  selectNext();
  playerPlay();
}
Beispiel #7
0
static gboolean playLater(gpointer udata) {
  playerPlay();
  return G_SOURCE_REMOVE;
}