MCPcopy Create free account
hub / github.com/LabSound/LabSound / AudioHardwareDeviceNode

Method AudioHardwareDeviceNode

src/core/AudioHardwareDeviceNode.cpp:34–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34AudioHardwareDeviceNode::AudioHardwareDeviceNode(AudioContext & context,
35 const AudioStreamConfig & outputConfig,
36 const AudioStreamConfig & inputConfig)
37 : AudioNode(context, *desc())
38 , m_context(&context)
39 , outConfig(outputConfig)
40 , inConfig(inputConfig)
41{
42 // Ensure that input and output sample rates match
43 if (inputConfig.device_index != -1 && outputConfig.device_index != -1)
44 {
45 ASSERT(outputConfig.desired_samplerate == inputConfig.desired_samplerate);
46 }
47
48 m_platformAudioDevice = std::unique_ptr<AudioDevice>(AudioDevice::MakePlatformSpecificDevice(*this, outputConfig, inputConfig));
49
50 LOG_INFO("MakePlatformSpecificDevice() \n"
51 "\t* Sample Rate: %f \n"
52 "\t* Input Channels: %i \n"
53 "\t* Output Channels: %i ",
54 outputConfig.desired_samplerate, inputConfig.desired_channels, outputConfig.desired_channels);
55
56 if (inputConfig.device_index != -1)
57 {
58 m_audioHardwareInput = new AudioHardwareInput(inputConfig.desired_channels);
59 }
60
61 // This is the "final node" in the chain. It will pull on all others from this input.
62 addInput(std::make_unique<AudioNodeInput>(this));
63
64 // Node-specific default mixing rules.
65 //m_channelCount = outputConfig.desired_channels;
66 m_channelCountMode = ChannelCountMode::Explicit;
67 m_channelInterpretation = ChannelInterpretation::Speakers;
68
69 ContextGraphLock glock(&context, "AudioHardwareDeviceNode");
70 AudioNode::setChannelCount(glock, outputConfig.desired_channels);
71
72 // Info is provided by the backend every frame, but some nodes need to be constructed
73 // with a valid sample rate before the first frame so we make our best guess here
74 last_info = {};
75 last_info.sampling_rate = outputConfig.desired_samplerate;
76
77 initialize();
78}
79
80AudioHardwareDeviceNode::~AudioHardwareDeviceNode()
81{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected