private boolean onFrame(byte[] buf, int offset, int length){
// 获取输入buffer index
ByteBuffer[] inputBuffers = mMediaCodec.getInputBuffers();
//-1表示一直等待;0表示不等待;其他大于0的参数表示等待毫秒数
int inputBufferIndex;
try{
inputBufferIndex = mMediaCodec.dequeueInputBuffer(-1);
}catch (Exception e){
return false;
}
if (inputBufferIndex >= 0) {
ByteBuffer inputBuffer = inputBuffers[inputBufferIndex];
//清空buffer
inputBuffer.clear();
//put需要解码的数据
inputBuffer.put(buf, offset, length);
//解码
mMediaCodec.queueInputBuffer(inputBufferIndex, 0, length, System.currentTimeMillis(), 0);
} else {
return false;
}
// 获取输出buffer index
MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
int outputBufferIndex = mMediaCodec.dequeueOutputBuffer(bufferInfo, 100);
//循环解码,直到数据全部解码完成
while (outputBufferIndex >= 0) {
//true : 将解码的数据显示到surface上
mMediaCodec.releaseOutputBuffer(outputBufferIndex, true);
outputBufferIndex = mMediaCodec.dequeueOutputBuffer(bufferInfo, 0);
}
return true;
}
Android4.4调用 MediaCodec.queueInputBuffer()时报错
04-30 11:11:38.028 113-113/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-30 11:11:38.028 113-113/? I/DEBUG: Build fingerprint: 'rockchip/M1/M1:4.4.4/KTU84Q/rk3188.20170911.162732:user/test-keys'
04-30 11:11:38.028 113-113/? I/DEBUG: Revision: '0'
04-30 11:11:38.028 113-113/? I/DEBUG: pid: 3141, tid: 3191, name: CodecLooper >>> com.zao.edu <<<
04-30 11:11:38.028 113-113/? I/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
04-30 11:11:38.108 113-113/? I/DEBUG: r0 00000000 r1 00000c77 r2 00000006 r3 00000000
04-30 11:11:38.108 113-113/? I/DEBUG: r4 00000006 r5 00000000 r6 00000c77 r7 0000010c
04-30 11:11:38.108 113-113/? I/DEBUG: r8 00000001 r9 00319200 sl 00000000 fp 00000000
04-30 11:11:38.108 113-113/? I/DEBUG: ip 00000001 sp 71658748 lr 400f309d pc 40102048 cpsr 000f0010
04-30 11:11:38.108 113-113/? I/DEBUG: d0 203a64656c696166 d1 202b207465736666
04-30 11:11:38.108 113-113/? I/DEBUG: d2 61436d2c657a6973 d3 2029797469636170
04-30 11:11:38.108 113-113/? I/DEBUG: d4 646e756f662f7468 d5 42412f6e6f697461
04-30 11:11:38.108 113-113/? I/DEBUG: d6 70632e7265666675 d7 4548432038353a70
04-30 11:11:38.108 113-113/? I/DEBUG: d8 0000000000000000 d9 0000000000000000
04-30 11:11:38.108 113-113/? I/DEBUG: d10 0000000000000000 d11 0000000000000000
04-30 11:11:38.108 113-113/? I/DEBUG: d12 0000000000000000 d13 0000000000000000
04-30 11:11:38.108 113-113/? I/DEBUG: d14 0000000000000000 d15 0000000000000000
04-30 11:11:38.108 113-113/? I/DEBUG: d16 402e000000000000 d17 402f000000000000
04-30 11:11:38.118 113-113/? I/DEBUG: d18 0000000000000000 d19 0000000000000000
04-30 11:11:38.118 113-113/? I/DEBUG: d20 3ff0000000000000 d21 0000000000000000
04-30 11:11:38.118 113-113/? I/DEBUG: d22 0000000000000000 d23 0000000000000000
04-30 11:11:38.118 113-113/? I/DEBUG: d24 402c000000000000 d25 0000000000000000
04-30 11:11:38.118 113-113/? I/DEBUG: d26 3ff0000000000000 d27 0000000000000000
04-30 11:11:38.118 113-113/? I/DEBUG: d28 402c000000000000 d29 0000000000000000
04-30 11:11:38.118 113-113/? I/DEBUG: d30 000000000000001f d31 0000000000000021
04-30 11:11:38.118 113-113/? I/DEBUG: scr 60000013
04-30 11:11:38.118 113-113/? I/DEBUG: backtrace:
04-30 11:11:38.118 113-113/? I/DEBUG: #00 pc 00022048 /system/lib/libc.so (tgkill+12)
04-30 11:11:38.118 113-113/? I/DEBUG: #01 pc 00013099 /system/lib/libc.so (pthread_kill+48)
04-30 11:11:38.118 113-113/? I/DEBUG: #02 pc 000132ad /system/lib/libc.so (raise+10)
04-30 11:11:38.118 113-113/? I/DEBUG: #03 pc 00011fe3 /system/lib/libc.so
04-30 11:11:38.118 113-113/? I/DEBUG: #04 pc 000218fc /system/lib/libc.so (abort+4)
04-30 11:11:38.118 113-113/? I/DEBUG: #05 pc 000014c3 /system/lib/liblog.so (__android_log_assert+86)
04-30 11:11:38.118 113-113/? I/DEBUG: #06 pc 00008a07 /system/lib/libstagefright_foundation.so (android::ABuffer::setRange(unsigned int, unsigned int)+138)
04-30 11:11:38.118 113-113/? I/DEBUG: #07 pc 000597ff /system/lib/libstagefright.so (android::ACodec::BaseState::onOMXFillBufferDone(void*, unsigned int, unsigned int, unsigned long, long long, void*, void*)+402)
04-30 11:11:38.118 113-113/? I/DEBUG: #08 pc 00059c4b /system/lib/libstagefright.so (android::ACodec::BaseState::onOMXMessage(android::spandroid::AMessage const&)+610)
04-30 11:11:38.118 113-113/? I/DEBUG: #09 pc 0005a0ed /system/lib/libstagefright.so (android::ACodec::ExecutingState::onMessageReceived(android::spandroid::AMessage const&)+536)
04-30 11:11:38.118 113-113/? I/DEBUG: #10 pc 00008c7f /system/lib/libstagefright_foundation.so (android::AHierarchicalStateMachine::onMessageReceived(android::spandroid::AMessage const&)+82)
04-30 11:11:38.118 113-113/? I/DEBUG: #11 pc 0000981d /system/lib/libstagefright_foundation.so (android::ALooperRoster::deliverMessage(android::spandroid::AMessage const&)+152)
04-30 11:11:38.118 113-113/? I/DEBUG: #12 pc 000091e7 /system/lib/libstagefright_foundation.so (android::ALooper::loop()+198)
04-30 11:11:38.118 113-113/? I/DEBUG: #13 pc 0000e9ed /system/lib/libutils.so (android::Thread::_threadLoop(void*)+104)
04-30 11:11:38.118 113-113/? I/DEBUG: #14 pc 0000e58f /system/lib/libutils.so
04-30 11:11:38.118 113-113/? I/DEBUG: #15 pc 0000d228 /system/lib/libc.so (__thread_entry+72)
04-30 11:11:38.118 113-113/? I/DEBUG: #16 pc 0000d3c0 /system/lib/libc.so (pthread_create+240)
04-30 11:11:38.118 113-113/? I/DEBUG: stack:
04-30 11:11:38.118 113-113/? I/DEBUG: 71658708 00000000
04-30 11:11:38.118 113-113/? I/DEBUG: 7165870c 00000000
04-30 11:11:38.118 113-113/? I/DEBUG: 71658710 00000000
04-30 11:11:38.118 113-113/? I/DEBUG: 71658714 000003ff
04-30 11:11:38.118 113-113/? I/DEBUG: 71658718 00319200
04-30 11:11:38.118 113-113/? I/DEBUG: 7165871c 00000000
04-30 11:11:38.118 113-113/? I/DEBUG: 71658720 00000001
04-30 11:11:38.118 113-113/? I/DEBUG: 71658724 00000001
04-30 11:11:38.118 113-113/? I/DEBUG: 71658728 00319200
04-30 11:11:38.118 113-113/? I/DEBUG: 7165872c 00000000
04-30 11:11:38.118 113-113/? I/DEBUG: 71658730 400890b1 /system/lib/liblog.so
04-30 11:11:38.118 113-113/? I/DEBUG: 71658734 4008a5f9 /system/lib/liblog.so
04-30 11:11:38.118 113-113/? I/DEBUG: 71658738 716587ac
04-30 11:11:38.118 113-113/? I/DEBUG: 7165873c 00000000
04-30 11:11:38.118 113-113/? I/DEBUG: 71658740 4012a1d8 /system/lib/libc.so
04-30 11:11:38.118 113-113/? I/DEBUG: 71658744 66d7c6c8
04-30 11:11:38.118 113-113/? I/DEBUG: #00 71658748 00000006
04-30 11:11:38.118 113-113/? I/DEBUG: 7165874c 00000000
04-30 11:11:38.118 113-113/? I/DEBUG: 71658750 00000c77
04-30 11:11:38.118 113-113/? I/DEBUG: 71658754 00000001
04-30 11:11:38.118 113-113/? I/DEBUG: 71658758 00000001
04-30 11:11:38.118 113-113/? I/DEBUG: 7165875c 400f309d /system/lib/libc.so (pthread_kill+52)
04-30 11:11:38.118 113-113/? I/DEBUG: #01 71658760 00000006
04-30 11:11:38.118 113-113/? I/DEBUG: 71658764 00000000
04-30 11:11:38.118 113-113/? I/DEBUG: 71658768 00000000
04-30 11:11:38.118 113-113/? I/DEBUG: 7165876c 400f32b1 /system/lib/libc.so (raise+14)
04-30 11:11:38.118 113-113/? I/DEBUG: #02 71658770 7165877c
04-30 11:11:38.118 113-113/? I/DEBUG: 71658774 400f1fe7 /system/lib/libc.so
04-30 11:11:38.118 113-113/? I/DEBUG: memory near r9:
04-30 11:11:38.118 113-113/? I/DEBUG: 003191e0 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 003191f0 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319200 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319210 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319220 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319230 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319240 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319250 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319260 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319270 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319280 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 00319290 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 003192a0 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 003192b0 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 003192c0 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: 003192d0 ffffffff ffffffff ffffffff ffffffff
04-30 11:11:38.128 113-113/? I/DEBUG: memory near sp:
04-30 11:11:38.128 113-113/? I/DEBUG: 71658728 00319200 00000000 400890b1 4008a5f9
04-30 11:11:38.128 113-113/? I/DEBUG: 71658738 716587ac 00000000 4012a1d8 66d7c6c8
04-30 11:11:38.128 113-113/? I/DEBUG: 71658748 00000006 00000000 00000c77 00000001
04-30 11:11:38.128 113-113/? I/DEBUG: 71658758 00000001 400f309d 00000006 00000000
04-30 11:11:38.128 113-113/? I/DEBUG: 71658768 00000000 400f32b1 7165877c 400f1fe7
04-30 11:11:38.128 113-113/? I/DEBUG: 71658778 00004000 ffffffdf 2a2a2a2a 7165877c
04-30 11:11:38.128 113-113/? I/DEBUG: 71658788 00000001 b25da946 00000007 00000000
04-30 11:11:38.128 113-113/? I/DEBUG: 71658798 00319200 40101900 400890b1 400894c7
04-30 11:11:38.128 113-113/? I/DEBUG: 716587a8 71658bbc 6d617266 726f7765 612f736b
04-30 11:11:38.128 113-113/? I/DEBUG: 716587b8 656d2f76 2f616964 7362696c 65676174
04-30 11:11:38.128 113-113/? I/DEBUG: 716587c8 67697266 662f7468 646e756f 6f697461
04-30 11:11:38.128 113-113/? I/DEBUG: 716587d8 42412f6e 65666675 70632e72 38353a70
04-30 11:11:38.128 113-113/? I/DEBUG: 716587e8 45484320 4c5f4b43 6f202845 65736666
04-30 11:11:38.128 113-113/? I/DEBUG: 716587f8 202b2074 657a6973 61436d2c 69636170
04-30 11:11:38.128 113-113/? I/DEBUG: 71658808 20297974 6c696166 203a6465 38343233
04-30 11:11:38.128 113-113/? I/DEBUG: 71658818 20303436 202e7376 32383331 00303034
04-30 11:11:38.128 113-113/? I/DEBUG: code around pc:
04-30 11:11:38.128 113-113/? I/DEBUG: 40102028 e8bd00f0 e3700a01 912fff1e e2600000
04-30 11:11:38.128 113-113/? I/DEBUG: 40102038 ea006e3d e92d50f0 e3a07f43 ef000000
04-30 11:11:38.128 113-113/? I/DEBUG: 40102048 e8bd50f0 e3700a01 912fff1e e2600000
04-30 11:11:38.128 113-113/? I/DEBUG: 40102058 ea006e35 e92d50f0 e3a070ee ef000000
04-30 11:11:38.128 113-113/? I/DEBUG: 40102068 e8bd50f0 e3700a01 912fff1e e2600000
04-30 11:11:38.128 113-113/? I/DEBUG: 40102078 ea006e2d f200429a bf0080cf f000f891
04-30 11:11:38.128 113-113/? I/DEBUG: 40102088 4001e92d f040f891 d3532a10 0301ea80
04-30 11:11:38.128 113-113/? I/DEBUG: 40102098 0303f013 806ef000 d3262ae0 0300f1c0
04-30 11:11:38.128 113-113/? I/DEBUG: 401020a8 030ff013 eba2d021 ea5f0203 bf447cc3
04-30 11:11:38.128 113-113/? I/DEBUG: 401020b8 eb01f811 eb01f800 f811bf21 f811cb01
04-30 11:11:38.128 113-113/? I/DEBUG: 401020c8 f800eb01 f800cb01 ea5feb01 da037c43
04-30 11:11:38.128 113-113/? I/DEBUG: 401020d8 080df9a1 083df980 f921d303 f900070d
04-30 11:11:38.128 113-113/? I/DEBUG: 401020e8 f891071d f891f000 3a40f040 f891d30f
04-30 11:11:38.128 113-113/? I/DEBUG: 401020f8 f891f080 f921f0c0 f921020d f891420d
04-30 11:11:38.128 113-113/? I/DEBUG: 40102108 3a40f0c0 020df900 420df900 f102d2f3
04-30 11:11:38.128 113-113/? I/DEBUG: 40102118 3a200240 f921d305 3a20020d 020df900
04-30 11:11:38.128 113-113/? I/DEBUG: code around lr:
04-30 11:11:38.128 113-113/? I/DEBUG: 400f307c 447b4b13 42b3e010 6a1ed10e 44784811
04-30 11:11:38.128 113-113/? I/DEBUG: 400f308c ec84f7fb ea0ef00d 46224631 efd0f00e
04-30 11:11:38.128 113-113/? I/DEBUG: 400f309c d00a3001 e00b2400 2b00681b 480ad1eb
04-30 11:11:38.128 113-113/? I/DEBUG: 400f30ac 44782403 ec72f7fb f001e002 6804fa23
04-30 11:11:38.128 113-113/? I/DEBUG: 400f30bc fa20f001 46206005 bf00bd70 0003b326
04-30 11:11:38.128 113-113/? I/DEBUG: 400f30cc 0003b31a 0003b312 0003b2ee bf7ef7ff
04-30 11:11:38.128 113-113/? I/DEBUG: 400f30dc 4a3e4b3d e92d447b b08b43f0 4606589c
04-30 11:11:38.128 113-113/? I/DEBUG: 400f30ec 6823460d 930946a1 fa04f001 8000f8d0
04-30 11:11:38.128 113-113/? I/DEBUG: 400f30fc d0482d00 f00f4628 280ffe91 d8444604
04-30 11:11:38.128 113-113/? I/DEBUG: 400f310c ffe4f7ff d1064286 4629200f e8d8f00d
04-30 11:11:38.128 113-113/? I/DEBUG: 400f311c d03c2800 482ee02e f7fb4478 482debb6
04-30 11:11:38.128 113-113/? I/DEBUG: 400f312c e0154478 d11342b0 482b6a06 f7fb4478
04-30 11:11:38.128 113-113/? I/DEBUG: 400f313c 4a2aec2e 46332120 a801447a f9b2f013
04-30 11:11:38.128 113-113/? I/DEBUG: 400f314c a8012101 fcccf01a 46061c42 e011d104
04-30 11:11:38.128 113-113/? I/DEBUG: 400f315c 28006800 e02cd1e6 46294630 f00d4622
04-30 11:11:38.128 113-113/? I/DEBUG: 400f316c 1c43e914 d11e4607 f9c4f001 29046801
--------- beginning of /dev/log/system
04-30 11:11:38.328 435-456/? I/BootReceiver: Copying /data/tombstones/tombstone_06 to DropBox (SYSTEM_TOMBSTONE)
04-30 11:11:38.328 435-3215/? W/ActivityManager: Force finishing activity com.zao.edu/.activitys.OneScreenActivity
04-30 11:11:38.348 118-1000/? E/OMXNodeInstance: !!! Observer died. Quickly, do something, ... anything...
04-30 11:11:38.368 435-463/? W/InputDispatcher: channel '41d843a8 com.zao.edu/com.zao.edu.activitys.HomeActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
04-30 11:11:38.368 435-463/? E/InputDispatcher: channel '41d843a8 com.zao.edu/com.zao.edu.activitys.HomeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
04-30 11:11:38.368 435-463/? W/InputDispatcher: channel '41d8ffb0 (server)' ~ Consumer closed input channel or an error occurred. events=0x9
04-30 11:11:38.368 435-463/? E/InputDispatcher: channel '41d8ffb0 (server)' ~ Channel is unrecoverably broken and will be disposed!
04-30 11:11:38.368 435-463/? W/InputDispatcher: channel '41deafa0 com.zao.edu/com.zao.edu.activitys.OneScreenActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
04-30 11:11:38.368 435-463/? E/InputDispatcher: channel '41deafa0 com.zao.edu/com.zao.edu.activitys.OneScreenActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
04-30 11:11:38.368 116-116/? D/Zygote: Process 3141 terminated by signal (6)