[Android Video FrameWork] OMXNodeIntance中动态控制log的一种方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012188065/article/details/86756693

从事此行业N年,遇到问题上去先是一通王八拳,能把问题打死,
就继续找下一个问题的茬,如果打不死,就再打一套王八拳,直至打死问题为止。

王八拳(不成体系的定位方法和手段)对付问题有效果,但是效率低,
我的王八拳主要是:
加log,编译,替库,运行,看log, 加log,编译,替库,运行,看log……
运用这种磨豆腐的磨劲,磨死了好多问题,但 碰到流程套路深的框架和体系,这个效率实在实在是太低了,
有时候能从java层跟到内核层,有种上穷碧落下黄泉的感觉,甚至最后还 两处茫茫皆不见。

后来升级王八拳至 王八拳V2.0,即增加调用栈的方式,编译替库一次,可以揪出一大窜流程
从java到内核的调用栈方法如下:
https://blog.csdn.net/u012188065/article/details/84667625

再后来,学会了 adb shell dumpsys, 可以dump media.audio_flinger, dump media.player 等进程
瞬间感觉到了人生的巅峰,使用之前是我给代码打工,使用之后是代码给我打工
可以参考此文 https://blog.csdn.net/u012188065/article/details/84255809 中的 部分专用调试命令 模块

再来后问题也开始迭代升级了(也有可能通用的问题很容易被这些通用的定位调试手段消灭掉,剩下来的都是特有问题),
原有手段命中率也开始下降,又逐渐回归到我给代码打工,还是996的那种。
是时候去总结一些特定的定位手段,把王八拳中有价值的招式提取处理,荟萃成少林长拳,武当剑法甚至凌波微步这些特定的招式,去打击特定的问题。

某天梳理video代码流程,发现OMXNodeIntance构造函数中有如下语句:

DEBUG = ADebug::GetDebugLevelFromProperty(name, "debug.stagefright.omx-debug");

机警如我的我,一看到property这几个字,就知道是一个动态开关
果不其然,文件头有大量控制log的宏,如下:

