有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java NdkMediaCodec返回错误(0x90000012)

我正在将java解码过程转换为JNI。 首先,我使用以下源代码初始化mediacodec:

AMediaCodec* codec;
AMediaFormat* format = AMediaFormat_new();
AMediaFormat_setInt32(format,AMEDIAFORMAT_KEY_WIDTH,1920);
AMediaFormat_setInt32(format,AMEDIAFORMAT_KEY_HEIGHT,1080);
AMediaFormat_setString(format,AMEDIAFORMAT_KEY_MIME,"video/avc");

codec = AMediaCodec_createDecoderByType(AVR_MEDIA_MIME_FORMAT);
AMediaCodec_configure(codec, format, newNativeWindow, NULL, 0);
AMediaCodec_start(codec);

然后在缓冲区中填充。(数据在java中没有问题)

buffer = AMediaCodec_getOutputBuffer(codec, buffer_index, &buffer_size);
if(buffer >=0){
    memcpy(buffer, background, background_size);
    AMediaCodec_queueInputBuffer(codec,buffer_index, 0, background_size, 0, 0);
}

但它不起作用。日志是:

I/ACodec(19130):  [] Now uninitialized
I/OMXClient(19130): Using client-side OMX mux.
I/ACodec(19130): can't find wfdsink-exynos-enable
I/ACodec(19130): [OMX.Exynos.avc.dec] configureOutputBuffersFromNativeWindow setBufferCount : 6, minUndequeuedBuffers : 4
I/ACodec(19130): [OMX.Exynos.avc.dec] allocated meta buffer with ID 0xed110060 (pointer = 0xf49e5000)
I/ACodec(19130): [OMX.Exynos.avc.dec] allocated meta buffer with ID 0xed110510 (pointer = 0xf49e5020)
I/ACodec(19130): [OMX.Exynos.avc.dec] allocated meta buffer with ID 0xecf06970 (pointer = 0xf49e5040)
I/ACodec(19130): [OMX.Exynos.avc.dec] allocated meta buffer with ID 0xed406290 (pointer = 0xf49e5060)
I/ACodec(19130): [OMX.Exynos.avc.dec] allocated meta buffer with ID 0xed1106f0 (pointer = 0xf49e5080)
I/ACodec(19130): [OMX.Exynos.avc.dec] allocated meta buffer with ID 0xed406100 (pointer = 0xf49e50a0)
I/ACodec(19130): [OMX.Exynos.avc.dec] Now Executing
I/Timeline(19130): Timeline: Activity_idle id: 安卓.os.BinderProxy@298cf478 time:6236268
E/ACodec(19130): [OMX.Exynos.avc.dec] ERROR(0x90000012)
E/ACodec(19130): signalError(omxError 0x90000012, internalError -2147483648)
E/MediaCodec(19130): Codec reported err 0x90000012, actionCode 0, while in state 6
E/NdkMediaCodec(19130): sf error code: -38
E/NdkMediaCodec(19130): sf error code: -38
E/NdkMediaCodec(19130): sf error code: -38

共 (1) 个答案

  1. # 1 楼答案

    代码中存在两个潜在问题:

    1. 条件“if(buffer>;=0)”不正确,应为“if(buffer)”
    2. 确保背景尺寸<;=缓冲区大小