jarikomppa / soloud

Free, easy, portable audio engine for games
http://soloud-audio.com
Other
1.8k stars 284 forks source link

portaudio support improvements #26

Closed jarikomppa closed 6 years ago

jarikomppa commented 11 years ago

We're doing plenty of stuff in the portaudio callback that portaudio documentation directly forbids, including file i/o and memory allocations.

A better way would probably be to run a separate thread that performs those calculations in advance, and gets triggered by the portaudio callback whenever we've run out of ready material.

Negative side effect from this is increased latency, and things seem to work fine..

vk2gpu commented 9 years ago

Just scanning through bugs and spotted this. It's good practice to never do file i/o or memory allocation on an audio callback as you can't reason about how long those will take and I'd consider filling an audio buffer pretty time critical :) Possibly should be moving all that stuff out of the mixing thread in general across the board, not just for portaudio? There shouldn't be any increase in latency from doing that unless file io falls behind, which would just cause stuttering anyway.

jarikomppa commented 9 years ago

Yes.

On Wed, May 13, 2015 at 6:51 AM, Neil Richardson notifications@github.com wrote:

Just scanning through bugs and spotted this. It's good practice to never do file i/o or memory allocation on an audio callback as you can't reason about how long those will take and I'd consider filling an audio buffer pretty time critical :) Possibly should be moving all that stuff out of the mixing thread in general across the board, not just for portaudio? There shouldn't be any increase in latency from doing that unless file io falls behind, which would just cause stuttering anyway.

— Reply to this email directly or view it on GitHub https://github.com/jarikomppa/soloud/issues/26#issuecomment-101505380.

jarikomppa commented 6 years ago

I'll close this because it's a more generic issue, and there's #107 for it.