MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

FlacCommon.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 /*
21 * Common data structures and functions used by FLAC and OggFLAC
22 */
23
24 #ifndef MPD_FLAC_COMMON_HXX
25 #define MPD_FLAC_COMMON_HXX
26
27 #include "FlacInput.hxx"
28 #include "FlacPcm.hxx"
29 #include "../DecoderAPI.hxx"
30
31 #include <FLAC/stream_decoder.h>
32
33 struct FlacDecoder : public FlacInput {
37 bool initialized = false;
38
42 bool unsupported = false;
43
44 FlacPcmImport pcm_import;
45
50 FLAC__uint64 position = 0;
51
52 Tag tag;
53
54 FlacDecoder(DecoderClient &_client, InputStream &_input_stream)
55 :FlacInput(_input_stream, &_client) {}
56
60 bool Initialize(unsigned sample_rate, unsigned bits_per_sample,
61 unsigned channels, FLAC__uint64 total_frames);
62
63 void OnMetadata(const FLAC__StreamMetadata &metadata);
64
65 FLAC__StreamDecoderWriteStatus OnWrite(const FLAC__Frame &frame,
66 const FLAC__int32 *const buf[],
67 FLAC__uint64 nbytes);
68
73 FLAC__uint64 GetDeltaPosition(const FLAC__StreamDecoder &sd);
74
75 private:
76 void OnStreamInfo(const FLAC__StreamMetadata_StreamInfo &stream_info);
77 void OnVorbisComment(const FLAC__StreamMetadata_VorbisComment &vc);
78
86 bool OnFirstFrame(const FLAC__FrameHeader &header);
87 };
88
89 #endif /* _FLAC_COMMON_H */
FlacDecoder
Definition: FlacCommon.hxx:33
DecoderClient
An interface between the decoder plugin and the MPD core.
Definition: Client.hxx:39
FlacDecoder::unsupported
bool unsupported
Does the FLAC file contain an unsupported audio format?
Definition: FlacCommon.hxx:42
Tag
The meta information about a song file.
Definition: Tag.hxx:34
FlacDecoder::OnWrite
FLAC__StreamDecoderWriteStatus OnWrite(const FLAC__Frame &frame, const FLAC__int32 *const buf[], FLAC__uint64 nbytes)
InputStream
Definition: InputStream.hxx:36
FlacPcm.hxx
FlacDecoder::position
FLAC__uint64 position
End of last frame's position within the stream.
Definition: FlacCommon.hxx:50
FlacDecoder::GetDeltaPosition
FLAC__uint64 GetDeltaPosition(const FLAC__StreamDecoder &sd)
Calculate the delta (in bytes) between the last frame and the current frame.
FlacDecoder::Initialize
bool Initialize(unsigned sample_rate, unsigned bits_per_sample, unsigned channels, FLAC__uint64 total_frames)
Wrapper for DecoderClient::Ready().
FlacDecoder::FlacDecoder
FlacDecoder(DecoderClient &_client, InputStream &_input_stream)
Definition: FlacCommon.hxx:54
FlacInput.hxx
FlacDecoder::tag
Tag tag
Definition: FlacCommon.hxx:52
FlacDecoder::initialized
bool initialized
Has DecoderClient::Ready() been called yet?
Definition: FlacCommon.hxx:37
FlacPcmImport
This class imports libFLAC PCM data into a PCM format supported by MPD.
Definition: FlacPcm.hxx:35
FlacInput
This class wraps an InputStream in libFLAC stream decoder callbacks.
Definition: FlacInput.hxx:32
FlacDecoder::OnMetadata
void OnMetadata(const FLAC__StreamMetadata &metadata)
FlacDecoder::pcm_import
FlacPcmImport pcm_import
Definition: FlacCommon.hxx:44