servo_media_audio/
destination_node.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use crate::block::Chunk;
6use crate::node::{AudioNodeEngine, AudioNodeType, BlockInfo, ChannelCountMode, ChannelInfo};
7
8#[derive(AudioNodeCommon)]
9pub(crate) struct DestinationNode {
10    channel_info: ChannelInfo,
11    chunk: Option<Chunk>,
12}
13
14impl DestinationNode {
15    pub fn new(channel_count: u8) -> Self {
16        DestinationNode {
17            channel_info: ChannelInfo {
18                mode: ChannelCountMode::Explicit,
19                count: channel_count,
20                ..Default::default()
21            },
22            chunk: None,
23        }
24    }
25}
26
27impl AudioNodeEngine for DestinationNode {
28    fn node_type(&self) -> AudioNodeType {
29        AudioNodeType::DestinationNode
30    }
31
32    fn process(&mut self, inputs: Chunk, _: &BlockInfo) -> Chunk {
33        self.chunk = Some(inputs);
34        Chunk::default()
35    }
36
37    fn destination_data(&mut self) -> Option<Chunk> {
38        self.chunk.take()
39    }
40
41    fn output_count(&self) -> u32 {
42        0
43    }
44}