First of all thanks for the feedback! I am glad to see that the code is getting some attention!
Think this should also include some kind of error handling[...]
Like Laurent said the code outputs an error message and does not start recording if you pass a wrong name to the
setAudioCaptureDevice method. But while testing wrong names I noticed a "bug" that confused me and made me think it's left in a broken state. I used
sf::SoundBufferRecorder for testing and if you try to save a completely empty buffer you get an error message saying "Format not recognised" which is confusing and not very discribtiv in this case. But this has nothing to do with
sf::SoundRecorder it's an error in
sf::SoundBuffer. This should be discussed in a seperate thread.
As of for this class, it should handle wrong input in a clean way.
[...]you should call start() and stop() inside of setAudioCaptureDevice[...]
I decided not to call
start() and
stop(), because it makes it impossible to change of the device while recording. In
start() m_samples.clear(); is called and the call to
onStart() does the same thing to derived classes (for example in
sf::SoundBufferRecorder onStart() clears the buffer too). The way I see it
setAudioCaptureDevice() doesn't stop and (re)start the recording. It simply changes the device. The user shouldn't worry about losing samples, because he changed the device.
Before you pointed it out I didn't even noticed that
onStop() is called! Of course this is a bug. But now that I look at it I am asking myself why is
onStop() being called in the
record() method anyway? It should be called in
stop() after
m_thread.wait();. That would also fix this problem.
I know that this means a little code duplication, but as I explained the code works a little different and I think the functionality overweights.
You are definitly right about the method names. They are way to long! I'm terrible at finding names... I'll change that later.