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
use block::Chunk;
use node::{AudioNodeEngine, BlockInfo};
use node::{AudioNodeType, ChannelCountMode, ChannelInfo};

#[derive(AudioNodeCommon)]
pub(crate) struct DestinationNode {
    channel_info: ChannelInfo,
    chunk: Option<Chunk>,
}

impl DestinationNode {
    pub fn new(channel_count: u8) -> Self {
        DestinationNode {
            channel_info: ChannelInfo {
                mode: ChannelCountMode::Explicit,
                count: channel_count,
                ..Default::default()
            },
            chunk: None,
        }
    }
}

impl AudioNodeEngine for DestinationNode {
    fn node_type(&self) -> AudioNodeType {
        AudioNodeType::DestinationNode
    }

    fn process(&mut self, inputs: Chunk, _: &BlockInfo) -> Chunk {
        self.chunk = Some(inputs);
        Chunk::default()
    }

    fn destination_data(&mut self) -> Option<Chunk> {
        self.chunk.take()
    }

    fn output_count(&self) -> u32 {
        0
    }
}