Handle streams separately in tree_add_track()
[cmus.git] / player.h
blobb8bae5430d980e80b1fc70824fa8da23d8871f00
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"
25 #include "track_info.h"
27 #include <pthread.h>
29 enum {
30 /* no error */
31 PLAYER_ERROR_SUCCESS,
32 /* system error (error code in errno) */
33 PLAYER_ERROR_ERRNO,
34 /* function not supported */
35 PLAYER_ERROR_NOT_SUPPORTED
38 enum player_status {
39 PLAYER_STATUS_STOPPED,
40 PLAYER_STATUS_PLAYING,
41 PLAYER_STATUS_PAUSED
44 enum replaygain {
45 RG_DISABLED,
46 RG_TRACK,
47 RG_ALBUM
50 struct player_callbacks {
51 int (*get_next)(struct track_info **ti);
54 struct player_info {
55 pthread_mutex_t mutex;
57 /* current track */
58 struct track_info *ti;
60 /* stream metadata */
61 char metadata[255 * 16 + 1];
63 /* status */
64 enum player_status status;
65 int pos;
67 int buffer_fill;
68 int buffer_size;
70 /* display this if not NULL */
71 char *error_msg;
73 unsigned int file_changed : 1;
74 unsigned int metadata_changed : 1;
75 unsigned int status_changed : 1;
76 unsigned int position_changed : 1;
77 unsigned int buffer_fill_changed : 1;
80 extern struct player_info player_info;
81 extern int player_cont;
82 extern int player_repeat_current;
83 extern enum replaygain replaygain;
84 extern int replaygain_limit;
85 extern double replaygain_preamp;
86 extern int soft_vol;
87 extern int soft_vol_l;
88 extern int soft_vol_r;
90 void player_init(const struct player_callbacks *callbacks);
91 void player_exit(void);
93 /* set current file */
94 void player_set_file(struct track_info *ti);
96 /* set current file and start playing */
97 void player_play_file(struct track_info *ti);
99 void player_play(void);
100 void player_stop(void);
101 void player_pause(void);
102 void player_seek(double offset, int relative);
103 void player_set_op(const char *name);
104 void player_set_buffer_chunks(unsigned int nr_chunks);
105 int player_get_buffer_chunks(void);
107 void player_set_soft_volume(int l, int r);
108 void player_set_soft_vol(int soft);
109 void player_set_rg(enum replaygain rg);
110 void player_set_rg_limit(int limit);
111 void player_set_rg_preamp(double db);
113 #define player_info_lock() cmus_mutex_lock(&player_info.mutex)
114 #define player_info_unlock() cmus_mutex_unlock(&player_info.mutex)
116 #endif