MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

Bridge.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 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 #ifndef MPD_DECODER_BRIDGE_HXX
21 #define MPD_DECODER_BRIDGE_HXX
22
23 #include "Client.hxx"
24 #include "ReplayGainInfo.hxx"
25
26 #include <exception>
27
28 class PcmConvert;
29 struct MusicChunk;
30 struct DecoderControl;
31 struct Tag;
32
37 class DecoderBridge final : public DecoderClient {
38 public:
39 DecoderControl &dc;
40
45 PcmConvert *convert = nullptr;
46
50 double timestamp = 0;
51
56 bool initial_seek_pending;
57
64 bool initial_seek_running = false;
65
70 bool seeking = false;
71
77 Tag *song_tag;
78
80 Tag *stream_tag = nullptr;
81
83 Tag *decoder_tag = nullptr;
84
86 MusicChunk *current_chunk = nullptr;
87
88 ReplayGainInfo replay_gain_info;
89
94 unsigned replay_gain_serial = 0;
95
100 std::exception_ptr error;
101
102 DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending,
103 Tag *_tag)
104 :dc(_dc),
105 initial_seek_pending(_initial_seek_pending),
106 song_tag(_tag) {}
107
108 ~DecoderBridge();
109
116 gcc_pure
117 bool CheckCancelRead() const;
118
125 MusicChunk *GetChunk();
126
132 void FlushChunk();
133
134 /* virtual methods from DecoderClient */
135 void Ready(AudioFormat audio_format,
136 bool seekable, SignedSongTime duration) override;
137 DecoderCommand GetCommand() override;
138 void CommandFinished() override;
139 SongTime GetSeekTime() override;
140 uint64_t GetSeekFrame() override;
141 void SeekError() override;
142 InputStreamPtr OpenUri(const char *uri) override;
143 size_t Read(InputStream &is, void *buffer, size_t length) override;
144 void SubmitTimestamp(double t) override;
145 DecoderCommand SubmitData(InputStream *is,
146 const void *data, size_t length,
147 uint16_t kbit_rate) override;
148 DecoderCommand SubmitTag(InputStream *is, Tag &&tag) override ;
149 void SubmitReplayGain(const ReplayGainInfo *replay_gain_info) override;
150 void SubmitMixRamp(MixRampInfo &&mix_ramp) override;
151
152 private:
157 bool PrepareInitialSeek();
158
164 DecoderCommand GetVirtualCommand();
165 DecoderCommand LockGetVirtualCommand();
166
171 DecoderCommand DoSendTag(const Tag &tag);
172
173 bool UpdateStreamTag(InputStream *is);
174 };
175
176 #endif
DecoderBridge::CheckCancelRead
gcc_pure bool CheckCancelRead() const
Should be read operation be cancelled? That is the case when the player thread has sent a command suc...
DecoderBridge::GetCommand
DecoderCommand GetCommand() override
Determines the pending decoder command.
DecoderClient
An interface between the decoder plugin and the MPD core.
Definition: Client.hxx:39
AudioFormat
This structure describes the format of a raw PCM stream.
Definition: AudioFormat.hxx:37
DecoderBridge::GetChunk
MusicChunk * GetChunk()
Returns the current chunk the decoder writes to, or allocates a new chunk if there is none...
DecoderBridge::decoder_tag
Tag * decoder_tag
the last tag received from the decoder plugin
Definition: Bridge.hxx:83
DecoderBridge::initial_seek_pending
bool initial_seek_pending
Is the initial seek (to the start position of the sub-song) pending, or has it been performed already...
Definition: Bridge.hxx:56
Tag
The meta information about a song file.
Definition: Tag.hxx:34
SongTime
A time stamp within a song.
Definition: Chrono.hxx:31
DecoderBridge::convert
PcmConvert * convert
For converting input data to the configured audio format.
Definition: Bridge.hxx:45
DecoderBridge::~DecoderBridge
~DecoderBridge()
InputStream
Definition: InputStream.hxx:36
DecoderBridge::FlushChunk
void FlushChunk()
Flushes the current chunk.
DecoderBridge::SeekError
void SeekError() override
Call this instead of CommandFinished() when seeking has failed.
DecoderControl
Definition: DecoderControl.hxx:63
MixRampInfo
Definition: MixRampInfo.hxx:28
MusicChunk
A chunk of music data.
Definition: MusicChunk.hxx:43
DecoderBridge::replay_gain_info
ReplayGainInfo replay_gain_info
Definition: Bridge.hxx:88
DecoderBridge::DecoderBridge
DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending, Tag *_tag)
Definition: Bridge.hxx:102
DecoderBridge::current_chunk
MusicChunk * current_chunk
the chunk currently being written to
Definition: Bridge.hxx:86
DecoderBridge::error
std::exception_ptr error
An error has occurred (in DecoderAPI.cxx), and the plugin will be asked to stop.
Definition: Bridge.hxx:100
DecoderBridge::replay_gain_serial
unsigned replay_gain_serial
A positive serial number for checking if replay gain info has changed since the last check...
Definition: Bridge.hxx:94
DecoderBridge::SubmitData
DecoderCommand SubmitData(InputStream *is, const void *data, size_t length, uint16_t kbit_rate) override
This function is called by the decoder plugin when it has successfully decoded block of input data...
Client.hxx
DecoderBridge::seeking
bool seeking
This flag is set by GetSeekTime(), and checked by CommandFinished().
Definition: Bridge.hxx:70
ReplayGainInfo
Definition: ReplayGainInfo.hxx:46
DecoderBridge::timestamp
double timestamp
The time stamp of the next data chunk, in seconds.
Definition: Bridge.hxx:50
DecoderBridge::Read
size_t Read(InputStream &is, void *buffer, size_t length) override
Blocking read from the input stream.
DecoderBridge::SubmitTimestamp
void SubmitTimestamp(double t) override
Sets the time stamp for the next data chunk [seconds].
DecoderBridge::CommandFinished
void CommandFinished() override
Called by the decoder when it has performed the requested command (dc->command).
InputStreamPtr
std::unique_ptr< InputStream > InputStreamPtr
Definition: Ptr.hxx:25
DecoderBridge::SubmitMixRamp
void SubmitMixRamp(MixRampInfo &&mix_ramp) override
Store MixRamp tags.
ReplayGainInfo.hxx
DecoderBridge::initial_seek_running
bool initial_seek_running
Is the initial seek currently running? During this time, the decoder command is SEEK.
Definition: Bridge.hxx:64
DecoderBridge::GetSeekTime
SongTime GetSeekTime() override
Call this when you have received the DecoderCommand::SEEK command.
DecoderCommand
DecoderCommand
Definition: DecoderCommand.hxx:25
SignedSongTime
A variant of SongTime that is based on a signed integer.
Definition: Chrono.hxx:115
DecoderBridge::stream_tag
Tag * stream_tag
the last tag received from the stream
Definition: Bridge.hxx:80
DecoderBridge::dc
DecoderControl & dc
Definition: Bridge.hxx:39
DecoderBridge::SubmitReplayGain
void SubmitReplayGain(const ReplayGainInfo *replay_gain_info) override
Set replay gain values for the following chunks.
DecoderBridge::SubmitTag
DecoderCommand SubmitTag(InputStream *is, Tag &&tag) override
This function is called by the decoder plugin when it has successfully decoded a tag.
DecoderBridge::song_tag
Tag * song_tag
The tag from the song object.
Definition: Bridge.hxx:77
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
PcmConvert
This object is statically allocated (within another struct), and holds buffer allocations and the sta...
Definition: PcmConvert.hxx:40
DecoderBridge::GetSeekFrame
uint64_t GetSeekFrame() override
Call this when you have received the DecoderCommand::SEEK command.
DecoderBridge::Ready
void Ready(AudioFormat audio_format, bool seekable, SignedSongTime duration) override
Notify the client that it has finished initialization and that it has read the song's meta data...
uri
const Storage const char * uri
Definition: DatabasePlaylist.hxx:31
DecoderBridge
A bridge between the DecoderClient interface and the MPD core (DecoderControl, MusicPipe etc...
Definition: Bridge.hxx:37
DecoderBridge::OpenUri
InputStreamPtr OpenUri(const char *uri) override
Open a new InputStream and wait until it's ready.