Reputation: 49
Do I need to worry about syncing issues when working with multiple threads?
I'm programming a code which calculates the latency between separate microphone channels and outputs several .wav files with the latency compensated.
Here is my current brute-force method:
My current method (number 2) works if the total recording session is short since the size of the static buffers is limited. I was feeling unsure whether the recorded data were going to be in sync or not if I accessed the recorded data every time they are available.
Possible solutions:
Store them in a circular buffer. Implement a counter for each thread and increment whenever new data is available. This gives me the ability to track any possible sync issues.
Don't worry about the issue because they are nonexistent?
Other possible, more efficient methods that I'm unaware of?
Upvotes: 1
Views: 100
Reputation: 571
The data you are receiving is generally equidistantly spaced and I don't see any interoperation between your threads - so computation-wise you should be good: However, in my experiences NAudio likes to drop frames if your WaveIn callback is not processed right away. This can certainly get you out of sync.
Upvotes: 1