MPD 0.17~git
|
00001 /* 00002 * Copyright (C) 2003-2011 The Music Player Daemon Project 00003 * http://www.musicpd.org 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 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 }; 00119 00120 struct player_control * 00121 pc_new(unsigned buffer_chunks, unsigned buffered_before_play); 00122 00123 void 00124 pc_free(struct player_control *pc); 00125 00129 static inline void 00130 player_lock(struct player_control *pc) 00131 { 00132 g_mutex_lock(pc->mutex); 00133 } 00134 00138 static inline void 00139 player_unlock(struct player_control *pc) 00140 { 00141 g_mutex_unlock(pc->mutex); 00142 } 00143 00149 static inline void 00150 player_wait(struct player_control *pc) 00151 { 00152 g_cond_wait(pc->cond, pc->mutex); 00153 } 00154 00162 void 00163 player_wait_decoder(struct player_control *pc, struct decoder_control *dc); 00164 00169 static inline void 00170 player_signal(struct player_control *pc) 00171 { 00172 g_cond_signal(pc->cond); 00173 } 00174 00179 static inline void 00180 player_lock_signal(struct player_control *pc) 00181 { 00182 player_lock(pc); 00183 player_signal(pc); 00184 player_unlock(pc); 00185 } 00186 00192 void 00193 pc_song_deleted(struct player_control *pc, const struct song *song); 00194 00195 void 00196 pc_play(struct player_control *pc, struct song *song); 00197 00201 void 00202 pc_cancel(struct player_control *pc); 00203 00204 void 00205 pc_set_pause(struct player_control *pc, bool pause_flag); 00206 00207 void 00208 pc_pause(struct player_control *pc); 00209 00210 void 00211 pc_kill(struct player_control *pc); 00212 00213 void 00214 pc_get_status(struct player_control *pc, struct player_status *status); 00215 00216 enum player_state 00217 pc_get_state(struct player_control *pc); 00218 00219 void 00220 pc_clear_error(struct player_control *pc); 00221 00227 char * 00228 pc_get_error_message(struct player_control *pc); 00229 00230 enum player_error 00231 pc_get_error(struct player_control *pc); 00232 00233 void 00234 pc_stop(struct player_control *pc); 00235 00236 void 00237 pc_update_audio(struct player_control *pc); 00238 00239 void 00240 pc_enqueue_song(struct player_control *pc, struct song *song); 00241 00248 bool 00249 pc_seek(struct player_control *pc, struct song *song, float seek_time); 00250 00251 void 00252 pc_set_cross_fade(struct player_control *pc, float cross_fade_seconds); 00253 00254 float 00255 pc_get_cross_fade(const struct player_control *pc); 00256 00257 void 00258 pc_set_mixramp_db(struct player_control *pc, float mixramp_db); 00259 00260 float 00261 pc_get_mixramp_db(const struct player_control *pc); 00262 00263 void 00264 pc_set_mixramp_delay(struct player_control *pc, float mixramp_delay_seconds); 00265 00266 float 00267 pc_get_mixramp_delay(const struct player_control *pc); 00268 00269 double 00270 pc_get_total_play_time(const struct player_control *pc); 00271 00272 #endif