OK, thanks Jean-Michel. Having at least an "existence proof" that
onMarkerReached() can work will make me look at it again, although I
do not yet see anything that I have overlooked. In case there is some
buffering/startup issue with AudioTrack: what is the duration of your
sounds? In my case it is by default only one second. I'm aware that I
must look at sample ("frame") counts, not byte counts, but even
setting the marker at a third of my sample count did not work for me,
but I'll try an even more extreme (and useless) case like setting it
at 10 samples. I use 8 bit mono PCM by default, so there byte count
(minus header) even matches the sample count. My callback is actually
created and specified within the setPlaybackPositionUpdateListener
definition, right after creating an AudioTrack, so it is definitely in
the same thread, and the fact that it is all wrapped inside a factory
method ought not to matter like it certainly does not matter for
MediaPlayer. Strange. I'll experiment some more. Thanks for your help.

Regards

On May 1, 6:43 pm, Jean-Michel <[email protected]> wrote:
> Blindfold,
> I can get onMarkerReached() called for a STATICAudioTrackinstance. 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 yourAudioTrackinstance. 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 <[email protected]> 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 <[email protected]> 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 [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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to