Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalStateException at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method) #10

Open
ToysoftInc opened this issue Nov 18, 2016 · 9 comments

Comments

@ToysoftInc
Copy link

When doing a recording on the Samsung S4 with OS5.0.1. I got this crash log

11-18 07:53:25.045 18723-20104/com.serenegiant.audiovideosample E/ACodec: signalError(omxError 0x80001009, internalError -2147483648)
11-18 07:53:25.055 18723-20103/com.serenegiant.audiovideosample E/MediaCodec: Codec reported err 0x80001009, actionCode 0, while in state 6
11-18 07:53:25.055 18723-20093/com.serenegiant.audiovideosample E/AndroidRuntime: FATAL EXCEPTION: MediaVideoEncoder
java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:1033)
at com.serenegiant.audiovideosample.encoder.MediaEncoder.drain(MediaEncoder.java:301)
at com.serenegiant.audiovideosample.encoder.MediaEncoder.run(MediaEncoder.java:155)
at java.lang.Thread.run(Thread.java:818)

@saki4510t
Copy link
Owner

Could you confirm which MediaCodec crash, for audio or for video?
Did you see other errors before above log? Tag may be ACodec.
MediaCodec usually throws IllegalStateException when the instance did not correctly initialize/prepare or is not in Executing state or configured in asynchronous mode.
But your log shows the state is state 6(=STARTED), so MediaCodec is started.

@ToysoftInc
Copy link
Author

I'm not sure which one but it crashed in the MediaEncoder class in the drain()

encoderStatus = mMediaCodec.dequeueOutputBuffer(mBufferInfo, TIMEOUT_USEC);

It was recording around 2 minutes when it crashed.

@atul-bsb
Copy link

atul-bsb commented Dec 27, 2016

Observed the same crash trace at my end. As per the trace it happens on doing drain() after signalEndOfInputStream(). This is not OS specific. @saki4510t Any help/pointers would be highly appreciated.

Thanks

@RockyLin
Copy link

RockyLin commented Jan 4, 2017

@saki4510t

Thanks for this great lib! We got this from crashlytics.

Device:SM-G386T1,
OS:4.4.2
screen shot 2017-01-04 at 9 39 18 pm

screen shot 2017-01-04 at 9 41 50 pm

@ashishvirani
Copy link

same problem

@anonym24
Copy link

Recording fails to start on KitKat 4.4 (Samsuns GT-9070), some audio error

09-20 22:02:17.636 16238-16238/com.testaudiovideosample E/dalvikvm: Could not find class 'android.support.v4.app.ActivityCompat$SharedElementCallback21Impl', referenced from method android.support.v4.app.ActivityCompat.setExitSharedElementCallback
09-20 22:02:29.788 16238-16238/com.testaudiovideosample E/VideoRecorder-VideoRecorder: startEncoder:begin
09-20 22:02:29.798 16238-16331/com.testaudiovideosample E/VideoRecorder-VideoRecorder: startEncoder:begin
09-20 22:02:29.938 16238-16331/com.testaudiovideosample E/VideoRecorder-VideoRecorder: supportedType:OMX.ST.VFM.MPEG4Enc,MIME=video/3gpp
    supportedType:OMX.ST.VFM.MPEG4Enc,MIME=video/mp4v-es
    supportedType:OMX.ST.VFM.H264Enc,MIME=video/avc
    supportedType:OMX.google.amrnb.encoder,MIME=audio/3gpp
    supportedType:OMX.google.amrwb.encoder,MIME=audio/amr-wb
    supportedType:OMX.google.aac.encoder,MIME=audio/mp4a-latm
    selected codec: OMX.google.aac.encoder
    format: {bitrate=64000, channel-count=1, aac-profile=2, mime=audio/mp4a-latm, sample-rate=44100, channel-mask=16}
09-20 22:02:30.729 16238-16339/com.testaudiovideosample E/BellagioCore: ST Static Component Loader : Cannot open OpenMAX registry file /tmp/.omxregister
09-20 22:02:30.739 16238-16339/com.testaudiovideosample E/BellagioCore: Component loader 1 constructor fails. Error= 0x80001000 
09-20 22:02:30.769 16238-16331/com.testaudiovideosample E/VideoRecorder-VideoRecorder: prepare finishing
09-20 22:02:31.640 16238-16337/com.testaudiovideosample E/ACodec: OMX/mediaserver died, signalling error!
09-20 22:02:31.640 16238-16336/com.testaudiovideosample E/MediaCodec: Codec reported an error. (omx error 0x8000100d, internalError -32)
09-20 22:02:31.640 16238-16339/com.testaudiovideosample E/ACodec: OMX/mediaserver died, signalling error!
09-20 22:02:31.640 16238-16339/com.testaudiovideosample E/MediaCodec: Codec reported an error. (omx error 0x8000100d, internalError -32)
09-20 22:02:31.640 16238-16259/com.testaudiovideosample E/Surface: queueBuffer: error queuing buffer to SurfaceTexture, -32
09-20 22:02:31.640 16238-16259/com.testaudiovideosample E/[EGL-ERROR]: void __egl_platform_queue_buffer(mali_base_ctx_handle, egl_buffer*):1122: unable to queue buffer (0x52ac32ac)
09-20 22:02:31.650 16238-16258/com.testaudiovideosample E/Camera: Error 100
09-20 22:02:37.495 16238-16343/com.testaudiovideosample E/VideoRecorder: AudioThread#run
    java.lang.IllegalStateException
        at android.media.MediaCodec.getBuffers(Native Method)
        at android.media.MediaCodec.getInputBuffers(MediaCodec.java:542)
        at com.erlei.videorecorder.encoder.MediaEncoder.encode(MediaEncoder.java:249)
        at com.erlei.videorecorder.encoder.MediaAudioEncoder$AudioThread.run(MediaAudioEncoder.java:154)

@kartik1225
Copy link

I also have the same Issue on android 5.1

08-08 16:11:15.598 20736-20736/com.w3saver.typography E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.w3saver.typography, PID: 20736
    java.lang.IllegalStateException
        at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
        at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:1033)
        at com.w3saver.typography.RenderEngine.RenderEngine.drainEncoder(RenderEngine.java:161)
        at com.w3saver.typography.RenderEngine.Renderer$2.run(Renderer.java:136)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5254)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

@aruproy
Copy link

aruproy commented Dec 12, 2019

I see the same issue in various Android versions and devices:

java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2406)
at com.serenegiant.d.b.k(SourceFile:334)
at com.serenegiant.d.b.run(SourceFile:160)
at java.lang.Thread.run(Thread.java:833)

This appears to come from this line of code in MediaEncoder drain() method:
// get encoded data with maximum timeout duration of TIMEOUT_USEC(=10[msec])
encoderStatus = mMediaCodec.dequeueOutputBuffer(mBufferInfo, TIMEOUT_USEC);

Hope someone can help resolve this issue.

@shivangbtech
Copy link

getting the same issue, Any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants