player_control.h 3.06 KB
Newer Older
Warren Dukes's avatar
Warren Dukes committed
1
/* the Music Player Daemon (MPD)
2
 * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
Warren Dukes's avatar
Warren Dukes committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * This project's homepage is: http://www.musicpd.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

19 20
#ifndef MPD_PLAYER_H
#define MPD_PLAYER_H
Warren Dukes's avatar
Warren Dukes committed
21

Max Kellermann's avatar
Max Kellermann committed
22
#include "notify.h"
23
#include "audio_format.h"
24 25

#include <stdint.h>
Warren Dukes's avatar
Warren Dukes committed
26

27 28 29 30 31
enum player_state {
	PLAYER_STATE_STOP = 0,
	PLAYER_STATE_PAUSE,
	PLAYER_STATE_PLAY
};
Warren Dukes's avatar
Warren Dukes committed
32

33 34
enum player_command {
	PLAYER_COMMAND_NONE = 0,
Max Kellermann's avatar
Max Kellermann committed
35
	PLAYER_COMMAND_EXIT,
36 37 38 39 40
	PLAYER_COMMAND_STOP,
	PLAYER_COMMAND_PLAY,
	PLAYER_COMMAND_PAUSE,
	PLAYER_COMMAND_SEEK,
	PLAYER_COMMAND_CLOSE_AUDIO,
41 42 43 44 45 46 47 48 49 50

	/** player_control.next_song has been updated */
	PLAYER_COMMAND_QUEUE,

	/**
	 * cancel pre-decoding player_control.next_song; if the player
	 * has already started playing this song, it will completely
	 * stop
	 */
	PLAYER_COMMAND_CANCEL,
51 52
};

53 54 55 56 57 58 59 60
enum player_error {
	PLAYER_ERROR_NOERROR = 0,
	PLAYER_ERROR_FILE,
	PLAYER_ERROR_AUDIO,
	PLAYER_ERROR_SYSTEM,
	PLAYER_ERROR_UNKTYPE,
	PLAYER_ERROR_FILENOTFOUND,
};
Warren Dukes's avatar
Warren Dukes committed
61

62
struct player_control {
63 64
	unsigned int buffered_before_play;

65
	struct notify notify;
66
	volatile enum player_command command;
67
	volatile enum player_state state;
68
	volatile enum player_error error;
69
	uint16_t bit_rate;
70
	struct audio_format audio_format;
71 72
	float total_time;
	float elapsed_time;
73 74
	struct song *volatile next_song;
	struct song *errored_song;
Max Kellermann's avatar
Max Kellermann committed
75
	volatile double seek_where;
76 77 78
	float cross_fade_seconds;
	uint16_t software_volume;
	double total_play_time;
79 80 81
};

extern struct player_control pc;
Warren Dukes's avatar
Warren Dukes committed
82

83 84
void pc_init(unsigned int buffered_before_play);

85 86
void pc_deinit(void);

87 88
void
playerPlay(struct song *song);
Warren Dukes's avatar
Warren Dukes committed
89

90 91 92 93 94
/**
 * see PLAYER_COMMAND_CANCEL
 */
void pc_cancel(void);

95
void playerSetPause(int pause_flag);
96

97
void playerPause(void);
Warren Dukes's avatar
Warren Dukes committed
98

99
void playerKill(void);
Warren Dukes's avatar
Warren Dukes committed
100

101
int getPlayerTotalTime(void);
Warren Dukes's avatar
Warren Dukes committed
102

103
int getPlayerElapsedTime(void);
Warren Dukes's avatar
Warren Dukes committed
104

105
unsigned long getPlayerBitRate(void);
Warren Dukes's avatar
Warren Dukes committed
106

107
enum player_state getPlayerState(void);
Warren Dukes's avatar
Warren Dukes committed
108

109
void clearPlayerError(void);
Warren Dukes's avatar
Warren Dukes committed
110

111
char *getPlayerErrorStr(void);
Warren Dukes's avatar
Warren Dukes committed
112

113
enum player_error getPlayerError(void);
Warren Dukes's avatar
Warren Dukes committed
114

115
void playerWait(void);
116

117 118
void
queueSong(struct song *song);
Warren Dukes's avatar
Warren Dukes committed
119

120 121
int
playerSeek(struct song *song, float seek_time);
Warren Dukes's avatar
Warren Dukes committed
122 123 124

void setPlayerCrossFade(float crossFadeInSeconds);

125
float getPlayerCrossFade(void);
Warren Dukes's avatar
Warren Dukes committed
126 127 128

void setPlayerSoftwareVolume(int volume);

129
double getPlayerTotalPlayTime(void);
Warren Dukes's avatar
Warren Dukes committed
130

131 132 133 134 135
static inline const struct audio_format *
player_get_audio_format(void)
{
	return &pc.audio_format;
}
136

137 138
struct song *
playerCurrentDecodeSong(void);
139

140
void playerInit(void);
141

Warren Dukes's avatar
Warren Dukes committed
142
#endif