I assume we're talking native code and not Java since you used "::" instead of ".".
For AudioTrack, you have 2 options: Option 1 Write: Call start(). Keep calling write() until you have written all the audio you want to play. The write() calls will block your thread until the mixer engine needs more audio. You probably want this to run on its own thread so that it doesn't block your main thread. Option 2 Callback: Create an audio track with a callback. Call start(). Your callback will be called several times in succession to pre-fill buffers. After that, you will get callbacks roughly at the buffer fill rate (about 20 msecs). When done, return a zero in the callback (I think - can't remember for sure). Please bear in mind that you are using an unpublished interface (meaning that we have not made them part of the SDK). We have made significant changes to AudioTrack in Cupcake and your application will break. On Feb 26, 5:58 am, Nikhil <[email protected]> wrote: > But what i understand is that audio is played only when > AudioTrack::start() is called. In such a case we should wait for the > audio to complete playing the sound buffer. Please let me know if my > understanding is correct. > > On Feb 25, 9:51 pm, Marco Nelissen <[email protected]> wrote: > > > On Wed, Feb 25, 2009 at 5:00 AM, Nikhil <[email protected]> wrote: > > > > Hi All, > > > > I am trying to play sound buffer for streaming sound(PCM sound data) > > > through a library in Android framework. > > > > I am trying by using AudioTrack::write() for passing sound buffer to > > > Audio Flinger and AudioTrack::start() function for playing that sound. > > > But it's required to get a callback once each buffer is played before > > > sending the next buffer for playing. > > > > Can anyone help me to know if there is anyway to get a callback from > > > AudioTrack once the playback of given buffer is completed? > > > AudioTrack::write blocks until the data has been consumed by the audio > > engine, so as soon as write() returns, you can write more data. > > > > or is there any other way to play PCM data in Android? > > > No. Also note that AudioTrack is a Cupcake API, so your app won't work > > on most people's device currently. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "android-framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~----------~----~----~----~------~----~------~--~---
