Hi,
There have been lots of discussions here about how to decode sound asset files using an fd source and buffer queue sink to extract the PCM data. You just enqueue an empty buffer, register a callback and set the player's status to playing. The callback will be called with decoded data where you re-enqueue the buffer to get the next chunk and so on. There has been no talk about the last cycle.
1) Each time the callback is called, how do you know if there is still more data to be decoded? How can the callback decide if it should re-enqueue the buffer or signal another thread decoding is done?
2) In the last iteration where the callback is invoked, how will it know how much of the buffer is filled with decoded data? In all invocations (except the last) the buffer will be full (i.e., the size you pass to Enqueue). In the last iteration the buffer may be half full. How to know how much of it is full with decoded data?
The bigger picture of what I generally trying to do is this. I want to decode a bunch of sound effect files at load time into buffers, then at run time when I need the sound effects played, play them as decoded buffers from memory without having to load from assets which are encoded.
Help? Thoughts? Hints?
Thanks