Blindfold,
I can get onMarkerReached() called for a STATIC AudioTrack instance. A
few things you might want to try:
- the marker position must be set in frames, not bytes. So make sure
you're not giving a marker position that's not beyond your content.
For instance if your content is stereo/8bit, you must divide the size
by two, by four for stereo/16bit, to go from data size to frame count.
- try setting a really low value for your marker position, like 10, to
see if it gets called.
- if all that still doesn't work, I'd start checking in which thread
the callback is supposed to be called. By default it's in the same
thread as the one in which you created your AudioTrack instance. If
you want it to be called from a different thread, use
setPlaybackPositionUpdateListener(listener, handler) where you pass
the handler of the thread you want to use.
Hope this helps.

On May 1, 3:37 am, blindfold <seeingwithso...@gmail.com> wrote:
> Should I file a bug report for Cupcake's onMarkerReached() 
> inAudioTrackplayback? The only workaround I currently have for
> onMarkerReached() never getting invoked is to explicitly poll
> getPlaybackHeadPosition(), while taking into account extra margins for
> sample rates 11025 and 22050 because there the getPlaybackHeadPosition
> () does not quite reach the expected end values - as described in my
> previous post.
>
> Regards
>
> On Apr 30, 10:02 pm, blindfold <seeingwithso...@gmail.com> wrote:
>
> > Has anybody had any success with OnPlaybackPositionUpdateListener? I'm
> > successfully playing one-second PCM sound clips withAudioTrackin
> > MODE_STATIC mode (although the playback often appears truncated), but
> > no matter what I do, onMarkerReached() is never called. I set
> > setNotificationMarkerPosition() to a position a bit less than my
> > sample count. I do not have any such problems with its MediaPlayer
> > counterpart setOnCompletionListener(). I simply want onMarkerReached()
> > to run when myAudioTrackinstance has finished playing, but the
> > getPlayState() remains PLAYSTATE_PLAYING after myAudioTrackhas
> > finished sounding. What might be wrong? What does it take to get
> >AudioTrackto run onMarkerReached() at the end of the data? Any
> > concrete sample code for this that works?
>
> > Another strange thing is that at the end of a one second sound at
> > sample rate 16000, getPlaybackHeadPosition() returns 16000 as
> > expected, but for a sample rate of 22050 getPlaybackHeadPosition()
> > becomes consistently 22016, for a sample rate of 11025
> > getPlaybackHeadPosition() becomes 11008, while for a sample rate of
> > 8000 the getPlaybackHeadPosition() returns consistently 8000 again.
> > Are the discrepancies for sample rates of 11025 and 22050 due to
> > rounding inaccuracies in theAudioTracksample rate divider?
>
> > Thanks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to