MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

MusicChunk.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_MUSIC_CHUNK_HXX
21 #define MPD_MUSIC_CHUNK_HXX
22
23 #include "Chrono.hxx"
24 #include "ReplayGainInfo.hxx"
25 #include "util/WritableBuffer.hxx"
26
27 #ifndef NDEBUG
28 #include "AudioFormat.hxx"
29 #endif
30
31 #include <stdint.h>
32 #include <stddef.h>
33
34 static constexpr size_t CHUNK_SIZE = 4096;
35
36 struct AudioFormat;
37 struct Tag;
38
43 struct MusicChunk {
45 MusicChunk *next;
46
51 MusicChunk *other = nullptr;
52
57 float mix_ratio;
58
60 uint16_t length = 0;
61
63 uint16_t bit_rate;
64
66 SignedSongTime time;
67
74 Tag *tag = nullptr;
75
80 ReplayGainInfo replay_gain_info;
81
87 unsigned replay_gain_serial = 0;
88
90 uint8_t data[CHUNK_SIZE];
91
92 #ifndef NDEBUG
93 AudioFormat audio_format;
94 #endif
95
96 MusicChunk() = default;
97
98 MusicChunk(const MusicChunk &) = delete;
99
100 ~MusicChunk();
101
102 MusicChunk &operator=(const MusicChunk &) = delete;
103
104 bool IsEmpty() const {
105 return length == 0 && tag == nullptr;
106 }
107
108 #ifndef NDEBUG
109
113 gcc_pure
114 bool CheckFormat(AudioFormat audio_format) const;
115 #endif
116
128 WritableBuffer<void> Write(AudioFormat af,
129 SongTime data_time,
130 uint16_t bit_rate);
131
141 bool Expand(AudioFormat af, size_t length);
142 };
143
144 #endif
WritableBuffer.hxx
AudioFormat
This structure describes the format of a raw PCM stream.
Definition: AudioFormat.hxx:37
Chrono.hxx
Tag
The meta information about a song file.
Definition: Tag.hxx:34
AudioFormat.hxx
SongTime
A time stamp within a song.
Definition: Chrono.hxx:31
MusicChunk::CheckFormat
gcc_pure bool CheckFormat(AudioFormat audio_format) const
Checks if the audio format if the chunk is equal to the specified audio_format.
MusicChunk::tag
Tag * tag
An optional tag associated with this chunk (and the following chunks); appears at song boundaries...
Definition: MusicChunk.hxx:74
MusicChunk::mix_ratio
float mix_ratio
The current mix ratio for cross-fading: 1.0 means play 100% of this chunk, 0.0 means play 100% of the...
Definition: MusicChunk.hxx:57
MusicChunk::IsEmpty
bool IsEmpty() const
Definition: MusicChunk.hxx:104
MusicChunk
A chunk of music data.
Definition: MusicChunk.hxx:43
MusicChunk::length
uint16_t length
number of bytes stored in this chunk
Definition: MusicChunk.hxx:60
MusicChunk::other
MusicChunk * other
An optional chunk which should be mixed into this chunk.
Definition: MusicChunk.hxx:51
WritableBuffer< void >
Definition: WritableBuffer.hxx:45
MusicChunk::replay_gain_serial
unsigned replay_gain_serial
A serial number for checking if replay gain info has changed since the last chunk.
Definition: MusicChunk.hxx:87
CHUNK_SIZE
static constexpr size_t CHUNK_SIZE
Definition: MusicChunk.hxx:34
ReplayGainInfo
Definition: ReplayGainInfo.hxx:46
MusicChunk::data
uint8_t data[CHUNK_SIZE]
the data (probably PCM)
Definition: MusicChunk.hxx:90
MusicChunk::Expand
bool Expand(AudioFormat af, size_t length)
Increases the length of the chunk after the caller has written to the buffer returned by Write()...
MusicChunk::time
SignedSongTime time
the time stamp within the song
Definition: MusicChunk.hxx:66
ReplayGainInfo.hxx
MusicChunk::replay_gain_info
ReplayGainInfo replay_gain_info
Replay gain information associated with this chunk.
Definition: MusicChunk.hxx:80
MusicChunk::Write
WritableBuffer< void > Write(AudioFormat af, SongTime data_time, uint16_t bit_rate)
Prepares appending to the music chunk.
SignedSongTime
A variant of SongTime that is based on a signed integer.
Definition: Chrono.hxx:115
MusicChunk::next
MusicChunk * next
the next chunk in a linked list
Definition: MusicChunk.hxx:45
MusicChunk::operator=
MusicChunk & operator=(const MusicChunk &)=delete
MusicChunk::bit_rate
uint16_t bit_rate
current bit rate of the source file
Definition: MusicChunk.hxx:63
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
MusicChunk::MusicChunk
MusicChunk()=default
MusicChunk::~MusicChunk
~MusicChunk()
MusicChunk::audio_format
AudioFormat audio_format
Definition: MusicChunk.hxx:93