#define CLOGI_(level, fn, fmt, ...) \
    ALOGI_IF(DEBUG >= (level), #fn "(%p:%s, " fmt ")", mHandle, mName, ##__VA_ARGS__)
#define CLOGD_(level, fn, fmt, ...) \
    ALOGD_IF(DEBUG >= (level), #fn "(%p:%s, " fmt ")", mHandle, mName, ##__VA_ARGS__)

#define CLOG_LIFE(fn, fmt, ...)     CLOGI_(ADebug::kDebugLifeCycle,     fn, fmt, ##__VA_ARGS__)
#define CLOG_STATE(fn, fmt, ...)    CLOGI_(ADebug::kDebugState,         fn, fmt, ##__VA_ARGS__)
#define CLOG_CONFIG(fn, fmt, ...)   CLOGI_(ADebug::kDebugConfig,        fn, fmt, ##__VA_ARGS__)
#define CLOG_INTERNAL(fn, fmt, ...) CLOGD_(ADebug::kDebugInternalState, fn, fmt, ##__VA_ARGS__)

代码中存在大量使用 CLOG_LIFE, CLOG_INTERNAL这些宏
通过设置的 DEBUG 与log级别中的 ADebug::kDebugLifeCycle, ADebug::kDebugState等级别比较
高于log中的级别就打印,低于就不打印。
log级别共有如下几个level, 见 ADebug.cpp

    enum Level {
        kDebugNone,             // no debug
        kDebugLifeCycle,        // lifecycle events: creation/deletion
        kDebugState,            // commands and events
        kDebugConfig,           // configuration
        kDebugInternalState,    // internal state changes
        kDebugAll,              // all
        kDebugMax = kDebugAll,

    };

默认 property键值 “debug.stagefright.omx-debug” 未使能,为 kDebugNone,播放视频log如下:

02-03 10:49:47.266 13916 14190 I OMXNodeInstance: debug level for OMX.google.aac.decoder is 0, mName:google.aac.decoder
02-03 10:49:47.268 13916 14190 E OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:49:47.269 13916 14190 E OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:49:47.269 13916 14190 E OMXNodeInstance: getConfig(0xf2f26e40:google.aac.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)

adb shell setprop debug.stagefright.omx-debug 1, 设置为kDebugLifeCycle后,

02-03 10:50:19.947 13916 14257 I OMXNodeInstance: debug level for OMX.google.aac.decoder is 1, mName:google.aac.decoder
02-03 10:50:19.948 13916 14257 I OMXNodeInstance: allocateNode(0x0:google.aac.decoder, handle=0xf2f262a0)
02-03 10:50:19.949 13916 14257 E OMXNodeInstance: setConfig(0xf2f262a0:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:50:19.950 13916 14257 E OMXNodeInstance: setConfig(0xf2f262a0:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:50:19.950 13916 14257 E OMXNodeInstance: getConfig(0xf2f262a0:google.aac.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
02-03 10:50:22.196 13916 14257 I OMXNodeInstance: freeNode(0xf2f262a0:google.aac.decoder, handle=0xf2f262a0)

可以看出多了 allocateNode 和 freeNode 两句log
针对一些视频,播放完成后无法退出,我们可以通过此level log,来定位是codec没有退出还是上层player没有退出。

设置为 kDebugState后:

02-03 10:52:10.771 13916 14257 I OMXNodeInstance: debug level for OMX.google.aac.decoder is 2, mName:google.aac.decoder
02-03 10:52:10.772 13916 14257 I OMXNodeInstance: allocateNode(0x0:google.aac.decoder, handle=0xf2f262a0)
02-03 10:52:10.772 13916 14257 E OMXNodeInstance: setConfig(0xf2f262a0:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:52:10.773 13916 14257 E OMXNodeInstance: setConfig(0xf2f262a0:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:52:10.774 13916 14257 E OMXNodeInstance: getConfig(0xf2f262a0:google.aac.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
02-03 10:52:10.775 13916 14257 I OMXNodeInstance: sendCommand(0xf2f262a0:google.aac.decoder, StateSet(0), Idle(2))
02-03 10:52:10.780 13916 14257 I OMXNodeInstance: onEvent(0xf2f262a0:google.aac.decoder, CmdComplete(0), StateSet(0), Idle(2))
02-03 10:52:10.781 13916 14257 I OMXNodeInstance: sendCommand(0xf2f262a0:google.aac.decoder, StateSet(0), Executing(3))
02-03 10:52:10.781 13916 15411 I OMXNodeInstance: onEvent(0xf2f262a0:google.aac.decoder, CmdComplete(0), StateSet(0), Executing(3))
02-03 10:52:10.782 13916 14257 I OMXNodeInstance: sendCommand(0xf2f262a0:google.aac.decoder, PortDisable(2), Output(1))
02-03 10:52:10.783 13916 14257 I OMXNodeInstance: sendCommand(0xf2f262a0:google.aac.decoder, PortEnable(3), Output(1))
02-03 10:52:13.019 13916 14257 I OMXNodeInstance: sendCommand(0xf2f262a0:google.aac.decoder, Flush(1), All(-1))
02-03 10:52:13.033 13916 14257 I OMXNodeInstance: sendCommand(0xf2f262a0:google.aac.decoder, StateSet(0), Idle(2))
02-03 10:52:13.033 13916 15411 I OMXNodeInstance: onEvent(0xf2f262a0:google.aac.decoder, CmdComplete(0), StateSet(0), Idle(2))
02-03 10:52:13.034 13916 14257 I OMXNodeInstance: sendCommand(0xf2f262a0:google.aac.decoder, StateSet(0), Loaded(1))
02-03 10:52:13.036 13916 14207 I OMXNodeInstance: onEvent(0xf2f262a0:google.aac.decoder, CmdComplete(0), StateSet(0), Loaded(1))
02-03 10:52:13.037 13916 13921 I OMXNodeInstance: freeNode(0xf2f262a0:google.aac.decoder, handle=0xf2f262a0)

log中多了 setConfig/getConfig, sendCommand, onEvent等与component交互的过程,
我们可以根据此log查看上层player是否正确地,完整地配置component

设置为 kDebugConfig 后:

02-03 10:54:49.936 13916 14257 I OMXNodeInstance: debug level for OMX.google.aac.decoder is 3, mName:google.aac.decoder
02-03 10:54:49.937 13916 14257 I OMXNodeInstance: allocateNode(0x0:google.aac.decoder, handle=0xf2f26e40)
02-03 10:54:49.938 13916 14257 I OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002), 16@0xf2f13130))
02-03 10:54:49.938 13916 14257 E OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:54:49.938 13916 14257 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamStandardComponentRole(0x1000017), 136@0xf2f1a0a0))
02-03 10:54:49.938 13916 14257 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamPortDefinition(0x2000001), 96@0xf2f26c00))
02-03 10:54:49.938 13916 14257 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamAudioPcm(0x4000002), 104@0xf0ef2070))
02-03 10:54:49.939 13916 14257 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamAudioAac(0x4000003), 52@0xf2f300e0))
02-03 10:54:49.939 13916 14257 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamAudioAndroidAacPresentation(0x6f400003), 36@0xf2f0b230))
02-03 10:54:49.939 13916 14257 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamPortDefinition(0x2000001), 96@0xf2f26c00))
02-03 10:54:49.939 13916 14257 I OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002), 16@0xf2f13130))
02-03 10:54:49.939 13916 14257 E OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:54:49.939 13916 14257 E OMXNodeInstance: getConfig(0xf2f26e40:google.aac.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
02-03 10:54:49.940 13916 14257 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, StateSet(0), Idle(2))
02-03 10:54:49.945 13916 14257 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), StateSet(0), Idle(2))
02-03 10:54:49.947 13916 14257 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, StateSet(0), Executing(3))
02-03 10:54:49.947 13916 15571 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), StateSet(0), Executing(3))
02-03 10:54:49.950 13916 14257 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, PortDisable(2), Output(1))
02-03 10:54:49.951 13916 14257 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, PortEnable(3), Output(1))
02-03 10:54:52.180 13916 13921 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, Flush(1), All(-1))
02-03 10:54:52.183 13916 13921 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, StateSet(0), Idle(2))
02-03 10:54:52.183 13916 15571 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), StateSet(0), Idle(2))
02-03 10:54:52.184 13916 13921 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, StateSet(0), Loaded(1))
02-03 10:54:52.188 13916 14312 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), StateSet(0), Loaded(1))
02-03 10:54:52.188 13916 14190 I OMXNodeInstance: freeNode(0xf2f26e40:google.aac.decoder, handle=0xf2f26e40)

