Skip to content

Make microphone polling interval configurable#877

Open
watsaig wants to merge 1 commit intoRustAudio:masterfrom
watsaig:feat/adjust-mic-polling-interval
Open

Make microphone polling interval configurable#877
watsaig wants to merge 1 commit intoRustAudio:masterfrom
watsaig:feat/adjust-mic-polling-interval

Conversation

@watsaig
Copy link
Copy Markdown

@watsaig watsaig commented Apr 24, 2026

The microphone functionality added recently is very useful but for some use cases, the hard-coded 5ms poll interval is a limitation.

This makes the interval configurable, as suggested by @roderickvd in the original PR.

@roderickvd
Copy link
Copy Markdown
Member

Thanks. If memory serves me well, then in #799 we even moved to a Condvar-based approach, removing the poll interval altogether. Would you port that from there to here?

@yara-blue
Copy link
Copy Markdown
Member

yara-blue commented Apr 25, 2026

If memory serves me well, then in #799 we even moved to a Condvar-based approach

Oh hey, apologies I dropped the ball there, we should have landed that!

Would you port that from there to here?

@watsaig if you could help out there that would be super nice :)

@yara-blue
Copy link
Copy Markdown
Member

Regarding this PR: as far as I know there are two big latency sources for a VoIP like application:

  • OS input buffer size (configurable through CPAL and should be exposed on the builder)
  • The polling interval seen above

Switching to the condvar should remove the polling latency entirely. I would also be open to other implementations.

The reason we have the polling interval is to convert from OS callbacks pushing samples to OS callbacks pulling samples:

Microphone 
  ----- Analog cable -----> DAC
  ----- Kernel polling/interrupts -----> OS audio buffer
  ----- Kernel calling on "non empty" buffer ----> Rodio microphone callback (via CPAL)
  
  
  Rodio callback <----- kernel calling on "non full" buffer ----
  OS audio buffer <----- kernel pollling/interrupst ------------ 
  ADC <--------------------analog cable-------------------------
  Speaker

So we have a thread to "reverse the flow" at the microphone side, to go from the
kernel pushing things into it to Rodio's iterator like architecture where
(eventually) the ADC pulls samples in.

I did the initial microphone design mostly to get the feature landed. It might
very well not be optimal.

For example maybe we could do without the thread. If you want to feel free to
give it a thought. Could we use shared memory here instead?

@watsaig
Copy link
Copy Markdown
Author

watsaig commented Apr 25, 2026

Thanks for the feedback! I'll take a deeper dive and see if the condvar approach works best or if we can do without the thread as you mentioned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants