ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

IllegalStateException: buffer is inaccessible

Open mkovalyk opened this issue 10 years ago • 3 comments

Hi, I have found the issue [https://github.com/google/ExoPlayer/issues/729], but in my case malformed stream is not the reason. I have faced the issue while trying to get DirectByteBuffer on Nexus 5X Android 7.0 (sampleHolder.data.duplicate()) and get error buffer is inaccessible. Same stream works correctly on Samsung S6 and J7 with Android 6.0.1. Please advice on this issue.

mkovalyk avatar Sep 23 '16 11:09 mkovalyk

Please provide all of the information requested in the issue template, otherwise we don't have enough data to help. Thanks!

ojw28 avatar Sep 26 '16 08:09 ojw28

@ojw28 Thanks for reply. While preparing sample to reproduce problem on Demo app, I figured out what the problem was... Multithreading. So I was trying to get access to ByteBuffer from another thread. In API < 24 it worked correctly, but for API 24 it was changed and is not allowed anymore (most likely).

mkovalyk avatar Sep 26 '16 16:09 mkovalyk

Hi @mkovalyk could you post your solution to solve this type of error?

I have a queue (ArrayList<ArrayDeque>) where audio & video encoding threads add their respective data for the streamer thread that grabs it and sends it. Here is how I add the data:

ByteBuffer muxerInput; synchronized (mMuxerInputQueue) { muxerInput = mMuxerInputQueue.get(trackIndex).isEmpty() ? ByteBuffer.allocateDirect(encodedData.capacity()) : mMuxerInputQueue.get(trackIndex).remove(); muxerInput.put(encodedData); muxerInput.position(0); }

The error is in the line: muxerInput.put - muxerInput buffer is inaccessible

Any help please?

Thanks.

xdeop avatar May 02 '17 11:05 xdeop