Exemplo n.º 1
0
/**
 * Called in the main thread after the database update is finished.
 */
static void update_finished_event(void)
{
	char *path;

	assert(progress == UPDATE_PROGRESS_DONE);

	g_thread_join(update_thr);

	idle_add(IDLE_UPDATE);

	if (modified) {
		/* send "idle" events */
		playlist_increment_version_all(&g_playlist);
		idle_add(IDLE_DATABASE);
	}

	path = update_queue_shift(&discard);
	if (path != NULL) {
		/* schedule the next path */
		spawn_update_task(path);
		g_free(path);
	} else {
		progress = UPDATE_PROGRESS_IDLE;

		stats_update();
	}
}
enum playlist_result
spl_save_queue(const char *name_utf8, const struct queue *queue)
{
	char *path_fs;
	FILE *file;

	if (map_spl_path() == NULL)
		return PLAYLIST_RESULT_DISABLED;

	if (!spl_valid_name(name_utf8))
		return PLAYLIST_RESULT_BAD_NAME;

	path_fs = map_spl_utf8_to_fs(name_utf8);
	if (path_fs == NULL)
		return PLAYLIST_RESULT_BAD_NAME;

	if (g_file_test(path_fs, G_FILE_TEST_EXISTS)) {
		g_free(path_fs);
		return PLAYLIST_RESULT_LIST_EXISTS;
	}

	file = fopen(path_fs, "w");
	g_free(path_fs);

	if (file == NULL)
		return PLAYLIST_RESULT_ERRNO;

	for (unsigned i = 0; i < queue_length(queue); i++)
		playlist_print_song(file, queue_get(queue, i));

	fclose(file);

	idle_add(IDLE_STORED_PLAYLIST);
	return PLAYLIST_RESULT_SUCCESS;
}
Exemplo n.º 3
0
enum playlist_result
spl_move_index(const char *utf8path, unsigned src, unsigned dest)
{
	GPtrArray *list;
	char *uri;
	enum playlist_result result;

	if (src == dest)
		/* this doesn't check whether the playlist exists, but
		   what the hell.. */
		return PLAYLIST_RESULT_SUCCESS;

	if (!(list = spl_load(utf8path)))
		return PLAYLIST_RESULT_NO_SUCH_LIST;

	if (src >= list->len || dest >= list->len) {
		spl_free(list);
		return PLAYLIST_RESULT_BAD_RANGE;
	}

	uri = spl_remove_index_internal(list, src);
	spl_insert_index_internal(list, dest, uri);

	result = spl_save(list, utf8path);

	spl_free(list);

	idle_add(IDLE_STORED_PLAYLIST);
	return result;
}
Exemplo n.º 4
0
static bool
spl_rename_internal(const char *from_path_fs, const char *to_path_fs,
                    GError **error_r)
{
    if (!g_file_test(from_path_fs, G_FILE_TEST_IS_REGULAR)) {
        g_set_error_literal(error_r, playlist_quark(),
                            PLAYLIST_RESULT_NO_SUCH_LIST,
                            "No such playlist");
        return false;
    }

    if (g_file_test(to_path_fs, G_FILE_TEST_EXISTS)) {
        g_set_error_literal(error_r, playlist_quark(),
                            PLAYLIST_RESULT_LIST_EXISTS,
                            "Playlist exists already");
        return false;
    }

    if (rename(from_path_fs, to_path_fs) < 0) {
        playlist_errno(error_r);
        return false;
    }

    idle_add(IDLE_STORED_PLAYLIST);
    return true;
}
Exemplo n.º 5
0
bool
spl_remove_index(const char *utf8path, unsigned pos, GError **error_r)
{
    char *uri;

    GPtrArray *list = spl_load(utf8path, error_r);
    if (list == NULL)
        return false;

    if (pos >= list->len) {
        spl_free(list);
        g_set_error_literal(error_r, playlist_quark(),
                            PLAYLIST_RESULT_BAD_RANGE,
                            "Bad range");
        return false;
    }

    uri = spl_remove_index_internal(list, pos);
    g_free(uri);
    bool result = spl_save(list, utf8path, error_r);

    spl_free(list);

    idle_add(IDLE_STORED_PLAYLIST);
    return result;
}
Exemplo n.º 6
0
bool
spl_move_index(const char *utf8path, unsigned src, unsigned dest,
               GError **error_r)
{
    char *uri;

    if (src == dest)
        /* this doesn't check whether the playlist exists, but
           what the hell.. */
        return true;

    GPtrArray *list = spl_load(utf8path, error_r);
    if (list == NULL)
        return false;

    if (src >= list->len || dest >= list->len) {
        spl_free(list);
        g_set_error_literal(error_r, playlist_quark(),
                            PLAYLIST_RESULT_BAD_RANGE,
                            "Bad range");
        return false;
    }

    uri = spl_remove_index_internal(list, src);
    spl_insert_index_internal(list, dest, uri);

    bool result = spl_save(list, utf8path, error_r);

    spl_free(list);

    idle_add(IDLE_STORED_PLAYLIST);
    return result;
}
void
pc_set_mixramp_delay(float mixramp_delay_seconds)
{
	pc.mixramp_delay_seconds = mixramp_delay_seconds;

	idle_add(IDLE_OPTIONS);
}
Exemplo n.º 8
0
void playerPause(void)
{
	if (pc.state != PLAYER_STATE_STOP) {
		player_command(PLAYER_COMMAND_PAUSE);
		idle_add(IDLE_PLAYER);
	}
}
Exemplo n.º 9
0
void
pc_set_mixramp_delay(struct player_control *pc, float mixramp_delay_seconds)
{
	pc->mixramp_delay_seconds = mixramp_delay_seconds;

	idle_add(IDLE_OPTIONS);
}
Exemplo n.º 10
0
void
pc_set_mixramp_db(struct player_control *pc, float mixramp_db)
{
	pc->mixramp_db = mixramp_db;

	idle_add(IDLE_OPTIONS);
}
Exemplo n.º 11
0
void
pc_set_mixramp_db(float mixramp_db)
{
	pc.mixramp_db = mixramp_db;

	idle_add(IDLE_OPTIONS);
}
Exemplo n.º 12
0
void
pc_stop(struct player_control *pc)
{
	player_command(pc, PLAYER_COMMAND_CLOSE_AUDIO);
	assert(pc->next_song == NULL);

	idle_add(IDLE_PLAYER);
}
Exemplo n.º 13
0
void
pc_stop(void)
{
	player_command(PLAYER_COMMAND_CLOSE_AUDIO);
	assert(pc.next_song == NULL);

	idle_add(IDLE_PLAYER);
}
Exemplo n.º 14
0
static void
pc_pause_locked(void)
{
	if (pc.state != PLAYER_STATE_STOP) {
		player_command_locked(PLAYER_COMMAND_PAUSE);
		idle_add(IDLE_PLAYER);
	}
}
Exemplo n.º 15
0
void
RenderArea::setIdleMode(bool theEnabledFlag) {
    if (theEnabledFlag) {
        idle_add();
    } else {
        idle_remove();
    }
}
Exemplo n.º 16
0
void setPlayerCrossFade(float crossFadeInSeconds)
{
	if (crossFadeInSeconds < 0)
		crossFadeInSeconds = 0;
	pc.cross_fade_seconds = crossFadeInSeconds;

	idle_add(IDLE_OPTIONS);
}
Exemplo n.º 17
0
static void
pc_pause_locked(struct player_control *pc)
{
	if (pc->state != PLAYER_STATE_STOP) {
		player_command_locked(pc, PLAYER_COMMAND_PAUSE);
		idle_add(IDLE_PLAYER);
	}
}
Exemplo n.º 18
0
void
playlist_set_consume(struct playlist *playlist, bool status)
{
	if (status == playlist->queue.consume)
		return;

	playlist->queue.consume = status;
	idle_add(IDLE_OPTIONS);
}
Exemplo n.º 19
0
static gboolean
map (GtkWidget   *widget,
     GdkEventAny *event,
     gpointer     data)
{
  idle_add (widget);

  return TRUE;
}
Exemplo n.º 20
0
void
pc_set_cross_fade(struct player_control *pc, float cross_fade_seconds)
{
	if (cross_fade_seconds < 0)
		cross_fade_seconds = 0;
	pc->cross_fade_seconds = cross_fade_seconds;

	idle_add(IDLE_OPTIONS);
}
Exemplo n.º 21
0
void
pc_set_cross_fade(float cross_fade_seconds)
{
	if (cross_fade_seconds < 0)
		cross_fade_seconds = 0;
	pc.cross_fade_seconds = cross_fade_seconds;

	idle_add(IDLE_OPTIONS);
}
Exemplo n.º 22
0
void playerKill(void)
{
	assert(pc.thread != NULL);

	player_command(PLAYER_COMMAND_EXIT);
	g_thread_join(pc.thread);
	pc.thread = NULL;

	idle_add(IDLE_PLAYER);
}
Exemplo n.º 23
0
/***
 *** The "map_event" signal handler. Any processing required when the
 *** OpenGL-capable drawing area is mapped should be done here.
 ***/
