Open RightFS opened 8 months ago
Do you mean you just don't want to block if there is no data? In that case, just check for the buffer fill level with Pa_GetStreamReadAvailable
before you call Pa_ReadStream
and only read as much data as is available.
For echo cancellation (or full-duplex IO in general) I would be inclined to use the callback API as it will typically have more deterministic latency.
Do you mean you just don't want to block if there is no data? In that case, just check for the buffer fill level with
Pa_GetStreamReadAvailable
before you callPa_ReadStream
and only read as much data as is available.For echo cancellation (or full-duplex IO in general) I would be inclined to use the callback API as it will typically have more deterministic latency.
The problem in my case is reading from a loopback input will never return if there no sound is playing. same problem in callback mode, no sound playing, no callback calling
The problem in my case is reading from a loopback input will never return if there no sound is playing. same problem in callback mode, no sound playing, no callback calling
The behavior that you describe ("never return if there no sound is playing" or "no sound playing, no callback calling") won't happen. If there is no source available either
Neither blocking read nor callback is gated on "sound playing".
situation: I need capture the audio output (loopback) to do some echo cancellation. The timing requirements are very strict, if I use the callback to capture I need to do some addtional synchronizations. But If I use the blocking API, It will not return when no sound is palying...
I think we can return a muted buffer after the
wait time
.example: require to fill a 8 samples buffer on a 48000/16/2 stream, just wait for 4/48000ms then fill 0 to the buffer and return it, if there are some sound in the middle of buffer, the buffer should be 00001110
I want to record a continuous audio stream, if no sound just return muted buffer instead of blocking.
The current situation: time 12345678 buff 345
What I want: time 12345678 buff 00045600