Can a stream which is not "Started" call onAudioReady? #1226
-
I have a small question. If a stream is not in the state of "Started", can it call onAudioReady callback? More specifically, should I check like below,
Before any IO operation? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You will not get an onAudioReady callback before you call stream->requestStart().
What kind of IO operation? You do not need to write the stream. Just fill the buffer in onAudioReady(). |
Beta Was this translation helpful? Give feedback.
-
Note that the audio callbacks are real-time threads. So you should not be doing any blocking operations. This include:
You should open a stream without a callback, PerformanceMode::None. Or, if you need a low latency callback, read or write a large FIFO and then have a background thread that writes or reads the FIFO and does the file I/O. |
Beta Was this translation helpful? Give feedback.
You will not get an onAudioReady callback before you call stream->requestStart().
After requestStart() the stream will be in state Starting state then it will transition to Started state.
A callback can occur any time after requestStart().
It is possible for a callback to still be running after calling requestStop() because that is an asynchronous request.
What kind of IO operation? You do not need to write the stream. Just fill the buffer in onAudioReady().
Generally you do not need to check the state. That is mostly for debugging.