libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
audioblock.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <functional>
14
16
17class String;
18class AudioDesc;
19
26class AudioBlock : public ObjectBase {
27 PROMEKI_OBJECT(AudioBlock, ObjectBase);
28 public:
34 class Config {
35 public:
40 size_t sourceChannels = 0;
45 size_t sinkChannels = 0;
46 };
47
53 AudioBlock(const Config &config, ObjectBase *parent = nullptr);
54
56 virtual ~AudioBlock() {}
57
61 bool isSource() const { return _blockConfig.sourceChannels > 0; }
62
68 bool isSourceValid(size_t val) const { return val < _blockConfig.sourceChannels; }
69
73 size_t sourceChannels() const { return _blockConfig.sourceChannels; }
74
80 virtual AudioDesc sourceDesc(size_t channel) const;
81
88 virtual bool setSourceDesc(size_t channel, const AudioDesc &val);
89
95 virtual String sourceName(size_t channel) const;
96
103 virtual bool setSourceName(size_t channel, const String &val);
104
111
117
121 bool isSink() const { return _blockConfig.sinkChannels > 0; }
122
128 bool isSinkValid(size_t val) const { return val < _blockConfig.sinkChannels; }
129
133 size_t sinkChannels() const { return _blockConfig.sinkChannels; }
134
140 virtual AudioDesc sinkDesc(size_t channel) const;
141
148 virtual bool setSinkDesc(size_t channel, const AudioDesc &val);
149
155 virtual String sinkName(size_t channel) const;
156
163 virtual bool setSinkName(size_t channel, const String &val);
164
170 virtual ssize_t sinkSamplesAllowed(size_t channel) const;
171
177
178 private:
179 Config _blockConfig;
180 StringList _sourceNameList;
181 StringList _sinkNameList;
182
183};
184
186
Config used by the derived class to configure AudioBlock This config is passed in by the derived clas...
Definition audioblock.h:34
size_t sinkChannels
Number of channels this block can sink Should be set to zero if this block can not sink any channels.
Definition audioblock.h:45
size_t sourceChannels
Number of channels this block can source Should be set to zero if this block can not source any chann...
Definition audioblock.h:40
Base class for an audio processing block This object defines an interface for composing an audio proc...
Definition audioblock.h:26
virtual String sinkName(size_t channel) const
Returns the name of a given sink channel.
size_t sourceChannels() const
Returns the number of channels this object can source.
Definition audioblock.h:73
PROMEKI_SIGNAL(sinkReadyForSamples, AudioBlock *, size_t)
Signal emitted whenever a sink channel can accept more samples.
size_t sinkChannels() const
Returns the number of sink channels.
Definition audioblock.h:133
virtual bool setSourceDesc(size_t channel, const AudioDesc &val)
Sets the audio description for a given source channel.
virtual ~AudioBlock()
Virtual destructor.
Definition audioblock.h:56
bool isSource() const
Returns true if the audio block is a source.
Definition audioblock.h:61
virtual String sourceName(size_t channel) const
Returns the name of a given source channel.
virtual AudioDesc sourceDesc(size_t channel) const
Returns the audio description for a given source channel.
bool isSink() const
Returns true if the object is an audio sink.
Definition audioblock.h:121
PROMEKI_SIGNAL(sourceHasSamples, AudioBlock *, size_t)
Signal emitted when a source has samples available.
AudioBlock(const Config &config, ObjectBase *parent=nullptr)
Constructs an AudioBlock with a given configuration.
virtual ssize_t sinkSamplesAllowed(size_t channel) const
Returns the number of samples a sink channel can currently accept.
virtual bool setSourceName(size_t channel, const String &val)
Sets the name of a given source channel.
virtual AudioDesc sinkDesc(size_t channel) const
Returns the audio description of a given sink channel.
virtual bool setSinkDesc(size_t channel, const AudioDesc &val)
Sets the audio description of a given sink channel.
virtual bool setSinkName(size_t channel, const String &val)
Sets the name of a given sink channel.
bool isSinkValid(size_t val) const
Returns true if the given sink channel index is valid.
Definition audioblock.h:128
virtual ssize_t sourceSamplesAvailable(size_t channel) const
Returns the number of samples available on a source channel.
bool isSourceValid(size_t val) const
Returns true if the given source index is valid.
Definition audioblock.h:68
Describes an audio format including sample type, rate, and channel count.
Definition audiodesc.h:28
Dynamic array container wrapping std::vector.
Definition list.h:40
Base object for promeki.
Definition objectbase.h:129
ObjectBase * parent() const
Returns the parent object, if one. nullptr if none.
Definition objectbase.h:258
Manages a list of strings.
Definition stringlist.h:21
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19