integrating soundcard callbacks with libuv

29 views
Skip to first unread message

Jonah Fox

unread,
Jan 11, 2021, 6:37:11 AM1/11/21
to libuv
Hi I'm trying to capture audio (using portaudio) and send and receive UDP packets.

I'm trying to work out how to integrate with the libuv loop from the soundcard callback.

*If I send using libuv directly from the loop - it occasionally crashes (perhaps expected)
* I could write into a buffer and have a libuv timer process this - but I'd get wasted latency.
* perhaps I can write into a buffer and direct libuv to wake up. I did try using uv_async, but it seemed to be too slow. 

What is the correct thing to do here?

J

Ben Noordhuis

unread,
Jan 12, 2021, 6:40:57 AM1/12/21
to li...@googlegroups.com
Is your soundcard callback called on the same thread as libuv or a
different one? I assume it's a different one and in that case
uv_async_send() is the right thing to use.

You say it's too slow. What kind of latency do you see? How and when
do you call uv_run()? Do you have callbacks that take a while to
complete? A uv_async_t callback won't run until libuv gets the
opportunity to poll for new events.
Reply all
Reply to author
Forward
0 new messages