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

Method process

src/core/AudioHardwareInputNode.cpp:40–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void AudioHardwareInputNode::process(ContextRenderLock &r, int bufferSize)
41{
42 AudioBus * outputBus = output(0)->bus(r);
43
44 // This used to be the function of a manual call to setFormat()
45 if (m_sourceNumberOfChannels == 0)
46 {
47 auto DeviceAsAudioNode = r.context()->device();
48
49 if (auto DeviceAsRenderCallback = std::dynamic_pointer_cast<AudioDeviceRenderCallback>(DeviceAsAudioNode))
50 {
51 auto inputConfig = DeviceAsRenderCallback->getInputConfig();
52 m_sourceNumberOfChannels = inputConfig.desired_channels;
53 output(0)->setNumberOfChannels(r, m_sourceNumberOfChannels); // Reconfigure the output's number of channels.
54 outputBus = output(0)->bus(r); // outputBus pointer was invalidated
55 }
56 }
57
58 if (!m_audioSourceProvider)
59 {
60 outputBus->zero();
61 return;
62 }
63
64 if (m_sourceNumberOfChannels != outputBus->numberOfChannels())
65 {
66 outputBus->zero();
67 return;
68 }
69
70 // Use a tryLock() to avoid contention in the real-time audio thread.
71 // If we fail to acquire the lock then the MediaStream must be in the middle of
72 // a format change, so we output silence in this case.
73 if (r.context())
74 {
75 // provide entire buffer
76 m_audioSourceProvider->provideInput(outputBus, bufferSize);
77 }
78 else
79 {
80 // We failed to acquire the lock.
81 outputBus->zero();
82 }
83}
84
85void AudioHardwareInputNode::reset(ContextRenderLock & r)
86{

Callers

nothing calls this directly

Calls 7

deviceMethod · 0.80
provideInputMethod · 0.80
busMethod · 0.45
contextMethod · 0.45
setNumberOfChannelsMethod · 0.45
zeroMethod · 0.45
numberOfChannelsMethod · 0.45

Tested by

no test coverage detected