00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MPD_PLAYER_H
00021 #define MPD_PLAYER_H
00022
00023 #include "audio_format.h"
00024
00025 #include <glib.h>
00026
00027 #include <stdint.h>
00028
00029 struct decoder_control;
00030
00031 enum player_state {
00032 PLAYER_STATE_STOP = 0,
00033 PLAYER_STATE_PAUSE,
00034 PLAYER_STATE_PLAY
00035 };
00036
00037 enum player_command {
00038 PLAYER_COMMAND_NONE = 0,
00039 PLAYER_COMMAND_EXIT,
00040 PLAYER_COMMAND_STOP,
00041 PLAYER_COMMAND_PAUSE,
00042 PLAYER_COMMAND_SEEK,
00043 PLAYER_COMMAND_CLOSE_AUDIO,
00044
00049 PLAYER_COMMAND_UPDATE_AUDIO,
00050
00052 PLAYER_COMMAND_QUEUE,
00053
00059 PLAYER_COMMAND_CANCEL,
00060
00065 PLAYER_COMMAND_REFRESH,
00066 };
00067
00068 enum player_error {
00069 PLAYER_ERROR_NOERROR = 0,
00070 PLAYER_ERROR_FILE,
00071 PLAYER_ERROR_AUDIO,
00072 PLAYER_ERROR_SYSTEM,
00073 PLAYER_ERROR_UNKTYPE,
00074 PLAYER_ERROR_FILENOTFOUND,
00075 };
00076
00077 struct player_status {
00078 enum player_state state;
00079 uint16_t bit_rate;
00080 struct audio_format audio_format;
00081 float total_time;
00082 float elapsed_time;
00083 };
00084
00085 struct player_control {
00086 unsigned buffer_chunks;
00087
00088 unsigned int buffered_before_play;
00089
00092 GThread *thread;
00093
00097 GMutex *mutex;
00098
00102 GCond *cond;
00103
00104 enum player_command command;
00105 enum player_state state;
00106 enum player_error error;
00107 uint16_t bit_rate;
00108 struct audio_format audio_format;
00109 float total_time;
00110 float elapsed_time;
00111 struct song *next_song;
00112 const struct song *errored_song;
00113 double seek_where;
00114 float cross_fade_seconds;
00115 float mixramp_db;
00116 float mixramp_delay_seconds;
00117 double total_play_time;
00118
00126 bool border_pause;
00127 };
00128
00129 struct player_control *
00130 pc_new(unsigned buffer_chunks, unsigned buffered_before_play);
00131
00132 void
00133 pc_free(struct player_control *pc);
00134
00138 static inline void
00139 player_lock(struct player_control *pc)
00140 {
00141 g_mutex_lock(pc->mutex);
00142 }
00143
00147 static inline void
00148 player_unlock(struct player_control *pc)
00149 {
00150 g_mutex_unlock(pc->mutex);
00151 }
00152
00158 static inline void
00159 player_wait(struct player_control *pc)
00160 {
00161 g_cond_wait(pc->cond, pc->mutex);
00162 }
00163
00171 void
00172 player_wait_decoder(struct player_control *pc, struct decoder_control *dc);
00173
00178 static inline void
00179 player_signal(struct player_control *pc)
00180 {
00181 g_cond_signal(pc->cond);
00182 }
00183
00188 static inline void
00189 player_lock_signal(struct player_control *pc)
00190 {
00191 player_lock(pc);
00192 player_signal(pc);
00193 player_unlock(pc);
00194 }
00195
00201 void
00202 pc_song_deleted(struct player_control *pc, const struct song *song);
00203
00204 void
00205 pc_play(struct player_control *pc, struct song *song);
00206
00210 void
00211 pc_cancel(struct player_control *pc);
00212
00213 void
00214 pc_set_pause(struct player_control *pc, bool pause_flag);
00215
00216 void
00217 pc_pause(struct player_control *pc);
00218
00222 void
00223 pc_set_border_pause(struct player_control *pc, bool border_pause);
00224
00225 void
00226 pc_kill(struct player_control *pc);
00227
00228 void
00229 pc_get_status(struct player_control *pc, struct player_status *status);
00230
00231 enum player_state
00232 pc_get_state(struct player_control *pc);
00233
00234 void
00235 pc_clear_error(struct player_control *pc);
00236
00242 char *
00243 pc_get_error_message(struct player_control *pc);
00244
00245 enum player_error
00246 pc_get_error(struct player_control *pc);
00247
00248 void
00249 pc_stop(struct player_control *pc);
00250
00251 void
00252 pc_update_audio(struct player_control *pc);
00253
00254 void
00255 pc_enqueue_song(struct player_control *pc, struct song *song);
00256
00263 bool
00264 pc_seek(struct player_control *pc, struct song *song, float seek_time);
00265
00266 void
00267 pc_set_cross_fade(struct player_control *pc, float cross_fade_seconds);
00268
00269 float
00270 pc_get_cross_fade(const struct player_control *pc);
00271
00272 void
00273 pc_set_mixramp_db(struct player_control *pc, float mixramp_db);
00274
00275 float
00276 pc_get_mixramp_db(const struct player_control *pc);
00277
00278 void
00279 pc_set_mixramp_delay(struct player_control *pc, float mixramp_delay_seconds);
00280
00281 float
00282 pc_get_mixramp_delay(const struct player_control *pc);
00283
00284 double
00285 pc_get_total_play_time(const struct player_control *pc);
00286
00287 #endif