Hi! I am making a voice chat application for macOS and having hard times getting echo cancellation to work.
I've made an audio unit graph with the following structure:
┌─────────────┐ ┌──────────────┐ ┌───────────────────────┐
│ │ │ │ │ │
│ My Render │ 48000 kHz │ Resampler │ 44100 kHz │ Voice Processing IO │
│ Callback │──────────────▶│ Node │──────────────▶│ Node │
│ │ │ │ │ │
└─────────────┘ └──────────────┘ └───────────────────────┘
The code is available on GitHub Gist (250 lines):
https://gist.github.com/konstantinpavlikhin/d08f98b14328baa5eddbdf98d0ab8b91
I receive samples in -[XXXSpeakerDevice myStreamFormat] format from the network. VPIO seems to like 44100 kHz, that's why I added a resampler node (otherwise I've got errors on initialization). The problem is that this thing doesn't work at all. I've carefully checked return code of every function call and there are no errors at all. Yet my render callback doesn't get called.
The CAShow() prints the following:
[aqme] 254: AQDefaultOutput (1): skipping input stream 0 0 0x0
AudioUnitGraph 0x1299086:
Member Nodes:
node 1: 'aufc' 'conv' 'appl', instance 0x81299087 O I
node 2: 'auou' 'vpio' 'appl', instance 0x81299088 O I
Connections:
node 1 bus 0 => node 2 bus 0 [ 1 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
Input Callbacks:
{0x1001e0c00, 0x608000437000} => node 1 bus 0 [1 ch, 48000 Hz]
CurrentState:
mLastUpdateError=0, eventsToProcess=F, isInitialized=T, isRunning=T (1)
And I also get this:
[vp] 17: >vp> SERIOUS AUDIO STREAM CORRUPTION ERROR DETECTED IN kVPSignalIndex_DlFev : stream has been all zeros for 10.00 seconds!!
When I change kAudioUnitSubType_VoiceProcessingIO to kAudioUnitSubType_HALOutput everything works, but obviosly without echo cancellation.
I would greatly appreciate any help on this problem!