1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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__
31 bool current
; /* current playing playlist */
32 char filename
[MAX_PATH
]; /* path name of m3u playlist on disk */
33 char control_filename
[MAX_PATH
]; /* full path of control file */
34 int fd
; /* descriptor of the open playlist file */
35 int control_fd
; /* descriptor of the open control file */
36 bool control_created
; /* has control file been created? */
37 int dirlen
; /* Length of the path to the playlist file */
38 unsigned long *indices
; /* array of indices */
39 int max_playlist_size
; /* Max number of files in playlist. Mirror of
40 global_settings.max_files_in_playlist */
41 bool in_ram
; /* playlist stored in ram (dirplay) */
42 char *buffer
; /* buffer for in-ram playlists */
43 int buffer_size
; /* size of buffer */
44 int buffer_end_pos
; /* last position where buffer was written */
45 int index
; /* index of current playing track */
46 int first_index
; /* index of first song in playlist */
47 int amount
; /* number of tracks in the index */
48 int last_insert_pos
; /* last position we inserted a track */
49 int seed
; /* shuffle seed */
50 bool shuffle_modified
; /* has playlist been shuffled with
52 bool deleted
; /* have any tracks been deleted? */
53 int num_inserted_tracks
; /* number of tracks inserted */
54 bool shuffle_flush
; /* does shuffle value need to be flushed? */
55 struct mutex control_mutex
; /* mutex for control file access */
58 #define PLAYLIST_ATTR_QUEUED 0x01
59 #define PLAYLIST_ATTR_INSERTED 0x02
61 struct playlist_track_info
63 char filename
[MAX_PATH
]; /* path name of mp3 file */
64 int attr
; /* playlist attributes for track */
65 int index
; /* index of track in playlist */
66 int display_index
; /* index of track for display */
69 /* Exported functions only for current playlist. */
70 void playlist_init(void);
71 int playlist_create(const char *dir
, const char *file
);
72 int playlist_resume(void);
73 int playlist_add(const char *filename
);
74 int playlist_shuffle(int random_seed
, int start_index
);
75 int playlist_start(int start_index
, int offset
);
76 bool playlist_check(int steps
);
77 char *playlist_peek(int steps
);
78 int playlist_next(int steps
);
79 int playlist_get_resume_info(int *resume_index
);
80 int playlist_get_display_index(void);
81 int playlist_amount(void);
83 /* Exported functions for all playlists. Pass NULL for playlist_info
84 structure to work with current playlist. */
85 int playlist_create_ex(struct playlist_info
* playlist
,
86 const char* dir
, const char* file
,
87 void* index_buffer
, int index_buffer_size
,
88 void* temp_buffer
, int temp_buffer_size
);
89 int playlist_set_current(struct playlist_info
* playlist
);
90 void playlist_close(struct playlist_info
* playlist
);
91 int playlist_insert_track(struct playlist_info
* playlist
, const char *filename
,
92 int position
, bool queue
);
93 int playlist_insert_directory(struct playlist_info
* playlist
,
94 const char *dirname
, int position
, bool queue
,
96 int playlist_insert_playlist(struct playlist_info
* playlist
, char *filename
,
97 int position
, bool queue
);
98 int playlist_delete(struct playlist_info
* playlist
, int index
);
99 int playlist_move(struct playlist_info
* playlist
, int index
, int new_index
);
100 int playlist_randomise(struct playlist_info
* playlist
, unsigned int seed
,
102 int playlist_sort(struct playlist_info
* playlist
, bool start_current
);
103 bool playlist_modified(const struct playlist_info
* playlist
);
104 int playlist_get_first_index(const struct playlist_info
* playlist
);
105 int playlist_get_seed(const struct playlist_info
* playlist
);
106 int playlist_amount_ex(const struct playlist_info
* playlist
);
107 char *playlist_name(const struct playlist_info
* playlist
, char *buf
,
109 char *playlist_get_name(const struct playlist_info
* playlist
, char *buf
,
111 int playlist_get_track_info(struct playlist_info
* playlist
, int index
,
112 struct playlist_track_info
* info
);
113 int playlist_save(struct playlist_info
* playlist
, char *filename
);
116 PLAYLIST_PREPEND
= -1,
117 PLAYLIST_INSERT
= -2,
118 PLAYLIST_INSERT_LAST
= -3,
119 PLAYLIST_INSERT_FIRST
= -4
123 PLAYLIST_DELETE_CURRENT
= -1
126 #endif /* __PLAYLIST_H__ */