MPD: output/MultipleOutputs.hxx Source File

MPD 0.20.15

MultipleOutputs.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 * Functions for dealing with all configured (enabled) audion outputs
22 * at once.
23 *
24 */
25
26 #ifndef OUTPUT_ALL_H
27 #define OUTPUT_ALL_H
28
29 #include "AudioFormat.hxx"
30 #include "ReplayGainMode.hxx"
31 #include "Chrono.hxx"
32 #include "Compiler.h"
33
34 #include <vector>
35
36 #include <assert.h>
37
38 class MusicBuffer;
39 class MusicPipe;
40 class EventLoop;
41 class MixerListener;
42 class AudioOutputClient;
43 struct MusicChunk;
44 struct AudioOutput;
45 struct ReplayGainConfig;
46
47 class MultipleOutputs {
48 MixerListener &mixer_listener;
49
50 std::vector<AudioOutput *> outputs;
51
52 AudioFormat input_audio_format = AudioFormat::Undefined();
53
57 MusicBuffer *buffer = nullptr;
58
63 MusicPipe *pipe = nullptr;
64
69 SignedSongTime elapsed_time = SignedSongTime::Negative();
70
71 public:
76 MultipleOutputs(MixerListener &_mixer_listener);
77 ~MultipleOutputs();
78
79 void Configure(EventLoop &event_loop,
80 const ReplayGainConfig &replay_gain_config,
81 AudioOutputClient &client);
82
87 gcc_pure
88 unsigned Size() const noexcept {
89 return outputs.size();
90 }
91
95 const AudioOutput &Get(unsigned i) const {
96 assert(i < Size());
97
98 return *outputs[i];
99 }
100
101 AudioOutput &Get(unsigned i) {
102 assert(i < Size());
103
104 return *outputs[i];
105 }
106
111 gcc_pure
112 AudioOutput *FindByName(const char *name) const noexcept;
113
118 void EnableDisable();
119
129 void Open(const AudioFormat audio_format, MusicBuffer &_buffer);
130
134 void Close();
135
140 void Release();
141
142 void SetReplayGainMode(ReplayGainMode mode);
143
152 void Play(MusicChunk *chunk);
153
160 unsigned Check();
161
166 void Pause();
167
171 void Drain();
172
176 void Cancel();
177
181 void SongBorder();
182
188 gcc_pure
189 SignedSongTime GetElapsedTime() const noexcept {
190 return elapsed_time;
191 }
192
197 gcc_pure
198 int GetVolume() const noexcept;
199
206 bool SetVolume(unsigned volume) noexcept;
207
213 gcc_pure
214 int GetSoftwareVolume() const noexcept;
215
222 void SetSoftwareVolume(unsigned volume) noexcept;
223
224 private:
229 gcc_pure
230 bool AllFinished() const noexcept;
231
232 void WaitAll() noexcept;
233
237 void AllowPlay();
238
245 bool Update(bool force);
246
250 bool IsChunkConsumed(const MusicChunk *chunk) const noexcept;
251
257 void ClearTailChunk(const MusicChunk *chunk, bool *locked);
258 };
259
260 #endif
ReplayGainMode
ReplayGainMode
Definition: ReplayGainMode.hxx:27
AudioFormat
This structure describes the format of a raw PCM stream.
Definition: AudioFormat.hxx:37
ReplayGainMode.hxx
AudioOutputClient
An interface between the AudioOutput and the #Player.
Definition: Client.hxx:28
MultipleOutputs::SetVolume
bool SetVolume(unsigned volume) noexcept
Sets the volume on all available mixers.
MultipleOutputs::Open
void Open(const AudioFormat audio_format, MusicBuffer &_buffer)
Opens all audio outputs which are not disabled.
MultipleOutputs::Pause
void Pause()
Puts all audio outputs into pause mode.
AudioOutput
Definition: Internal.hxx:45
Chrono.hxx
MusicPipe
A queue of MusicChunk objects.
Definition: MusicPipe.hxx:39
AudioFormat.hxx
ReplayGainConfig
Definition: ReplayGainConfig.hxx:25
MultipleOutputs::SetReplayGainMode
void SetReplayGainMode(ReplayGainMode mode)
MultipleOutputs::Drain
void Drain()
Drain all audio outputs.
EventLoop
An event loop that polls for events on file/socket descriptors.
Definition: Loop.hxx:51
MultipleOutputs::Size
gcc_pure unsigned Size() const noexcept
Returns the total number of audio output devices, including those which are disabled right now...
Definition: MultipleOutputs.hxx:88
MultipleOutputs::MultipleOutputs
MultipleOutputs(MixerListener &_mixer_listener)
Load audio outputs from the configuration file and initialize them.
MultipleOutputs::~MultipleOutputs
~MultipleOutputs()
MultipleOutputs::Check
unsigned Check()
Checks if the output devices have drained their music pipe, and returns the consumed music chunks to ...
MusicBuffer
An allocator for MusicChunk objects.
Definition: MusicBuffer.hxx:31
MultipleOutputs::Play
void Play(MusicChunk *chunk)
Enqueue a MusicChunk object for playing, i.e.
MultipleOutputs::Release
void Release()
Closes all audio outputs.
AudioFormat::Undefined
static constexpr AudioFormat Undefined()
Definition: AudioFormat.hxx:75
SignedSongTime::Negative
static constexpr SignedSongTime Negative()
Generate a negative value.
Definition: Chrono.hxx:137
MusicChunk
A chunk of music data.
Definition: MusicChunk.hxx:43
MultipleOutputs::GetElapsedTime
gcc_pure SignedSongTime GetElapsedTime() const noexcept
Returns the "elapsed_time" stamp of the most recently finished chunk.
Definition: MultipleOutputs.hxx:189
MultipleOutputs::Close
void Close()
Closes all audio outputs.
Compiler.h
MultipleOutputs::SetSoftwareVolume
void SetSoftwareVolume(unsigned volume) noexcept
Similar to SetVolume(), but sets the volume only for software mixers.
MultipleOutputs::EnableDisable
void EnableDisable()
Checks the "enabled" flag of all audio outputs, and if one has changed, commit the change...
MultipleOutputs::Cancel
void Cancel()
Try to cancel data which may still be in the device&#39;s buffers.
MultipleOutputs::FindByName
gcc_pure AudioOutput * FindByName(const char *name) const noexcept
Returns the audio output device with the specified name.
MultipleOutputs
Definition: MultipleOutputs.hxx:47
SignedSongTime
A variant of SongTime that is based on a signed integer.
Definition: Chrono.hxx:115
MixerListener
An interface that listens on events from mixer plugins.
Definition: Listener.hxx:29
MultipleOutputs::SongBorder
void SongBorder()
Indicate that a new song will begin now.
MultipleOutputs::Configure
void Configure(EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, AudioOutputClient &client)
MultipleOutputs::Get
AudioOutput & Get(unsigned i)
Definition: MultipleOutputs.hxx:101
MultipleOutputs::GetVolume
gcc_pure int GetVolume() const noexcept
Returns the average volume of all available mixers (range 0..100).
MultipleOutputs::Get
const AudioOutput & Get(unsigned i) const
Returns the "i"th audio output device.
Definition: MultipleOutputs.hxx:95
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
MultipleOutputs::GetSoftwareVolume
gcc_pure int GetSoftwareVolume() const noexcept
Similar to GetVolume(), but gets the volume only for software mixers.
name
const Partition const char * name
Definition: Count.hxx:34