Jeffrey Bakker
May 22, 2022

--

There are many examples with C-APIs which require data preparation to call one function. I can't share any of my employer's code, but here are a couple of public examples similar to what I've worked on...

Look at the first method "DeviceHasBuffersInScope" in the first answer of this post:

https://stackoverflow.com/questions/4575408/audioobjectgetpropertydata-to-get-a-list-of-input-devices

This is basically "one" API call to get some data on an audio device. However, you need to call another function to get the parameter for the size of the data you're asking for. Removing blank lines would make it too dense; I find separation helps. Separating this into multiple functions would be pointless.

A similar API call, this "GetAudioDeviceInfo" function is already very sparing on the blank lines:

https://chromium.googlesource.com/chromium/src/media/+/7479f0acde23267d810b8e58c07b342719d9a923/audio/mac/audio_manager_mac.cc#68

I don't know how much value you'd get from refactoring this.

--

--

Jeffrey Bakker
Jeffrey Bakker

Written by Jeffrey Bakker

Professional geek. Wannabe cyclist.

No responses yet