Skip to content

Commit bb63afa

Browse files
committed
Add guidance on what you should and shouldn't do inside the audio callback
1 parent 837a9b3 commit bb63afa

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

docs/FullGuide.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,22 @@ The callback does a non-blocking read from the input stream placing the data int
362362

363363
Note that in this example it is assumed the input and output streams have the same number of channels, format and sample rate. The format of the streams can be mismatched - as long as the code handles the translations properly.
364364

365+
#### Callback do's and don'ts
366+
These are things the `onAudioReady` method should NOT do:
367+
368+
- allocate memory using, for example, malloc() or new
369+
- any file operations such as opening, closing, reading or writing
370+
- any network operations such as streaming
371+
- use any mutexes or other synchronization primitives
372+
- sleep
373+
- stop or close the stream
374+
- Call read() or write() on the stream which invoked it
375+
376+
The following methods are OK to call:
377+
378+
- AudioStream::get*()
379+
- oboe::convertResultToText()
380+
365381
### Setting performance mode
366382

367383
Every AudioStream has a *performance mode* which has a large effect on your app's behavior. There are three modes:

0 commit comments

Comments
 (0)