[RK3288][Android6.0] 调试笔记 --- 关闭音频播放停止后进入Standby功能

Platform: ROCKCHIP
OS: Android 6.0
Kernel: 3.10.92

Android系统默认播放停止后3秒会进入Standby模式以节省电源.

需求:
    禁止进入Standby

HAL层虽然提供了Standby接口,但是不能直接屏蔽掉, 因为里面有pcm_close()
和播放的pcm_start()配对.

解决方法:
    增加standby的延迟时间,默认3秒,可以改成一天或者更久.

[kris@:~/rk3288/frameworks/av]$ g df
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 08fa70d..a5244d3 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -86,7 +86,7 @@ class ServerProxy;
 // This is typically due to audio mixer and resampler limitations.
 #define FCC_8 8     // FCC_8 = Fixed Channel Count 8
 
-static const nsecs_t kDefaultStandbyTimeInNsecs = seconds(3);
+static const nsecs_t kDefaultStandbyTimeInNsecs = seconds(60*60*24);



也可以通过property来设置:
void AudioFlinger::onFirstRef()
{
    int rc = 0;

    Mutex::Autolock _l(mLock);

    /* TODO: move all this work into an Init() function */
    char val_str[PROPERTY_VALUE_MAX] = { 0 };
    if (property_get("ro.audio.flinger_standbytime_ms", val_str, NULL) >= 0) {
        uint32_t int_val;
        if (1 == sscanf(val_str, "%u", &int_val)) {
            mStandbyTimeInNsecs = milliseconds(int_val);
            ALOGI("Using %u mSec as standby time.", int_val);
        } else {
            mStandbyTimeInNsecs = kDefaultStandbyTimeInNsecs;
            ALOGI("Using default %u mSec as standby time.",
                    (uint32_t)(mStandbyTimeInNsecs / 1000000));
        }
    }

    mPatchPanel = new PatchPanel(this);

    mMode = AUDIO_MODE_NORMAL;
}
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页