Handle streams separately in tree_add_track()
[cmus.git] / cmus.h
blob1102c4b4e9b7da37f1081b9924d3c282b66439ea
1 #ifndef _CMUS_H
2 #define _CMUS_H
4 #include "track_info.h"
6 /*
7 * these types are only used to determine what jobs we should cancel.
8 * for example ":load" cancels jobs for the current view before loading
9 * new playlist.
12 #define JOB_TYPE_LIB 1
13 #define JOB_TYPE_PL 2
14 #define JOB_TYPE_QUEUE 3
16 enum file_type {
17 /* not found, device file... */
18 FILE_TYPE_INVALID,
20 FILE_TYPE_URL,
21 FILE_TYPE_PL,
22 FILE_TYPE_DIR,
23 FILE_TYPE_FILE
26 typedef int (*track_info_cb)(void *data, struct track_info *ti);
28 /* lib_for_each, pl_for_each */
29 typedef int (*for_each_ti_cb)(track_info_cb cb, void *data);
31 /* lib_for_each_sel, pl_for_each_sel, play_queue_for_each_sel */
32 typedef int (*for_each_sel_ti_cb)(track_info_cb cb, void *data, int reverse);
34 /* lib_add_track, pl_add_track, play_queue_append, play_queue_prepend */
35 typedef void (*add_ti_cb)(struct track_info *);
37 int cmus_init(void);
38 void cmus_exit(void);
39 void cmus_play_file(const char *filename);
41 /* detect file type, returns absolute path or url in @ret */
42 enum file_type cmus_detect_ft(const char *name, char **ret);
44 /* add to library, playlist or queue view
46 * @add callback that does the actual adding
47 * @name playlist, directory, file, URL
48 * @ft detected FILE_TYPE_*
49 * @jt JOB_TYPE_{LIB,PL,QUEUE}
51 * returns immediately, actual work is done in the worker thread.
53 void cmus_add(add_ti_cb, const char *name, enum file_type ft, int jt);
55 int cmus_save(for_each_ti_cb for_each_ti, const char *filename);
57 void cmus_update_cache(void);
58 void cmus_update_lib(void);
59 void cmus_update_tis(struct track_info **tis, int nr);
61 int cmus_is_playlist(const char *filename);
62 int cmus_is_playable(const char *filename);
63 int cmus_is_supported(const char *filename);
65 int cmus_playlist_for_each(const char *buf, int size, int reverse,
66 int (*cb)(void *data, const char *line),
67 void *data);
69 void cmus_next(void);
70 void cmus_prev(void);
72 #endif