q-p / SoundPusher

Virtual audio device, real-time encoder and SPDIF forwarder for macOS
MIT License
153 stars 15 forks source link

gPlugIn_StateMutex vs. gDevice.Mutex in LoopbackAudio.c #5

Closed glaurent closed 6 years ago

glaurent commented 6 years ago

It seems you've moved many of the device-related variables into a Device struct, including the Mutex (gDevice.Mutex). However, the "old" gPlugIn_StateMutex is still there too, and still used in some of the functions, like LoopbackAudio_QueryInterface and LoopbackAudio_AddRef. Is this on purpose, or is it an oversight ?

q-p commented 6 years ago

It's on purpose: They're protecting different resources. One is for the plug-in itself, the other (inside the device struct) is specific to that device.

This only makes a marginal amount of sense at the moment where there can only be a single device, but still seemed like a sensible way to do it, in case I ever want to support multiple loopback devices, for example.

glaurent commented 6 years ago

Thanks, I understand why now.