i have example working decoding mp3 audio mediacodec playing using mediaplayer , audiotrack. example using getinputbuffers() depricated in api 21+. new getinputbuffer(int index) returns 1 buffer instead of array , api reference mediacodec still shows use case getinputbuffers().
can explain how need go using new method? index 0 each time? started loop , each , make array there isn't place, have seen, can length of available buffers.
you shouldn't try fetch buffers.
prior api 21, you'd bytebuffer inputs[] = codec.getinputbuffers(). index = codec.dequeueinputbuffer() return buffer index, , you'd use inputs[index], , submit buffer codec.queueinputbuffer(index, ...).
notice never touch more 1 element in inputs[] @ time, , you're allowed touched between dequeueinputbuffer , queueinputbuffer calls.
now instead of having array of bytebuffer objects, allowed touch 1 @ time, you're supposed fetch single bytebuffer going fill. is, after index = codec.dequeueinputbuffer(), instead of using inputs[index], call codec.getinputbuffer(index).
so basically, array used returned getinputbuffers() still exists internally within mediacodec object, don't need keep full array available, fetch single buffer you're going touch each time.
Comments
Post a Comment