Celina Val
2018-07-12 03:26:53 UTC
Hi,
I've been implementing an audio player using Android OpenSL ES API with a
buffer queue, but I'm having trouble keeping track of the playback
position. I've tried the following:
- Use GetPosition() method from SLPlayItf: This approach is not reliable
because the position seems to be reset every time there's a buffer
underrun. See this old question
<https://groups.google.com/forum/#!topic/android-ndk/Ez5_nvAmhE8> for
more details. Is this a bug? The original question is from 2011, so my
guess is that it won't get fixed so soon.
- Register a callback with SLPlayItf: This approach works well for the
first track I play. However, it won't work again after I stop the player
and try to play from a different source. This is what I'm doing:
1. Set audio player to PLAYING state.
2. Wait till the audio is being played and the playback position
starts getting updated.
3. Set audio player to STOPPED state.
4. Clear the buffer queue.
5. Set the state to PLAYING.
6. Audio starts playing again, but the playback position never gets
updated (i.e., the callback function is never called again).
- I've tried to re-register the callback between step #4 and #5, and I
also tried to set the event mask to 0 and back to the initial
value, but no
luck so far, Am I missing something? Do I always need to
recreate the audio
player when I want to restart the audio?
Thanks,
Celina
I've been implementing an audio player using Android OpenSL ES API with a
buffer queue, but I'm having trouble keeping track of the playback
position. I've tried the following:
- Use GetPosition() method from SLPlayItf: This approach is not reliable
because the position seems to be reset every time there's a buffer
underrun. See this old question
<https://groups.google.com/forum/#!topic/android-ndk/Ez5_nvAmhE8> for
more details. Is this a bug? The original question is from 2011, so my
guess is that it won't get fixed so soon.
- Register a callback with SLPlayItf: This approach works well for the
first track I play. However, it won't work again after I stop the player
and try to play from a different source. This is what I'm doing:
1. Set audio player to PLAYING state.
2. Wait till the audio is being played and the playback position
starts getting updated.
3. Set audio player to STOPPED state.
4. Clear the buffer queue.
5. Set the state to PLAYING.
6. Audio starts playing again, but the playback position never gets
updated (i.e., the callback function is never called again).
- I've tried to re-register the callback between step #4 and #5, and I
also tried to set the event mask to 0 and back to the initial
value, but no
luck so far, Am I missing something? Do I always need to
recreate the audio
player when I want to restart the audio?
Thanks,
Celina
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAOsb_O%3DAj2qoHC%2BtLW0%3Dz%3D46NJAoQnzod3EAksKJwCBQXLprXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAOsb_O%3DAj2qoHC%2BtLW0%3Dz%3D46NJAoQnzod3EAksKJwCBQXLprXA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.