MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

PeakBuffer.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_PEAK_BUFFER_HXX
21 #define MPD_PEAK_BUFFER_HXX
22
23 #include "Compiler.h"
24
25 #include <stddef.h>
26 #include <stdint.h>
27
28 template<typename T> struct WritableBuffer;
29 template<typename T> class DynamicFifoBuffer;
30
36 class PeakBuffer {
37 size_t normal_size, peak_size;
38
39 DynamicFifoBuffer<uint8_t> *normal_buffer, *peak_buffer;
40
41 public:
42 PeakBuffer(size_t _normal_size, size_t _peak_size)
43 :normal_size(_normal_size), peak_size(_peak_size),
44 normal_buffer(nullptr), peak_buffer(nullptr) {}
45
46 PeakBuffer(PeakBuffer &&other)
47 :normal_size(other.normal_size), peak_size(other.peak_size),
48 normal_buffer(other.normal_buffer),
49 peak_buffer(other.peak_buffer) {
50 other.normal_buffer = nullptr;
51 other.peak_buffer = nullptr;
52 }
53
54 ~PeakBuffer();
55
56 PeakBuffer(const PeakBuffer &) = delete;
57 PeakBuffer &operator=(const PeakBuffer &) = delete;
58
59 gcc_pure
60 bool IsEmpty() const;
61
62 gcc_pure
63 WritableBuffer<void> Read() const;
64
65 void Consume(size_t length);
66
67 bool Append(const void *data, size_t length);
68 };
69
70 #endif
PeakBuffer::Consume
void Consume(size_t length)
PeakBuffer
A FIFO-like buffer that will allocate more memory on demand to allow large peaks. ...
Definition: PeakBuffer.hxx:36
PeakBuffer::operator=
PeakBuffer & operator=(const PeakBuffer &)=delete
WritableBuffer
A reference to a memory area that is writable.
Definition: Silence.hxx:27
PeakBuffer::Read
gcc_pure WritableBuffer< void > Read() const
PeakBuffer::PeakBuffer
PeakBuffer(size_t _normal_size, size_t _peak_size)
Definition: PeakBuffer.hxx:42
Compiler.h
WritableBuffer< void >
Definition: WritableBuffer.hxx:45
PeakBuffer::IsEmpty
gcc_pure bool IsEmpty() const
PeakBuffer::Append
bool Append(const void *data, size_t length)
DynamicFifoBuffer
A first-in-first-out buffer: you can append data at the end, and read data from the beginning...
Definition: DynamicFifoBuffer.hxx:41
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
PeakBuffer::PeakBuffer
PeakBuffer(PeakBuffer &&other)
Definition: PeakBuffer.hxx:46
PeakBuffer::~PeakBuffer
~PeakBuffer()