static gboolean
map_event (GtkWidget *widget,
	   GdkEvent  *event,
	   gpointer   data)
{
  if (animate)
    idle_add (widget);

  return TRUE;
}
Exemplo n.º 24
0
void
pc_kill(struct player_control *pc)
{
	assert(pc->thread != NULL);

	player_command(pc, PLAYER_COMMAND_EXIT);
	g_thread_join(pc->thread);
	pc->thread = NULL;

	idle_add(IDLE_PLAYER);
}
Exemplo n.º 25
0
void
playlist_tag_changed(struct playlist *playlist)
{
	if (!playlist->playing)
		return;

	assert(playlist->current >= 0);

	queue_modify(&playlist->queue, playlist->current);
	idle_add(IDLE_PLAYLIST);
}
Exemplo n.º 26
0
static gboolean
visible (GtkWidget          *widget,
	 GdkEventVisibility *event,
	 gpointer            data)
{
  if (event->state == GDK_VISIBILITY_FULLY_OBSCURED)
    idle_remove (widget);
  else
    idle_add (widget);

  return TRUE;
}
Exemplo n.º 27
0
void
playerPlay(struct song *song)
{
	assert(song != NULL);

	if (pc.state != PLAYER_STATE_STOP)
		player_command(PLAYER_COMMAND_STOP);

	pc.next_song = song;
	player_command(PLAYER_COMMAND_PLAY);

	idle_add(IDLE_PLAYER);
}
Exemplo n.º 28
0
void
playlist_set_single(struct playlist *playlist, bool status)
{
	if (status == playlist->queue.single)
		return;

	playlist->queue.single = status;

	/* if the last song is currently being played, the "next song"
	   might change when single mode is toggled */
	playlist_update_queued_song(playlist,
				    playlist_get_queued_song(playlist));

	idle_add(IDLE_OPTIONS);
}
Exemplo n.º 29
0
static enum playlist_result
spl_rename_internal(const char *from_path_fs, const char *to_path_fs)
{
	if (!g_file_test(from_path_fs, G_FILE_TEST_IS_REGULAR))
		return PLAYLIST_RESULT_NO_SUCH_LIST;

	if (g_file_test(to_path_fs, G_FILE_TEST_EXISTS))
		return PLAYLIST_RESULT_LIST_EXISTS;

	if (rename(from_path_fs, to_path_fs) < 0)
		return PLAYLIST_RESULT_ERRNO;

	idle_add(IDLE_STORED_PLAYLIST);
	return PLAYLIST_RESULT_SUCCESS;
}
Exemplo n.º 30
0
void
pc_play(struct song *song)
{
	assert(song != NULL);

	if (pc.state != PLAYER_STATE_STOP)
		player_command(PLAYER_COMMAND_STOP);

	assert(pc.next_song == NULL);

	pc_enqueue_song(song);

	assert(pc.next_song == NULL);

	idle_add(IDLE_PLAYER);
}