[Android Video FrameWork] OMXNodeIntance中動態控制log的一種方法

從事此行業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), 時間戳爲 21333ms, 有2個inputBuffer和4個outputBuffer被component持有,等等等等

設置爲kDebugAll後,log中可以出現每一幀的每個狀態,這裏就不再贅述了。

總結:
動態設置 adb shell setprop debug.stagefright.omx-debug level 後
可以查看不同level的log 可以大致定位不同的問題。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章