~ubuntu-branches/ubuntu/utopic/mpd/utopic-proposed

« back to all changes in this revision

Viewing changes to src/DecoderAPI.hxx

  • Committer: Package Import Robot
  • Author(s): Steve Kowalik
  • Date: 2013-11-12 18:17:40 UTC
  • mfrom: (2.2.36 sid)
  • Revision ID: package-import@ubuntu.com-20131112181740-72aa4zihehoobedp
Tags: 0.18.3-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Add libmp3lame-dev to Build-Depends, and enable LAME.
  - Read the user for the daemon from the config file in the init script.
  - Move avahi-daemon from Suggests to Recommends.
  - Added apport hook to include user configuration file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2003-2013 The Music Player Daemon Project
 
3
 * http://www.musicpd.org
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
18
 */
 
19
 
 
20
/*! \file
 
21
 * \brief The MPD Decoder API
 
22
 *
 
23
 * This is the public API which is used by decoder plugins to
 
24
 * communicate with the mpd core.
 
25
 */
 
26
 
 
27
#ifndef MPD_DECODER_API_HXX
 
28
#define MPD_DECODER_API_HXX
 
29
 
 
30
#include "check.h"
 
31
#include "DecoderCommand.hxx"
 
32
#include "DecoderPlugin.hxx"
 
33
#include "ReplayGainInfo.hxx"
 
34
#include "tag/Tag.hxx"
 
35
#include "AudioFormat.hxx"
 
36
#include "MixRampInfo.hxx"
 
37
#include "ConfigData.hxx"
 
38
 
 
39
/**
 
40
 * Notify the player thread that it has finished initialization and
 
41
 * that it has read the song's meta data.
 
42
 *
 
43
 * @param decoder the decoder object
 
44
 * @param audio_format the audio format which is going to be sent to
 
45
 * decoder_data()
 
46
 * @param seekable true if the song is seekable
 
47
 * @param total_time the total number of seconds in this song; -1 if unknown
 
48
 */
 
49
void
 
50
decoder_initialized(Decoder &decoder,
 
51
                    AudioFormat audio_format,
 
52
                    bool seekable, float total_time);
 
53
 
 
54
/**
 
55
 * Determines the pending decoder command.
 
56
 *
 
57
 * @param decoder the decoder object
 
58
 * @return the current command, or DecoderCommand::NONE if there is no
 
59
 * command pending
 
60
 */
 
61
gcc_pure
 
62
DecoderCommand
 
63
decoder_get_command(Decoder &decoder);
 
64
 
 
65
/**
 
66
 * Called by the decoder when it has performed the requested command
 
67
 * (dc->command).  This function resets dc->command and wakes up the
 
68
 * player thread.
 
69
 *
 
70
 * @param decoder the decoder object
 
71
 */
 
72
void
 
73
decoder_command_finished(Decoder &decoder);
 
74
 
 
75
/**
 
76
 * Call this when you have received the DecoderCommand::SEEK command.
 
77
 *
 
78
 * @param decoder the decoder object
 
79
 * @return the destination position for the week
 
80
 */
 
81
gcc_pure
 
82
double
 
83
decoder_seek_where(Decoder &decoder);
 
84
 
 
85
/**
 
86
 * Call this instead of decoder_command_finished() when seeking has
 
87
 * failed.
 
88
 *
 
89
 * @param decoder the decoder object
 
90
 */
 
91
void
 
92
decoder_seek_error(Decoder &decoder);
 
93
 
 
94
/**
 
95
 * Blocking read from the input stream.
 
96
 *
 
97
 * @param decoder the decoder object
 
98
 * @param is the input stream to read from
 
99
 * @param buffer the destination buffer
 
100
 * @param length the maximum number of bytes to read
 
101
 * @return the number of bytes read, or 0 if one of the following
 
102
 * occurs: end of file; error; command (like SEEK or STOP).
 
103
 */
 
104
size_t
 
105
decoder_read(Decoder *decoder, InputStream &is,
 
106
             void *buffer, size_t length);
 
107
 
 
108
static inline size_t
 
109
decoder_read(Decoder &decoder, InputStream &is,
 
110
             void *buffer, size_t length)
 
111
{
 
112
        return decoder_read(&decoder, is, buffer, length);
 
113
}
 
114
 
 
115
/**
 
116
 * Sets the time stamp for the next data chunk [seconds].  The MPD
 
117
 * core automatically counts it up, and a decoder plugin only needs to
 
118
 * use this function if it thinks that adding to the time stamp based
 
119
 * on the buffer size won't work.
 
120
 */
 
121
void
 
122
decoder_timestamp(Decoder &decoder, double t);
 
123
 
 
124
/**
 
125
 * This function is called by the decoder plugin when it has
 
126
 * successfully decoded block of input data.
 
127
 *
 
128
 * @param decoder the decoder object
 
129
 * @param is an input stream which is buffering while we are waiting
 
130
 * for the player
 
131
 * @param data the source buffer
 
132
 * @param length the number of bytes in the buffer
 
133
 * @return the current command, or DecoderCommand::NONE if there is no
 
134
 * command pending
 
135
 */
 
136
DecoderCommand
 
137
decoder_data(Decoder &decoder, InputStream *is,
 
138
             const void *data, size_t length,
 
139
             uint16_t kbit_rate);
 
140
 
 
141
static inline DecoderCommand
 
142
decoder_data(Decoder &decoder, InputStream &is,
 
143
             const void *data, size_t length,
 
144
             uint16_t kbit_rate)
 
145
{
 
146
        return decoder_data(decoder, &is, data, length, kbit_rate);
 
147
}
 
148
 
 
149
/**
 
150
 * This function is called by the decoder plugin when it has
 
151
 * successfully decoded a tag.
 
152
 *
 
153
 * @param decoder the decoder object
 
154
 * @param is an input stream which is buffering while we are waiting
 
155
 * for the player
 
156
 * @param tag the tag to send
 
157
 * @return the current command, or DecoderCommand::NONE if there is no
 
158
 * command pending
 
159
 */
 
160
DecoderCommand
 
161
decoder_tag(Decoder &decoder, InputStream *is, Tag &&tag);
 
162
 
 
163
static inline DecoderCommand
 
164
decoder_tag(Decoder &decoder, InputStream &is, Tag &&tag)
 
165
{
 
166
        return decoder_tag(decoder, &is, std::move(tag));
 
167
}
 
168
 
 
169
/**
 
170
 * Set replay gain values for the following chunks.
 
171
 *
 
172
 * @param decoder the decoder object
 
173
 * @param rgi the replay_gain_info object; may be nullptr to invalidate
 
174
 * the previous replay gain values
 
175
 */
 
176
void
 
177
decoder_replay_gain(Decoder &decoder,
 
178
                    const ReplayGainInfo *replay_gain_info);
 
179
 
 
180
/**
 
181
 * Store MixRamp tags.
 
182
 *
 
183
 * @param decoder the decoder object
 
184
 * @param mixramp_start the mixramp_start tag; may be nullptr to invalidate
 
185
 * @param mixramp_end the mixramp_end tag; may be nullptr to invalidate
 
186
 */
 
187
void
 
188
decoder_mixramp(Decoder &decoder, MixRampInfo &&mix_ramp);
 
189
 
 
190
#endif