| 1 |
/* |
| 2 |
* Copyright 2008-2011 Various Authors |
| 3 |
* Copyright 2004 Timo Hirvonen |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU General Public License as |
| 7 |
* published by the Free Software Foundation; either version 2 of the |
| 8 |
* License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef _CMUS_H |
| 20 |
#define _CMUS_H |
| 21 |
|
| 22 |
#include "track_info.h" |
| 23 |
|
| 24 |
/* |
| 25 |
* these types are only used to determine what jobs we should cancel. |
| 26 |
* for example ":load" cancels jobs for the current view before loading |
| 27 |
* new playlist. |
| 28 |
*/ |
| 29 |
|
| 30 |
#define JOB_TYPE_LIB 1 |
| 31 |
#define JOB_TYPE_PL 2 |
| 32 |
#define JOB_TYPE_QUEUE 3 |
| 33 |
|
| 34 |
enum file_type { |
| 35 |
/* not found, device file... */ |
| 36 |
FILE_TYPE_INVALID, |
| 37 |
|
| 38 |
FILE_TYPE_URL, |
| 39 |
FILE_TYPE_PL, |
| 40 |
FILE_TYPE_DIR, |
| 41 |
FILE_TYPE_FILE, |
| 42 |
FILE_TYPE_CDDA |
| 43 |
}; |
| 44 |
|
| 45 |
typedef int (*track_info_cb)(void *data, struct track_info *ti); |
| 46 |
|
| 47 |
/* lib_for_each, lib_for_each_filtered, pl_for_each, play_queue_for_each */ |
| 48 |
typedef int (*for_each_ti_cb)(track_info_cb cb, void *data); |
| 49 |
|
| 50 |
/* lib_for_each_sel, pl_for_each_sel, play_queue_for_each_sel */ |
| 51 |
typedef int (*for_each_sel_ti_cb)(track_info_cb cb, void *data, int reverse); |
| 52 |
|
| 53 |
/* lib_add_track, pl_add_track, play_queue_append, play_queue_prepend */ |
| 54 |
typedef void (*add_ti_cb)(struct track_info *); |
| 55 |
|
| 56 |
/* cmus_save, cmus_save_ext */ |
| 57 |
typedef int (*save_ti_cb)(for_each_ti_cb for_each_ti, const char *filename); |
| 58 |
|
| 59 |
int cmus_init(void); |
| 60 |
void cmus_exit(void); |
| 61 |
void cmus_play_file(const char *filename); |
| 62 |
|
| 63 |
/* detect file type, returns absolute path or url in @ret */ |
| 64 |
enum file_type cmus_detect_ft(const char *name, char **ret); |
| 65 |
|
| 66 |
/* add to library, playlist or queue view |
| 67 |
* |
| 68 |
* @add callback that does the actual adding |
| 69 |
* @name playlist, directory, file, URL |
| 70 |
* @ft detected FILE_TYPE_* |
| 71 |
* @jt JOB_TYPE_{LIB,PL,QUEUE} |
| 72 |
* |
| 73 |
* returns immediately, actual work is done in the worker thread. |
| 74 |
*/ |
| 75 |
void cmus_add(add_ti_cb, const char *name, enum file_type ft, int jt); |
| 76 |
|
| 77 |
int cmus_save(for_each_ti_cb for_each_ti, const char *filename); |
| 78 |
int cmus_save_ext(for_each_ti_cb for_each_ti, const char *filename); |
| 79 |
|
| 80 |
void cmus_update_cache(int force); |
| 81 |
void cmus_update_lib(void); |
| 82 |
void cmus_update_tis(struct track_info **tis, int nr, int force); |
| 83 |
|
| 84 |
int cmus_is_playlist(const char *filename); |
| 85 |
int cmus_is_playable(const char *filename); |
| 86 |
int cmus_is_supported(const char *filename); |
| 87 |
|
| 88 |
int cmus_playlist_for_each(const char *buf, int size, int reverse, |
| 89 |
int (*cb)(void *data, const char *line), |
| 90 |
void *data); |
| 91 |
|
| 92 |
void cmus_next(void); |
| 93 |
void cmus_prev(void); |
| 94 |
|
| 95 |
#endif |