2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2011-01-29 10:13:54 +01:00
|
|
|
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-02-24 00:41:20 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-02-24 00:41:20 +01:00
|
|
|
*/
|
|
|
|
|
2008-10-31 09:19:53 +01:00
|
|
|
#ifndef MPD_PLAYLIST_H
|
|
|
|
#define MPD_PLAYLIST_H
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-01-22 23:40:11 +01:00
|
|
|
#include "queue.h"
|
2011-09-11 07:51:27 +02:00
|
|
|
#include "playlist_error.h"
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 11:03:39 +02:00
|
|
|
#include <stdbool.h>
|
2008-10-08 10:49:11 +02:00
|
|
|
|
2009-11-03 21:08:48 +01:00
|
|
|
struct player_control;
|
|
|
|
|
2009-01-24 13:34:53 +01:00
|
|
|
struct playlist {
|
2009-01-23 00:06:53 +01:00
|
|
|
/**
|
|
|
|
* The song queue - it contains the "real" playlist.
|
|
|
|
*/
|
2009-01-22 23:40:11 +01:00
|
|
|
struct queue queue;
|
|
|
|
|
2009-01-23 00:09:26 +01:00
|
|
|
/**
|
|
|
|
* This value is true if the player is currently playing (or
|
|
|
|
* should be playing).
|
|
|
|
*/
|
|
|
|
bool playing;
|
|
|
|
|
2009-01-24 13:20:07 +01:00
|
|
|
/**
|
|
|
|
* If true, then any error is fatal; if false, MPD will
|
|
|
|
* attempt to play the next song on non-fatal errors. During
|
|
|
|
* seeking, this flag is set.
|
|
|
|
*/
|
|
|
|
bool stop_on_error;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of errors since playback was started. If this
|
|
|
|
* number exceeds the length of the playlist, MPD gives up,
|
|
|
|
* because all songs have been tried.
|
|
|
|
*/
|
|
|
|
unsigned error_count;
|
|
|
|
|
2009-01-23 00:06:53 +01:00
|
|
|
/**
|
|
|
|
* The "current song pointer". This is the song which is
|
|
|
|
* played when we get the "play" command. It is also the song
|
|
|
|
* which is currently being played.
|
|
|
|
*/
|
2007-05-16 14:02:10 +02:00
|
|
|
int current;
|
2009-01-23 00:06:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The "next" song to be played, when the current one
|
2009-01-23 07:33:15 +01:00
|
|
|
* finishes. The decoder thread may start decoding and
|
|
|
|
* buffering it, while the "current" song is still playing.
|
|
|
|
*
|
|
|
|
* This variable is only valid if #playing is true.
|
2009-01-23 00:06:53 +01:00
|
|
|
*/
|
2007-05-16 14:02:10 +02:00
|
|
|
int queued;
|
2009-01-24 13:34:53 +01:00
|
|
|
};
|
2007-05-16 14:02:10 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
/** the global playlist object */
|
|
|
|
extern struct playlist g_playlist;
|
|
|
|
|
2009-07-14 21:28:36 +02:00
|
|
|
void
|
|
|
|
playlist_global_init(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-07-14 21:28:36 +02:00
|
|
|
void
|
|
|
|
playlist_global_finish(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void
|
|
|
|
playlist_init(struct playlist *playlist);
|
|
|
|
|
|
|
|
void
|
|
|
|
playlist_finish(struct playlist *playlist);
|
|
|
|
|
|
|
|
void
|
|
|
|
playlist_tag_changed(struct playlist *playlist);
|
|
|
|
|
2009-01-24 14:51:35 +01:00
|
|
|
/**
|
|
|
|
* Returns the "queue" object of the global playlist instance.
|
|
|
|
*/
|
2009-02-04 18:56:41 +01:00
|
|
|
static inline const struct queue *
|
|
|
|
playlist_get_queue(const struct playlist *playlist)
|
|
|
|
{
|
|
|
|
return &playlist->queue;
|
|
|
|
}
|
2009-01-24 14:51:35 +01:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_clear(struct playlist *playlist, struct player_control *pc);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-12-30 19:14:13 +01:00
|
|
|
#ifndef WIN32
|
2008-10-15 22:35:13 +02:00
|
|
|
/**
|
|
|
|
* Appends a local file (outside the music database) to the playlist,
|
|
|
|
* but only if the file's owner is equal to the specified uid.
|
|
|
|
*/
|
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_append_file(struct playlist *playlist, struct player_control *pc,
|
|
|
|
const char *path, int uid, unsigned *added_id);
|
2008-12-30 19:14:13 +01:00
|
|
|
#endif
|
2008-10-15 22:35:13 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_append_uri(struct playlist *playlist, struct player_control *pc,
|
|
|
|
const char *file, unsigned *added_id);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 10:49:11 +02:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_append_song(struct playlist *playlist, struct player_control *pc,
|
2009-02-04 18:56:41 +01:00
|
|
|
struct song *song, unsigned *added_id);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_delete(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-09-30 23:13:13 +02:00
|
|
|
/**
|
|
|
|
* Deletes a range of songs from the playlist.
|
|
|
|
*
|
|
|
|
* @param start the position of the first song to delete
|
|
|
|
* @param end the position after the last song to delete
|
|
|
|
*/
|
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_delete_range(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned start, unsigned end);
|
2009-09-30 23:13:13 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_delete_id(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_stop(struct playlist *playlist, struct player_control *pc);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_play(struct playlist *playlist, struct player_control *pc,
|
|
|
|
int song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_play_id(struct playlist *playlist, struct player_control *pc,
|
|
|
|
int song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_next(struct playlist *playlist, struct player_control *pc);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_sync(struct playlist *playlist, struct player_control *pc);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_previous(struct playlist *playlist, struct player_control *pc);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-07-14 21:28:36 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_shuffle(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned start, unsigned end);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 10:49:11 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_delete_song(struct playlist *playlist, struct player_control *pc,
|
|
|
|
const struct song *song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_move_range(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned start, unsigned end, int to);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_move_id(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned id, int to);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_swap_songs(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned song1, unsigned song2);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_swap_songs_id(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned id1, unsigned id2);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2011-07-19 00:34:33 +02:00
|
|
|
enum playlist_result
|
|
|
|
playlist_set_priority(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned start_position, unsigned end_position,
|
|
|
|
uint8_t priority);
|
|
|
|
|
|
|
|
enum playlist_result
|
|
|
|
playlist_set_priority_id(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned song_id, uint8_t priority);
|
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
bool
|
2009-07-29 00:07:01 +02:00
|
|
|
playlist_get_repeat(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_set_repeat(struct playlist *playlist, struct player_control *pc,
|
|
|
|
bool status);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
bool
|
2009-07-29 00:07:01 +02:00
|
|
|
playlist_get_random(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_set_random(struct playlist *playlist, struct player_control *pc,
|
|
|
|
bool status);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-03-27 14:42:55 +01:00
|
|
|
bool
|
2009-07-29 00:07:01 +02:00
|
|
|
playlist_get_single(const struct playlist *playlist);
|
2009-03-27 14:42:55 +01:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_set_single(struct playlist *playlist, struct player_control *pc,
|
|
|
|
bool status);
|
2009-03-27 14:42:55 +01:00
|
|
|
|
2009-03-30 00:01:02 +02:00
|
|
|
bool
|
2009-07-29 00:07:01 +02:00
|
|
|
playlist_get_consume(const struct playlist *playlist);
|
2009-03-30 00:01:02 +02:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
|
|
|
playlist_set_consume(struct playlist *playlist, bool status);
|
2009-03-30 00:01:02 +02:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
int
|
|
|
|
playlist_get_current_song(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
int
|
|
|
|
playlist_get_next_song(const struct playlist *playlist);
|
2009-02-08 06:21:00 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
unsigned
|
2009-07-29 00:07:01 +02:00
|
|
|
playlist_get_song_id(const struct playlist *playlist, unsigned song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
int
|
|
|
|
playlist_get_length(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
unsigned long
|
2009-07-29 00:07:01 +02:00
|
|
|
playlist_get_version(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_seek_song(struct playlist *playlist, struct player_control *pc,
|
|
|
|
unsigned song, float seek_time);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
2009-11-03 21:08:48 +01:00
|
|
|
playlist_seek_song_id(struct playlist *playlist, struct player_control *pc,
|
2009-02-04 18:56:41 +01:00
|
|
|
unsigned id, float seek_time);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2011-12-24 11:20:02 +01:00
|
|
|
/**
|
|
|
|
* Seek within the current song. Fails if MPD is not currently
|
|
|
|
* playing.
|
|
|
|
*
|
|
|
|
* @param time the time in seconds
|
|
|
|
* @param relative if true, then the specified time is relative to the
|
|
|
|
* current position
|
|
|
|
*/
|
|
|
|
enum playlist_result
|
|
|
|
playlist_seek_current(struct playlist *playlist, struct player_control *pc,
|
|
|
|
float seek_time, bool relative);
|
|
|
|
|
2009-07-29 00:07:01 +02:00
|
|
|
void
|
|
|
|
playlist_increment_version_all(struct playlist *playlist);
|
2008-09-07 13:37:04 +02:00
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
#endif
|