Android Question Using AudioStreamer

canalrun

Well-Known Member
Licensed User
Longtime User
I'm revisiting an app that I wrote several years ago

It uses the AudioStreamer object.

I generate a continuous waveform (sine wave) of unknown duration (it could be 5 seconds or many hours) and output this using StartPlaying and Write.

I don't use the record function at all.

I cannot write the entire buffer at once so I plan to Write single bytes at a time and check return value for false to find when the PlayBuffer is full, wait a little bit then write bytes until the buffer is full again, repeat.

Is this a good strategy for keeping the buffer full of data?

The second question occurs if the user requests to stop. If I call StopPlaying does this clear the PlayBuffer of any left over data so that if I call StartPlaying again later it will start with fresh data?

Thanks,
Barry.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Check this code: https://www.b4x.com/android/forum/threads/audio-library-beeper-duration.78712/#post-498840

If I call StopPlaying does this clear the PlayBuffer of any left over data so that if I call StartPlaying again later it will start with fresh data?
Yes. A new buffer is created each time.

I don't think that you should rely on the queue state. You can run out of available memory before it will be full.
Use a timer and add the next x seconds each time (plus a few milliseconds to compensate for inaccuracies).
 
Upvote 0
Top