During the time between the moment where you return false and the moment where the capture is actually stopped, there are still samples being captured, which are passed to
onProcessSamples() again. But I agree that it would be more intuitive if returning false would result in an immediate stop, also because
the documentation says returning false stops the capture.
The fix would be easy, I have to make sure that OpenAL doesn't require the sample buffer to be processed before cleaning up. Reading the
OpenAL specification, it says
If the application doesn't need to capture more audio for an amount of time, they can halt the device without closing it via the alcCaptureStop entry point:
void alcCaptureStop(ALCdevice *device);
The implementation is encouraged to optimize for this case. The amount of audio samples available after restarting a stopped capture device is reset to zero. The application does not need to stop the capture device to read from it.
So it should be fine if the samples are discarded.
By the way, please use the embedded [code=cpp] [/code] tags for such short example codes.