多了 setParameter 这些操作

设置 kDebugInternalState 后

02-03 10:56:43.763 13916 14190 I OMXNodeInstance: debug level for OMX.google.aac.decoder is 4, mName:google.aac.decoder
02-03 10:56:43.764 13916 14190 I OMXNodeInstance: allocateNode(0x0:google.aac.decoder, handle=0xf2f26e40)
02-03 10:56:43.765 13916 14190 I OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002), 16@0xf2f131a0))
02-03 10:56:43.765 13916 14190 E OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:56:43.765 13916 14190 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamStandardComponentRole(0x1000017), 136@0xf41cad20))
02-03 10:56:43.765 13916 14190 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamPortDefinition(0x2000001), 96@0xf2f26780))
02-03 10:56:43.765 13916 14190 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamAudioPcm(0x4000002), 104@0xf0ef27e0))
02-03 10:56:43.765 13916 14190 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamAudioAac(0x4000003), 52@0xf41a6340))
02-03 10:56:43.765 13916 14190 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamAudioAndroidAacPresentation(0x6f400003), 36@0xf2f0b208))
02-03 10:56:43.766 13916 14190 I OMXNodeInstance: setParameter(0xf2f26e40:google.aac.decoder, ParamPortDefinition(0x2000001), 96@0xf2f26780))
02-03 10:56:43.766 13916 14190 I OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002), 16@0xf2f131a0))
02-03 10:56:43.766 13916 14190 E OMXNodeInstance: setConfig(0xf2f26e40:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
02-03 10:56:43.766 13916 14190 E OMXNodeInstance: getConfig(0xf2f26e40:google.aac.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
02-03 10:56:43.767 13916 14190 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, StateSet(0), Idle(2))
02-03 10:56:43.772 13916 14190 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), StateSet(0), Idle(2))
02-03 10:56:43.772 13916 14190 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, StateSet(0), Executing(3))
02-03 10:56:43.772 13916 15655 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), StateSet(0), Executing(3))
02-03 10:56:43.773 13916 14190 D OMXNodeInstance: fillBuffer(0xf2f26e40, 0x5 [32768@0xf53b1000 fc=-1] { IN=0/4 OUT=1/4 })
02-03 10:56:43.773 13916 14190 D OMXNodeInstance: fillBuffer(0xf2f26e40, 0x6 [32768@0xf53a8000 fc=-1] { IN=0/4 OUT=2/4 })
02-03 10:56:43.773 13916 14190 D OMXNodeInstance: fillBuffer(0xf2f26e40, 0x7 [32768@0xf53a0000 fc=-1] { IN=0/4 OUT=3/4 })
02-03 10:56:43.773 13916 14190 D OMXNodeInstance: fillBuffer(0xf2f26e40, 0x8 [32768@0xf5398000 fc=-1] { IN=0/4 OUT=4/4 })
02-03 10:56:43.773 13916 14190 D OMXNodeInstance: emptyBuffer(0xf2f26e40, 0x1 [262144@0xf52e4000 (0..+5) f=90 ts=0 fc=-1] { IN=1/4 OUT=4/4 })
02-03 10:56:43.774 13916 14190 D OMXNodeInstance: emptyBuffer(0xf2f26e40, 0x2 [262144@0xf4e78000 (0..+23) f=10 ts=0 fc=-1] { IN=2/4 OUT=4/4 })
02-03 10:56:43.774 13916 15656 D OMXNodeInstance: EBD(0xf2f26e40, 0x1 [262144@0xf52e4000 fc=-1] { IN=1/4 OUT=4/4 })
02-03 10:56:43.774 13916 14190 D OMXNodeInstance: emptyBuffer(0xf2f26e40, 0x3 [262144@0xf4ddb000 (0..+6) f=10 ts=21333 fc=-1] { IN=2/4 OUT=4/4 })
02-03 10:56:43.774 13916 15655 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, PortSettingsChanged(3), Output(1), ??(0))
02-03 10:56:43.774 13916 15656 D OMXNodeInstance: EBD(0xf2f26e40, 0x2 [262144@0xf4e78000 fc=-1] { IN=1/4 OUT=4/4 })
02-03 10:56:43.775 13916 14190 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, PortDisable(2), Output(1))
02-03 10:56:43.775 13916 15656 D OMXNodeInstance: FBD(0xf2f26e40, 0x5 [32768@0xf53b1000 (0..+0) f=0 ts=0 fc=-1] { IN=1/4 OUT=3/4 })
02-03 10:56:43.775 13916 15656 D OMXNodeInstance: FBD(0xf2f26e40, 0x6 [32768@0xf53a8000 (0..+0) f=0 ts=0 fc=-1] { IN=1/4 OUT=2/4 })
02-03 10:56:43.775 13916 15656 D OMXNodeInstance: FBD(0xf2f26e40, 0x7 [32768@0xf53a0000 (0..+0) f=0 ts=0 fc=-1] { IN=1/4 OUT=1/4 })
02-03 10:56:43.775 13916 15656 D OMXNodeInstance: FBD(0xf2f26e40, 0x8 [32768@0xf5398000 (0..+0) f=0 ts=0 fc=-1] { IN=1/4 OUT=0/4 })
02-03 10:56:43.776 13916 14190 D OMXNodeInstance: emptyBuffer(0xf2f26e40, 0x4 [262144@0xf4cce000 (0..+6) f=10 ts=42667 fc=-1] { IN=2/4 OUT=0/4 })
02-03 10:56:43.776 13916 14190 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), PortDisable(2), Output(1))
02-03 10:56:43.776 13916 14190 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, PortEnable(3), Output(1))
02-03 10:56:43.779 13916 14190 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), PortEnable(3), Output(1))
02-03 10:56:43.779 13916 14190 D OMXNodeInstance: emptyBuffer(0xf2f26e40, 0x1 [262144@0xf52e4000 (0..+6) f=10 ts=64000 fc=-1] { IN=3/4 OUT=0/4 })
02-03 10:56:43.779 13916 14190 D OMXNodeInstance: fillBuffer(0xf2f26e40, 0x9 [32768@0xf53b1000 fc=-1] { IN=3/4 OUT=1/4 })
02-03 10:56:43.780 13916 14190 D OMXNodeInstance: fillBuffer(0xf2f26e40, 0xa [32768@0xf53a8000 fc=-1] { IN=3/4 OUT=2/4 })
02-03 10:56:43.780 13916 15656 D OMXNodeInstance: EBD(0xf2f26e40, 0x3 [262144@0xf4ddb000 fc=-1] { IN=2/4 OUT=2/4 })
02-03 10:56:43.780 13916 14190 D OMXNodeInstance: fillBuffer(0xf2f26e40, 0xb [32768@0xf53a0000 fc=-1] { IN=2/4 OUT=3/4 })
02-03 10:56:43.780 13916 15656 D OMXNodeInstance: EBD(0xf2f26e40, 0x4 [262144@0xf4cce000 fc=-1] { IN=1/4 OUT=3/4 })
02-03 10:56:43.780 13916 14190 D OMXNodeInstance: fillBuffer(0xf2f26e40, 0xc [32768@0xf5398000 fc=-1] { IN=1/4 OUT=4/4 })
02-03 10:56:43.780 13916 15656 D OMXNodeInstance: FBD(0xf2f26e40, 0x9 [32768@0xf53b1000 (0..+4096) f=0 ts=0 fc=-1] { IN=1/4 OUT=3/4 })
02-03 10:56:43.780 13916 15656 D OMXNodeInstance: EBD(0xf2f26e40, 0x1 [262144@0xf52e4000 fc=-1] { IN=0/4 OUT=3/4 })
02-03 10:56:43.780 13916 15656 D OMXNodeInstance: FBD(0xf2f26e40, 0xa [32768@0xf53a8000 (0..+4096) f=0 ts=21333 fc=-1] { IN=0/4 OUT=2/4 })
02-03 10:56:43.780 13916 14190 D OMXNodeInstance: emptyBuffer(0xf2f26e40, 0x2 [262144@0xf4e78000 (0..+6) f=10 ts=85333 fc=-1] { IN=1/4 OUT=2/4 })
02-03 10:56:46.008 13916 13921 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, Flush(1), All(-1))
02-03 10:56:46.008 13916 15655 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), Flush(1), Input(0))
02-03 10:56:46.009 13916 15655 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), Flush(1), Output(1))
02-03 10:56:46.009 13916 15656 D OMXNodeInstance: FBD(0xf2f26e40, 0x9 [32768@0xf53b1000 (0..+0) f=0 ts=1962667 fc=-1] { IN=0/4 OUT=1/4 })
02-03 10:56:46.009 13916 15655 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), Flush(1), All(ffffffff))
02-03 10:56:46.009 13916 15656 D OMXNodeInstance: FBD(0xf2f26e40, 0xc [32768@0xf5398000 (0..+0) f=0 ts=1941333 fc=-1] { IN=0/4 OUT=0/4 })
02-03 10:56:46.010 13916 13921 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, StateSet(0), Idle(2))
02-03 10:56:46.010 13916 15655 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), StateSet(0), Idle(2))
02-03 10:56:46.011 13916 13921 I OMXNodeInstance: sendCommand(0xf2f26e40:google.aac.decoder, StateSet(0), Loaded(1))
02-03 10:56:46.014 13916 14190 I OMXNodeInstance: onEvent(0xf2f26e40:google.aac.decoder, CmdComplete(0), StateSet(0), Loaded(1))
02-03 10:56:46.015 13916 13921 I OMXNodeInstance: freeNode(0xf2f26e40:google.aac.decoder, handle=0xf2f26e40)

