2 * Copyright (C) 2003-2010 The Music Player Daemon Project
3 * http://www.musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "audio_format.h"
28 struct decoder_control
;
31 PLAYER_STATE_STOP
= 0,
37 PLAYER_COMMAND_NONE
= 0,
42 PLAYER_COMMAND_CLOSE_AUDIO
,
45 * At least one audio_output.enabled flag has been modified;
46 * commit those changes to the output threads.
48 PLAYER_COMMAND_UPDATE_AUDIO
,
50 /** player_control.next_song has been updated */
54 * cancel pre-decoding player_control.next_song; if the player
55 * has already started playing this song, it will completely
58 PLAYER_COMMAND_CANCEL
,
61 * Refresh status information in the #player_control struct,
64 PLAYER_COMMAND_REFRESH
,
68 PLAYER_ERROR_NOERROR
= 0,
73 PLAYER_ERROR_FILENOTFOUND
,
76 struct player_status
{
77 enum player_state state
;
79 struct audio_format audio_format
;
84 struct player_control
{
85 unsigned buffer_chunks
;
87 unsigned int buffered_before_play
;
89 /** the handle of the player thread, or NULL if the player
90 thread isn't running */
94 * This lock protects #command, #state, #error.
99 * Trigger this object after you have modified #command.
103 enum player_command command
;
104 enum player_state state
;
105 enum player_error error
;
107 struct audio_format audio_format
;
110 struct song
*next_song
;
111 const struct song
*errored_song
;
113 float cross_fade_seconds
;
115 float mixramp_delay_seconds
;
116 double total_play_time
;
119 extern struct player_control pc
;
121 void pc_init(unsigned buffer_chunks
, unsigned buffered_before_play
);
123 void pc_deinit(void);
126 * Locks the #player_control object.
131 g_mutex_lock(pc
.mutex
);
135 * Unlocks the #player_control object.
140 g_mutex_unlock(pc
.mutex
);
144 * Waits for a signal on the #player_control object. This function is
145 * only valid in the player thread. The object must be locked prior
146 * to calling this function.
151 g_cond_wait(pc
.cond
, pc
.mutex
);
155 * Waits for a signal on the #player_control object. This function is
156 * only valid in the player thread. The #decoder_control object must
157 * be locked prior to calling this function.
159 * Note the small difference to the player_wait() function!
162 player_wait_decoder(struct decoder_control
*dc
);
165 * Signals the #player_control object. The object should be locked
166 * prior to calling this function.
171 g_cond_signal(pc
.cond
);
175 * Signals the #player_control object. The object is temporarily
176 * locked by this function.
179 player_lock_signal(void)
187 * Call this function when the specified song pointer is about to be
188 * invalidated. This makes sure that player_control.errored_song does
189 * not point to an invalid pointer.
192 pc_song_deleted(const struct song
*song
);
195 pc_play(struct song
*song
);
198 * see PLAYER_COMMAND_CANCEL
200 void pc_cancel(void);
203 pc_set_pause(bool pause_flag
);
212 pc_get_status(struct player_status
*status
);
218 pc_clear_error(void);
221 * Returns the human-readable message describing the last error during
222 * playback, NULL if no error occurred. The caller has to free the
226 pc_get_error_message(void);
235 pc_update_audio(void);
238 pc_enqueue_song(struct song
*song
);
241 * Makes the player thread seek the specified song to a position.
243 * @return true on success, false on failure (e.g. if MPD isn't
247 pc_seek(struct song
*song
, float seek_time
);
250 pc_set_cross_fade(float cross_fade_seconds
);
253 pc_get_cross_fade(void);
256 pc_set_mixramp_db(float mixramp_db
);
259 pc_get_mixramp_db(void);
262 pc_set_mixramp_delay(float mixramp_delay_seconds
);
265 pc_get_mixramp_delay(void);
268 pc_get_total_play_time(void);