1/*
2Copyright 2018 Google Inc. All Rights Reserved.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS-IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#include "graph/mixer_node.h"
18
19
20
21namespace vraudio {
22
23MixerNode::MixerNode(const SystemSettings& system_settings, size_t num_channels)
24 : num_channels_(num_channels),
25 mixer_(num_channels_, system_settings.GetFramesPerBuffer()) {
26 DCHECK_NE(num_channels_, 0U);
27 EnableProcessOnEmptyInput(enable: true);
28}
29
30const AudioBuffer* MixerNode::GetOutputBuffer() const {
31 return mixer_.GetOutput();
32}
33
34bool MixerNode::CleanUp() {
35 CallCleanUpOnInputNodes();
36 // Prevent node from being disconnected when all sources are removed.
37 return false;
38}
39
40const AudioBuffer* MixerNode::AudioProcess(const NodeInput& input) {
41
42
43 mixer_.Reset();
44
45 const auto& input_buffers = input.GetInputBuffers();
46 if (input_buffers.empty()) {
47 return nullptr;
48 }
49
50 for (auto input_buffer : input_buffers) {
51 DCHECK_EQ(input_buffer->num_channels(), num_channels_);
52 mixer_.AddInput(input: *input_buffer);
53 }
54 return mixer_.GetOutput();
55}
56
57} // namespace vraudio
58

source code of qtmultimedia/src/3rdparty/resonance-audio/resonance_audio/graph/mixer_node.cc