1 /* the Music Player Daemon (MPD)
2 * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
3 * Copyright (C) 2008 Max Kellermann <max@duempel.org>
4 * This project's homepage is: http://www.musicpd.org
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef MPD_DECODER_CONTROL_H
21 #define MPD_DECODER_CONTROL_H
23 #include "decoder_api.h"
25 #include "audio_format.h"
30 #define DECODE_TYPE_FILE 0
31 #define DECODE_TYPE_URL 1
34 DECODE_STATE_STOP
= 0,
39 * The last "START" command failed, because there was an I/O
40 * error or because no decoder was able to decode the file.
41 * This state will only come after START; once the state has
42 * turned to DECODE, by definition no such error can occur.
47 struct decoder_control
{
50 volatile enum decoder_state state
;
51 volatile enum decoder_command command
;
54 volatile double seek_where
;
56 /** the format of the song file */
57 struct audio_format in_audio_format
;
59 /** the format being sent to the music pipe */
60 struct audio_format out_audio_format
;
62 struct song
*current_song
;
63 struct song
*next_song
;
67 extern struct decoder_control dc
;
73 static inline bool decoder_is_idle(void)
75 return (dc
.state
== DECODE_STATE_STOP
||
76 dc
.state
== DECODE_STATE_ERROR
) &&
77 dc
.command
!= DECODE_COMMAND_START
;
80 static inline bool decoder_is_starting(void)
82 return dc
.command
== DECODE_COMMAND_START
||
83 dc
.state
== DECODE_STATE_START
;
86 static inline bool decoder_has_failed(void)
88 assert(dc
.command
== DECODE_COMMAND_NONE
);
90 return dc
.state
== DECODE_STATE_ERROR
;
93 static inline struct song
*
94 decoder_current_song(void)
97 case DECODE_STATE_STOP
:
98 case DECODE_STATE_ERROR
:
101 case DECODE_STATE_START
:
102 case DECODE_STATE_DECODE
:
103 return dc
.current_song
;
111 dc_command_wait(struct notify
*notify
);
114 dc_start(struct notify
*notify
, struct song
*song
);
117 dc_start_async(struct song
*song
);
120 dc_stop(struct notify
*notify
);
123 dc_seek(struct notify
*notify
, double where
);