新增了前几帧每一帧的状态(比如:emptyBuffer/fillBuffer, EBD/FBD等)
也可以看出当前codec拥有inputBuffer和outputBuffer的数量,以及inputBuffer和outputBuffer的总数量
卡顿的时候我们也可以根据当前buffer的归属状态,,从而判断出卡顿时的性能瓶颈。

可以看出当前每一帧数据的大小,时间戳等信息,以emptyBuffer为例

#define FULL_BUFFER(addr, header, fenceFd) "%#" PRIxPTR " [%u@%p (%u..+%u) f=%x ts=%lld fc=%d]", \
    (intptr_t)(addr), (header)->nAllocLen, (header)->pBuffer, \
    (header)->nOffset, (header)->nFilledLen, (header)->nFlags, (header)->nTimeStamp, (fenceFd)

emptyBuffer(0xf2f26e40, 0x3 [262144@0xf4ddb000 (0..+6) f=10 ts=21333 fc=-1] { IN=2/4 OUT=4/4 })

表示申请的输入bufferSize为 262144, 当前数据的offset为0, len为6, buffer的flag为10 (完整的一帧 OMX_BUFFERFLAG_ENDOFFRAME), 时间戳为 21333 us, 有2个inputBuffer和4个outputBuffer被component持有,等等等等

设置为kDebugAll后,log中可以出现每一帧的每个状态,这里就不再赘述了。

总结:
动态设置 adb shell setprop debug.stagefright.omx-debug level 后
可以查看不同level的log 可以大致定位不同的问题。

猜你喜欢

转载自blog.csdn.net/u012188065/article/details/86756693