configure.ac: Don't allow UNIX IPC to be configured for a native Windows build.
[mpd-mk.git] / src / playlist.h
blob3ba90ff91b3c428c156b204d3c816d1d07f9f208
1 /*
2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MPD_PLAYLIST_H
21 #define MPD_PLAYLIST_H
23 #include "queue.h"
25 #include <stdbool.h>
27 #define PLAYLIST_COMMENT '#'
29 enum playlist_result {
30 PLAYLIST_RESULT_SUCCESS,
31 PLAYLIST_RESULT_ERRNO,
32 PLAYLIST_RESULT_DENIED,
33 PLAYLIST_RESULT_NO_SUCH_SONG,
34 PLAYLIST_RESULT_NO_SUCH_LIST,
35 PLAYLIST_RESULT_LIST_EXISTS,
36 PLAYLIST_RESULT_BAD_NAME,
37 PLAYLIST_RESULT_BAD_RANGE,
38 PLAYLIST_RESULT_NOT_PLAYING,
39 PLAYLIST_RESULT_TOO_LARGE,
40 PLAYLIST_RESULT_DISABLED,
43 struct playlist {
44 /**
45 * The song queue - it contains the "real" playlist.
47 struct queue queue;
49 /**
50 * This value is true if the player is currently playing (or
51 * should be playing).
53 bool playing;
55 /**
56 * If true, then any error is fatal; if false, MPD will
57 * attempt to play the next song on non-fatal errors. During
58 * seeking, this flag is set.
60 bool stop_on_error;
62 /**
63 * Number of errors since playback was started. If this
64 * number exceeds the length of the playlist, MPD gives up,
65 * because all songs have been tried.
67 unsigned error_count;
69 /**
70 * The "current song pointer". This is the song which is
71 * played when we get the "play" command. It is also the song
72 * which is currently being played.
74 int current;
76 /**
77 * The "next" song to be played, when the current one
78 * finishes. The decoder thread may start decoding and
79 * buffering it, while the "current" song is still playing.
81 * This variable is only valid if #playing is true.
83 int queued;
86 /** the global playlist object */
87 extern struct playlist g_playlist;
89 void
90 playlist_global_init(void);
92 void
93 playlist_global_finish(void);
95 void
96 playlist_init(struct playlist *playlist);
98 void
99 playlist_finish(struct playlist *playlist);
101 void
102 playlist_tag_changed(struct playlist *playlist);
105 * Returns the "queue" object of the global playlist instance.
107 static inline const struct queue *
108 playlist_get_queue(const struct playlist *playlist)
110 return &playlist->queue;
113 void
114 playlist_clear(struct playlist *playlist);
116 #ifndef WIN32
118 * Appends a local file (outside the music database) to the playlist,
119 * but only if the file's owner is equal to the specified uid.
121 enum playlist_result
122 playlist_append_file(struct playlist *playlist, const char *path, int uid,
123 unsigned *added_id);
124 #endif
126 enum playlist_result
127 playlist_append_uri(struct playlist *playlist, const char *file,
128 unsigned *added_id);
130 enum playlist_result
131 playlist_append_song(struct playlist *playlist,
132 struct song *song, unsigned *added_id);
134 enum playlist_result
135 playlist_delete(struct playlist *playlist, unsigned song);
138 * Deletes a range of songs from the playlist.
140 * @param start the position of the first song to delete
141 * @param end the position after the last song to delete
143 enum playlist_result
144 playlist_delete_range(struct playlist *playlist, unsigned start, unsigned end);
146 enum playlist_result
147 playlist_delete_id(struct playlist *playlist, unsigned song);
149 void
150 playlist_stop(struct playlist *playlist);
152 enum playlist_result
153 playlist_play(struct playlist *playlist, int song);
155 enum playlist_result
156 playlist_play_id(struct playlist *playlist, int song);
158 void
159 playlist_next(struct playlist *playlist);
161 void
162 playlist_sync(struct playlist *playlist);
164 void
165 playlist_previous(struct playlist *playlist);
167 void
168 playlist_shuffle(struct playlist *playlist, unsigned start, unsigned end);
170 void
171 playlist_delete_song(struct playlist *playlist, const struct song *song);
173 enum playlist_result
174 playlist_move_range(struct playlist *playlist, unsigned start, unsigned end, int to);
176 enum playlist_result
177 playlist_move_id(struct playlist *playlist, unsigned id, int to);
179 enum playlist_result
180 playlist_swap_songs(struct playlist *playlist, unsigned song1, unsigned song2);
182 enum playlist_result
183 playlist_swap_songs_id(struct playlist *playlist, unsigned id1, unsigned id2);
185 bool
186 playlist_get_repeat(const struct playlist *playlist);
188 void
189 playlist_set_repeat(struct playlist *playlist, bool status);
191 bool
192 playlist_get_random(const struct playlist *playlist);
194 void
195 playlist_set_random(struct playlist *playlist, bool status);
197 bool
198 playlist_get_single(const struct playlist *playlist);
200 void
201 playlist_set_single(struct playlist *playlist, bool status);
203 bool
204 playlist_get_consume(const struct playlist *playlist);
206 void
207 playlist_set_consume(struct playlist *playlist, bool status);
210 playlist_get_current_song(const struct playlist *playlist);
213 playlist_get_next_song(const struct playlist *playlist);
215 unsigned
216 playlist_get_song_id(const struct playlist *playlist, unsigned song);
219 playlist_get_length(const struct playlist *playlist);
221 unsigned long
222 playlist_get_version(const struct playlist *playlist);
224 enum playlist_result
225 playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time);
227 enum playlist_result
228 playlist_seek_song_id(struct playlist *playlist,
229 unsigned id, float seek_time);
231 void
232 playlist_increment_version_all(struct playlist *playlist);
234 #endif