/** * Start the decoder. * * Player lock is not held. */ static void player_dc_start(struct player *player, struct music_pipe *pipe) { struct player_control *pc = player->pc; struct decoder_control *dc = player->dc; assert(player->queued || pc->command == PLAYER_COMMAND_SEEK); assert(pc->next_song != NULL); unsigned start_ms = pc->next_song->start_ms; if (pc->command == PLAYER_COMMAND_SEEK) start_ms += (unsigned)(pc->seek_where * 1000); dc_start(dc, song_dup_detached(pc->next_song), start_ms, pc->next_song->end_ms, player_buffer, pipe); }
/** * Queue a song, addressed by its order number. */ static void playlist_queue_song_order(struct playlist *playlist, struct player_control *pc, unsigned order) { char *uri; assert(queue_valid_order(&playlist->queue, order)); playlist->queued = order; struct song *song = song_dup_detached(queue_get_order(&playlist->queue, order)); uri = song_get_uri(song); g_debug("queue song %i:\"%s\"", playlist->queued, uri); g_free(uri); pc_enqueue_song(pc, song); }
void playlist_play_order(struct playlist *playlist, struct player_control *pc, int orderNum) { char *uri; playlist->playing = true; playlist->queued = -1; struct song *song = song_dup_detached(queue_get_order(&playlist->queue, orderNum)); uri = song_get_uri(song); g_debug("play %i:\"%s\"", orderNum, uri); g_free(uri); pc_play(pc, song); playlist->current = orderNum; }
static struct song * playlist_check_load_song(const struct song *song, const char *uri, bool secure) { struct song *dest; if (uri_has_scheme(uri)) { dest = song_remote_new(uri); } else if (g_path_is_absolute(uri) && secure) { dest = song_file_load(uri, NULL); if (dest == NULL) return NULL; } else { struct song *tmp = db_get_song(uri); if (tmp == NULL) /* not found in database */ return NULL; dest = song_dup_detached(tmp); db_return_song(tmp); } return apply_song_metadata(dest, song); }