AudioDriverKit IOUserAudioIOOperationWriteEnd avoid for input loopback

Dear Sirs,

I've written an audio driver based on AudioDriverKit.

In my audio callback function I'm receiving calls with io operation IOUserAudioIOOperationWriteEnd and IOUserAudioIOOperationBeginRead as expected which means I see IOUserAudioIOOperationWriteEnd operations during a playback in an application like VLC or the browser and I see IOUserAudioIOOperationBeginRead when recording in Audacity etc..

But when I open the SystemSettings and goto Sound and I select my driver as input I also see calls with IOUserAudioIOOperationWriteEnd which seem to be the just read input data. I can also watch this when starting up Teams. I think the purpose is to add the (mic) input also to the output so you have the chance to listen to yourself.

Nevertheless I'd like to fully avoid this but I don't see a way to distinguish between the playback audio data and the input audio data inside this callback. How could I do this?

Or even better is there a switch which would completely switch off these callbacks which forward the input to the output?

Thanks and best regards, Johannes

Replies

P.S.: This happens when I have my audio device selected as the default playback device.

In addition I just noticed that there seems to be a little step back back in the audio from the playback application at the moment my device is selected as input device in the SystemSettings.So a small part of the audio (est. 0.3 secs) from the playing application is transferred twice while the same amount of audio is skipped when I switch back to a different audio device as input device. Looking at the in_sample_time of the audio callback with io operation IOUserAudioIOOperationWriteEnd this seems to increase just steadily and according to the previous callbacks for my playback audio data. So I cannot see any jump backward or forward in the in_sample_time.