lots of old and new edits
[kugel-rb.git] / apps / playlist.h
blob286823e0cf1010242771a661e52ae4a538137bff
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by wavey@wavey.org
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #ifndef __PLAYLIST_H__
21 #define __PLAYLIST_H__
23 #include <stdbool.h>
24 #include "file.h"
25 #include "kernel.h"
26 #include "id3.h"
28 /* playlist data */
30 struct playlist_info
32 bool current; /* current playing playlist */
33 char filename[MAX_PATH]; /* path name of m3u playlist on disk */
34 char control_filename[MAX_PATH]; /* full path of control file */
35 int fd; /* descriptor of the open playlist file */
36 int control_fd; /* descriptor of the open control file */
37 bool control_created; /* has control file been created? */
38 int dirlen; /* Length of the path to the playlist file */
39 unsigned long *indices; /* array of indices */
40 const struct dircache_entry **filenames; /* Entries from dircache */
41 int max_playlist_size; /* Max number of files in playlist. Mirror of
42 global_settings.max_files_in_playlist */
43 bool in_ram; /* playlist stored in ram (dirplay) */
44 char *buffer; /* buffer for in-ram playlists */
45 int buffer_size; /* size of buffer */
46 int buffer_end_pos; /* last position where buffer was written */
47 int index; /* index of current playing track */
48 int first_index; /* index of first song in playlist */
49 int amount; /* number of tracks in the index */
50 int last_insert_pos; /* last position we inserted a track */
51 int seed; /* shuffle seed */
52 bool shuffle_modified; /* has playlist been shuffled with
53 inserted tracks? */
54 bool deleted; /* have any tracks been deleted? */
55 int num_inserted_tracks; /* number of tracks inserted */
56 bool shuffle_flush; /* does shuffle value need to be flushed? */
57 struct mutex control_mutex; /* mutex for control file access */
60 #define PLAYLIST_ATTR_QUEUED 0x01
61 #define PLAYLIST_ATTR_INSERTED 0x02
62 #define PLAYLIST_ATTR_SKIPPED 0x04
64 #define DEFAULT_DYNAMIC_PLAYLIST_NAME "/dynamic.m3u"
66 struct playlist_track_info
68 char filename[MAX_PATH]; /* path name of mp3 file */
69 int attr; /* playlist attributes for track */
70 int index; /* index of track in playlist */
71 int display_index; /* index of track for display */
74 /* Exported functions only for current playlist. */
75 void playlist_init(void);
76 int playlist_create(const char *dir, const char *file);
77 int playlist_resume(void);
78 int playlist_add(const char *filename);
79 int playlist_shuffle(int random_seed, int start_index);
80 int playlist_start(int start_index, int offset);
81 bool playlist_check(int steps);
82 char *playlist_peek(int steps);
83 int playlist_next(int steps);
84 bool playlist_next_dir(int direction);
85 int playlist_get_resume_info(int *resume_index);
86 int playlist_update_resume_info(const struct mp3entry* id3);
87 int playlist_get_display_index(void);
88 int playlist_amount(void);
90 /* Exported functions for all playlists. Pass NULL for playlist_info
91 structure to work with current playlist. */
92 int playlist_create_ex(struct playlist_info* playlist,
93 const char* dir, const char* file,
94 void* index_buffer, int index_buffer_size,
95 void* temp_buffer, int temp_buffer_size);
96 int playlist_set_current(struct playlist_info* playlist);
97 void playlist_close(struct playlist_info* playlist);
98 int playlist_insert_track(struct playlist_info* playlist, const char *filename,
99 int position, bool queue);
100 int playlist_insert_directory(struct playlist_info* playlist,
101 const char *dirname, int position, bool queue,
102 bool recurse);
103 int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
104 int position, bool queue);
105 void playlist_skip_entry(struct playlist_info *playlist, int steps);
106 int playlist_delete(struct playlist_info* playlist, int index);
107 int playlist_move(struct playlist_info* playlist, int index, int new_index);
108 int playlist_randomise(struct playlist_info* playlist, unsigned int seed,
109 bool start_current);
110 int playlist_sort(struct playlist_info* playlist, bool start_current);
111 bool playlist_modified(const struct playlist_info* playlist);
112 int playlist_get_first_index(const struct playlist_info* playlist);
113 int playlist_get_seed(const struct playlist_info* playlist);
114 int playlist_amount_ex(const struct playlist_info* playlist);
115 char *playlist_name(const struct playlist_info* playlist, char *buf,
116 int buf_size);
117 char *playlist_get_name(const struct playlist_info* playlist, char *buf,
118 int buf_size);
119 int playlist_get_track_info(struct playlist_info* playlist, int index,
120 struct playlist_track_info* info);
121 int playlist_save(struct playlist_info* playlist, char *filename);
123 enum {
124 PLAYLIST_PREPEND = -1,
125 PLAYLIST_INSERT = -2,
126 PLAYLIST_INSERT_LAST = -3,
127 PLAYLIST_INSERT_FIRST = -4,
128 PLAYLIST_INSERT_SHUFFLED = -5
131 enum {
132 PLAYLIST_DELETE_CURRENT = -1
135 #endif /* __PLAYLIST_H__ */