-
Notifications
You must be signed in to change notification settings - Fork 1
/
avsplitter.cpp
81 lines (69 loc) · 1.73 KB
/
avsplitter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "avsplitter.h"
#include "avexception.h"
AVSplitter::AVSplitter() :
_objects()
{
}
AVSplitter::~AVSplitter() {
}
size_t AVSplitter::pull(float */*buffer_ptr*/, size_t /*buffer_size*/)
{
throw AVException("pull: not supported operation");
}
size_t AVSplitter::push(float *buffer_ptr, size_t buffer_size) {
std::for_each(
_objects.begin(), _objects.end(),
[&](AVObject* obj) {
obj->push(buffer_ptr, buffer_size);
}
);
return buffer_size;
}
void AVSplitter::connectOutput(AVObject *object, bool recursive)
{
std::for_each(
_objects.begin(), _objects.end(),
[&](AVObject* obj) {
if (obj == object)
throw AVException("connectOutput: already connected");
}
);
_objects.push_back(object);
if (recursive)
object->connectInput(this, false);
}
void AVSplitter::disconnectOutput(AVObject *object, bool recursive)
{
bool found = false;
std::for_each(
_objects.begin(), _objects.end(),
[&](AVObject* obj) {
if (obj == object)
found = true;
}
);
if (!found)
throw AVException("disconnectOutput: programming error");
if (recursive)
object->disconnectInput(this, false);
}
void AVSplitter::setSamplerate(av_sample_rate_t sample_rate)
{
_sample_rate = sample_rate;
std::for_each(
_objects.begin(), _objects.end(),
[&](AVObject* obj) {
obj->setSamplerate(sample_rate);
}
);
}
void AVSplitter::setChannels(av_channels_t channels)
{
_channels = channels;
std::for_each(
_objects.begin(), _objects.end(),
[&](AVObject* obj) {
obj->setChannels(channels);
}
);
}