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 "notify.h"
00024 #include "audio_format.h"
00025
00026 #include <stdint.h>
00027
00028 enum player_state {
00029 PLAYER_STATE_STOP = 0,
00030 PLAYER_STATE_PAUSE,
00031 PLAYER_STATE_PLAY
00032 };
00033
00034 enum player_command {
00035 PLAYER_COMMAND_NONE = 0,
00036 PLAYER_COMMAND_EXIT,
00037 PLAYER_COMMAND_STOP,
00038 PLAYER_COMMAND_PLAY,
00039 PLAYER_COMMAND_PAUSE,
00040 PLAYER_COMMAND_SEEK,
00041 PLAYER_COMMAND_CLOSE_AUDIO,
00042
00044 PLAYER_COMMAND_QUEUE,
00045
00051 PLAYER_COMMAND_CANCEL,
00052 };
00053
00054 enum player_error {
00055 PLAYER_ERROR_NOERROR = 0,
00056 PLAYER_ERROR_FILE,
00057 PLAYER_ERROR_AUDIO,
00058 PLAYER_ERROR_SYSTEM,
00059 PLAYER_ERROR_UNKTYPE,
00060 PLAYER_ERROR_FILENOTFOUND,
00061 };
00062
00063 struct player_control {
00064 unsigned buffer_chunks;
00065
00066 unsigned int buffered_before_play;
00067
00070 GThread *thread;
00071
00072 struct notify notify;
00073 volatile enum player_command command;
00074 volatile enum player_state state;
00075 volatile enum player_error error;
00076 uint16_t bit_rate;
00077 struct audio_format audio_format;
00078 float total_time;
00079 float elapsed_time;
00080 struct song *volatile next_song;
00081 struct song *errored_song;
00082 volatile double seek_where;
00083 float cross_fade_seconds;
00084 uint16_t software_volume;
00085 double total_play_time;
00086 };
00087
00088 extern struct player_control pc;
00089
00090 void pc_init(unsigned buffer_chunks, unsigned buffered_before_play);
00091
00092 void pc_deinit(void);
00093
00099 void
00100 pc_song_deleted(const struct song *song);
00101
00102 void
00103 playerPlay(struct song *song);
00104
00108 void pc_cancel(void);
00109
00110 void playerSetPause(int pause_flag);
00111
00112 void playerPause(void);
00113
00114 void playerKill(void);
00115
00116 int getPlayerTotalTime(void);
00117
00118 int getPlayerElapsedTime(void);
00119
00120 unsigned long getPlayerBitRate(void);
00121
00122 enum player_state getPlayerState(void);
00123
00124 void clearPlayerError(void);
00125
00126 char *getPlayerErrorStr(void);
00127
00128 enum player_error getPlayerError(void);
00129
00130 void playerWait(void);
00131
00132 void
00133 queueSong(struct song *song);
00134
00141 bool
00142 pc_seek(struct song *song, float seek_time);
00143
00144 void setPlayerCrossFade(float crossFadeInSeconds);
00145
00146 float getPlayerCrossFade(void);
00147
00148 void setPlayerSoftwareVolume(int volume);
00149
00150 double getPlayerTotalPlayTime(void);
00151
00152 static inline const struct audio_format *
00153 player_get_audio_format(void)
00154 {
00155 return &pc.audio_format;
00156 }
00157
00158 void playerInit(void);
00159
00160 #endif