Here is my code for my 2 procedures. Much better now.
Nice. See, how that cleans up your code ?
Thanks to all especially TRon who put me on the right track.
Thank you, but it seems you are still having issues so perhaps I forgot something ?
I had to use Cmem only to free the name Hint.
afaik the hints are the only returns values that require this call. On the other hand I only have used the most common ALSA operations.
The last problem I have is that I use a progress bar driven by a timer to show/imitate the buffer filling. In windows and Mac the GUI does update. In Linux I have not found a way yet.
During the read, the interface is not updated, so the progress bar does not grow!
Strange.
Have you tried MarkMLI's suggestion of using a smaller capture buffer ? The only thing different would be that the buffer is smaller so you would have to read multiple buffers in case you wish to record/copy a larger amount of samples.
Because you update your progressbar using a timer, what happens if you place the processmessages in your timer event, after you've updated the progressbar (instead of doing so inside your read loop) ?
Possibly the non Blocking might do the trick, but so far I have not found a way to use it.
We're talking ALSA here, but also in general: that is a bit too broad statement
What have you tried and what were the result when your tried them ?
Does your code still locks-up if you set it to non-block ? or is it for example that your read loop is problematic ?
What you could also try is doing a latency test. ALSA comes accompanied with an example, see here
https://www.alsa-project.org/wiki/Test_latency.c (actual code is linked on that page).
If the latency test works for your hardware, then the issue is probably related to the code that you've tried. At least you would perhaps be able to get some inspiration from that code
To make sure, I repeat the warning about ALSA sometimes being finicky. If your code ever failed for whatever reason and handles/memory was not freed correctly then ALSA is able to throw in very strange error's (on successive runs) that make no sense (at least not to me) and can lead to confusion when you try to debug things. Reset often in such cases.