Skip to content

Record audio generate by my app, not the mic #1258

Answered by philburk
paulorrfilho asked this question in Q&A
Discussion options

You must be logged in to vote

If you want capture the output of your app then this may work.

Create an atomic FifoBuffer using the internal FIFO tool from Oboe.
https://github.com/google/oboe/blob/master/src/fifo/FifoBuffer.h
Make it fairly large, like a half second worth of data.

uint32_t capacity = sampleRate / 2;
FifoBuffer *fifo = new FifoBuffer(stream->getBytesPerFrame(), capacity);

Launch a thread that will periodically, maybe every 50 msec, will wake up and
read() from the FIFO and write the data to a file.
The fifo->read() method will return the number of frames actually read.

Then in your callback, write() a copy of your audio data to the FIFO.

It is important that the file is written in a separate thread, no…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@paulorrfilho
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by philburk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants