On Tue, 16 Jun 2020, Giuliano Pochini wrote:
On Tue, 16 Jun 2020 14:17:43 +0100 Mark Hills mark@xwax.org wrote:
Distorted audio appears occasionally, affecting either playback or capture and requiring the affected substream to be closed by all applications and re-opened.
Yes, it also happens here very rarely (one time every some months) and I failed to reproduce the problem.
It frustrated me for years, but I had other work I needed to do. Eventually I was working around it several times a day :-/
[...]
Check for progress using the counter from the hardware, not after it has been truncated to the buffer.
There appears to be a possible bug if a whole ringbuffer advances between interrupts, it goes unnoticed.
In that case the stream must be restarted anyway due to xrun.
Yes, but I think it will go unnoticed, so you don't know to re-start.
[...]
- Remove the accessing of pipe->dma_counter twice in the interrupt handler:
Why twice?
Yes, the interrupt handler calls pcm_pointer() directly to make a decision. Then it calls snd_pcm_period_elapsed(), which itself goes on to make another call to pcm_pointer(), by this time the bus mastering of the interface has adjusted the counter.
The new code processes the counter only once, and this is easier to rationalise whether there are bugs.