2004-02-24 00:41:20 +01:00
|
|
|
/* the Music Player Daemon (MPD)
|
2007-04-05 05:22:33 +02:00
|
|
|
* Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
|
2004-02-24 00:41:20 +01:00
|
|
|
* This project's homepage is: http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
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"
|
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
|
|
|
#include <stdio.h>
|
|
|
|
|
2007-05-16 14:02:10 +02:00
|
|
|
#define PLAYLIST_COMMENT '#'
|
|
|
|
|
2008-09-07 13:39:31 +02:00
|
|
|
enum playlist_result {
|
|
|
|
PLAYLIST_RESULT_SUCCESS,
|
|
|
|
PLAYLIST_RESULT_ERRNO,
|
2008-10-15 22:35:13 +02:00
|
|
|
PLAYLIST_RESULT_DENIED,
|
2008-09-07 13:39:31 +02:00
|
|
|
PLAYLIST_RESULT_NO_SUCH_SONG,
|
|
|
|
PLAYLIST_RESULT_NO_SUCH_LIST,
|
|
|
|
PLAYLIST_RESULT_LIST_EXISTS,
|
|
|
|
PLAYLIST_RESULT_BAD_NAME,
|
|
|
|
PLAYLIST_RESULT_BAD_RANGE,
|
|
|
|
PLAYLIST_RESULT_NOT_PLAYING,
|
2009-01-18 16:15:45 +01:00
|
|
|
PLAYLIST_RESULT_TOO_LARGE,
|
|
|
|
PLAYLIST_RESULT_DISABLED,
|
2008-09-07 13:39:31 +02:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
void initPlaylist(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2006-08-20 02:50:44 +02:00
|
|
|
void finishPlaylist(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
|
|
|
|
2006-07-31 01:32:47 +02:00
|
|
|
void readPlaylistState(FILE *);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2006-07-31 01:32:47 +02:00
|
|
|
void savePlaylistState(FILE *);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void clearPlaylist(struct playlist *playlist);
|
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-02-04 18:56:41 +01:00
|
|
|
playlist_append_file(struct playlist *playlist, 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
|
|
|
|
addToPlaylist(struct playlist *playlist, 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-02-04 18:56:41 +01:00
|
|
|
addSongToPlaylist(struct playlist *playlist,
|
|
|
|
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
|
|
|
|
deleteFromPlaylist(struct playlist *playlist, unsigned song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
|
|
|
deleteFromPlaylistById(struct playlist *playlist, unsigned song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void stopPlaylist(struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
|
|
|
playPlaylist(struct playlist *playlist, int song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
|
|
|
playPlaylistById(struct playlist *playlist, int song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void nextSongInPlaylist(struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void syncPlayerAndPlaylist(struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void previousSongInPlaylist(struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void shufflePlaylist(struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-10-08 10:49:11 +02:00
|
|
|
void
|
2009-02-04 18:56:41 +01:00
|
|
|
deleteASongFromPlaylist(struct playlist *playlist, const struct song *song);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
|
|
|
moveSongInPlaylist(struct playlist *playlist, unsigned from, int to);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
|
|
|
moveSongInPlaylistById(struct playlist *playlist, unsigned id, int to);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
|
|
|
swapSongsInPlaylist(struct playlist *playlist, unsigned song1, unsigned song2);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
|
|
|
swapSongsInPlaylistById(struct playlist *playlist, unsigned id1, unsigned id2);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
bool
|
2009-02-04 22:08:39 +01:00
|
|
|
getPlaylistRepeatStatus(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void setPlaylistRepeatStatus(struct playlist *playlist, bool status);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
bool
|
2009-02-04 22:08:39 +01:00
|
|
|
getPlaylistRandomStatus(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void setPlaylistRandomStatus(struct playlist *playlist, bool status);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 22:08:39 +01:00
|
|
|
int getPlaylistCurrentSong(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-08 06:21:00 +01:00
|
|
|
int getPlaylistNextSong(const struct playlist *playlist);
|
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
unsigned
|
2009-02-04 22:08:39 +01:00
|
|
|
getPlaylistSongId(const struct playlist *playlist, unsigned song);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-02-04 22:08:39 +01:00
|
|
|
int getPlaylistLength(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
unsigned long
|
2009-02-04 22:08:39 +01:00
|
|
|
getPlaylistVersion(const struct playlist *playlist);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
|
|
|
seekSongInPlaylist(struct playlist *playlist, unsigned song, float seek_time);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
enum playlist_result
|
|
|
|
seekSongInPlaylistById(struct playlist *playlist,
|
|
|
|
unsigned id, float seek_time);
|
2004-06-09 04:50:44 +02:00
|
|
|
|
2009-02-04 18:56:41 +01:00
|
|
|
void playlistVersionChange(struct playlist *playlist);
|
2004-06-05 03:14:37 +02:00
|
|
|
|
2008-09-07 13:37:04 +02:00
|
|
|
int is_valid_playlist_name(const char *utf8path);
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
#endif
|