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 "node/sink_node.h"
18
19#include "base/logging.h"
20
21namespace vraudio {
22
23SinkNode::SinkNode() : Node() {}
24
25const std::vector<const AudioBuffer*>& SinkNode::ReadInputs() {
26 return input_stream_.Read();
27}
28
29void SinkNode::Connect(
30 const std::shared_ptr<PublisherNodeType>& publisher_node) {
31 input_stream_.Connect(node: publisher_node->GetSharedNodePtr(),
32 output: publisher_node->GetOutput());
33}
34
35void SinkNode::Process() {
36 LOG(FATAL) << "Process should not be called on audio sink node.";
37}
38
39bool SinkNode::CleanUp() {
40 // We need to make a copy of the OutputNodeMap map since it might change due
41 // to Disconnect() calls.
42 const auto connected_nodes = input_stream_.GetConnectedNodeOutputPairs();
43 for (const auto& input_node : connected_nodes) {
44 Output<const AudioBuffer*>* output = input_node.first;
45 std::shared_ptr<Node> node = input_node.second;
46 const bool is_orphaned = node->CleanUp();
47 if (is_orphaned) {
48 input_stream_.Disconnect(output);
49 }
50 }
51 return false;
52}
53
54} // namespace vraudio
55

source code of qtmultimedia/src/3rdparty/resonance-audio/resonance_audio/node/sink_node.cc