Sort playlist file for library views in same order as view 2
[cmus.git] / player.h
blob8ea5fb6f0b80d67d9b3e9422780a4c56426754d7
1 /*
2 * Copyright 2004 Timo Hirvonen
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
20 #ifndef _PLAYER_H
21 #define _PLAYER_H
23 #include "locking.h"
24 #include "comment.h"
26 #include <pthread.h>
28 enum {
29 /* no error */
30 PLAYER_ERROR_SUCCESS,
31 /* system error (error code in errno) */
32 PLAYER_ERROR_ERRNO,
33 /* function not supported */
34 PLAYER_ERROR_NOT_SUPPORTED
37 enum player_status {
38 PLAYER_STATUS_STOPPED,
39 PLAYER_STATUS_PLAYING,
40 PLAYER_STATUS_PAUSED
43 struct player_callbacks {
44 int (*get_next)(char **filename);
47 struct player_info {
48 pthread_mutex_t mutex;
50 char filename[256];
52 /* stream metadata */
53 char metadata[255 * 16 + 1];
55 /* status */
56 enum player_status status;
57 int pos;
59 /* volume */
60 int vol_left;
61 int vol_right;
63 int buffer_fill;
64 int buffer_size;
66 /* display this if not NULL */
67 char *error_msg;
69 unsigned int file_changed : 1;
70 unsigned int metadata_changed : 1;
71 unsigned int status_changed : 1;
72 unsigned int position_changed : 1;
73 unsigned int buffer_fill_changed : 1;
74 unsigned int vol_changed : 1;
77 extern struct player_info player_info;
78 extern int player_cont;
80 /* defined in output.c */
81 extern int volume_max;
83 void player_load_plugins(void);
85 void player_init(const struct player_callbacks *callbacks);
86 void player_exit(void);
88 /* set current file */
89 void player_set_file(const char *filename);
91 /* set current file and start playing */
92 void player_play_file(const char *filename);
94 void player_play(void);
95 void player_stop(void);
96 void player_pause(void);
97 void player_seek(double offset, int relative);
98 void player_set_op(const char *name);
99 char *player_get_op(void);
100 void player_set_buffer_chunks(unsigned int nr_chunks);
101 int player_get_buffer_chunks(void);
102 void player_set_buffer_seconds(unsigned int seconds);
103 int player_get_fileinfo(const char *filename, int *duration, struct keyval **comments);
105 int player_get_volume(int *left, int *right);
106 int player_set_volume(int left, int right);
107 void player_set_soft_vol(int soft);
109 int player_set_op_option(unsigned int id, const char *val);
110 int player_get_op_option(unsigned int id, char **val);
111 int player_for_each_op_option(void (*callback)(unsigned int id, const char *key));
112 void player_dump_plugins(void);
114 #define player_info_lock() cmus_mutex_lock(&player_info.mutex)
115 #define player_info_unlock() cmus_mutex_unlock(&player_info.mutex)
117 #endif