Example #1
0
void
queue_print_changes_position(struct client *client, const struct queue *queue,
			     uint32_t version)
{
	for (unsigned i = 0; i < queue_length(queue); i++)
		if (queue_song_newer(queue, i, version))
			client_printf(client, "cpos: %i\nId: %i\n",
				      i, queue_position_to_id(queue, i));
}
Example #2
0
/**
 * Send detailed information about a range of songs in the queue to a
 * client.
 *
 * @param client the client which has requested information
 * @param start the index of the first song (including)
 * @param end the index of the last song (excluding)
 */
static void
queue_print_song_info(struct client *client, const struct queue *queue,
		      unsigned position)
{
	song_print_info(client, queue_get(queue, position));
	client_printf(client, "Pos: %u\nId: %u\n",
		      position, queue_position_to_id(queue, position));

	uint8_t priority = queue_get_priority_at_position(queue, position);
	if (priority != 0)
		client_printf(client, "Prio: %u\n", priority);
}
Example #3
0
void
queue_delete(struct queue *queue, unsigned position)
{
	struct song *song;
	unsigned id, order;

	assert(position < queue->length);

	song = queue_get(queue, position);
	if (!song_in_database(song))
		song_free(song);

	id = queue_position_to_id(queue, position);
	order = queue_position_to_order(queue, position);

	--queue->length;

	/* release the song id */

	queue->id_to_position[id] = -1;

	/* delete song from songs array */

	for (unsigned i = position; i < queue->length; i++)
		queue_move_song_to(queue, i + 1, i);

	/* delete the entry from the order array */

	for (unsigned i = order; i < queue->length; i++)
		queue->order[i] = queue->order[i + 1];

	/* readjust values in the order array */

	for (unsigned i = 0; i < queue->length; i++)
		if (queue->order[i] > position)
			--queue->order[i];
}
Example #4
0
unsigned
playlist_get_song_id(const struct playlist *playlist, unsigned song)
{
	return queue_position_to_id(&playlist->queue, song);
}