Android 4.4KitKat AudioFlinger 流程分析
AudioFlinger(AF)是一个服务,具体的启动代码在av\media\mediaserver\Main_mediaserver.cpp中:
int main(int argc, char** argv)
{
signal(SIGPIPE, SIG_IGN);
char value[PROPERTY_VALUE_MAX];
bool doLog = (property_get("ro.test_harness", value, "") > ) && (atoi(value) == );
pid_t childPid;
// FIXME The advantage of making the process containing media.log service the parent process of
// the process that contains all the other real services, is that it allows us to collect more
// detailed information such as signal numbers, stop and continue, resource usage, etc.
// But it is also more complex. Consider replacing this by independent processes, and using
// binder on death notification instead.
if (doLog && (childPid = fork()) != ) {
// media.log service
//prctl(PR_SET_NAME, (unsigned long) "media.log", 0, 0, 0);
// unfortunately ps ignores PR_SET_NAME for the main thread, so use this ugly hack
strcpy(argv[], "media.log");
sp<ProcessState> proc(ProcessState::self());
MediaLogService::instantiate();
ProcessState::self()->startThreadPool();
......
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm = defaultServiceManager();
ALOGI("ServiceManager: %p", sm.get());
AudioFlinger::instantiate();
MediaPlayerService::instantiate();
CameraService::instantiate();
AudioPolicyService::instantiate();
registerExtensions();
ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
}
}
追踪AudioFlinger::instantiate()函数的实现可到native\include\binder\BinderService.h中的
static status_t publish(bool allowIsolated = false) {
sp<IServiceManager> sm(defaultServiceManager());
return sm->addService(
String16(SERVICE::getServiceName()),
new SERVICE(), allowIsolated);
}
static void instantiate() { publish(); }
然后再往哪儿追踪代码就不知道了,没那个时间,不要在意细节,继续看AudioFlinger的构造函数:
AudioFlinger::AudioFlinger()
: BnAudioFlinger(),//初始化基类
mPrimaryHardwareDev(NULL),
mHardwareStatus(AUDIO_HW_IDLE),
mMasterVolume(1.0f),
mMasterMute(false),
mNextUniqueId(),
mMode(AUDIO_MODE_INVALID),
mBtNrecIsOff(false),
mIsLowRamDevice(true),
mIsDeviceTypeKnown(false),
mGlobalEffectEnableTime()
{
getpid_cached = getpid();
char value[PROPERTY_VALUE_MAX];
bool doLog = (property_get("ro.test_harness", value, "") > ) && (atoi(value) == );
if (doLog) {
mLogMemoryDealer = new MemoryDealer(kLogMemorySize, "LogWriters");
}
#ifdef TEE_SINK
(void) property_get("ro.debuggable", value, "");
int debuggable = atoi(value);
int teeEnabled = ;
if (debuggable) {
(void) property_get("af.tee", value, "");
teeEnabled = atoi(value);
}
if (teeEnabled & )
mTeeSinkInputEnabled = true;
if (teeEnabled & )
mTeeSinkOutputEnabled = true;
if (teeEnabled & )
mTeeSinkTrackEnabled = true;
#endif
}
设置硬件的各种属性状态。
Android 4.4KitKat AudioFlinger 流程分析的更多相关文章
- Android 4.4KitKat AudioRecord 流程分析
Android是架构分为三层: 底层 Linux Kernel 中间层 主要由C++实现 (Android 60%源码都是C++实现) 应用层 主要由JAVA开发的应用程序 应用程序执行 ...
- Android 4.4KitKat AudioTrack 流程分析
Android Audio 系统的主要内容: AudioManager:这个主要是用来管理Audio系统的,需要考虑整个系统上声音的策略问题,例如来电话铃声,短信铃声等,主要是策略上的问题. Audi ...
- Gradle之Android Gradle Plugin 主要流程分析(二)
[Android 修炼手册]Gradle 篇 -- Android Gradle Plugin 主要流程分析 预备知识 理解 gradle 的基本开发 了解 gradle task 和 plugin ...
- Cocos2d-x3.3RC0的Android编译Activity启动流程分析
本文将从引擎源代码Jni分析Cocos2d-x3.3RC0的Android Activity的启动流程,以下是具体分析. 1.引擎源代码Jni.部分Java层和C++层代码分析 watermark/2 ...
- Android FART脱壳机流程分析
本文首发于安全客 链接:https://www.anquanke.com/post/id/219094 0x1 前言 在Android平台上,程序员编写的Java代码最终将被编译成字节码在Androi ...
- Android恢复出厂设置流程分析【Android源码解析十】
最近看恢复出厂的一个问题,以前也查过这方面的流程,所以这里整理一些AP+framework层的流程: 在setting-->备份与重置--->恢复出厂设置--->重置手机---> ...
- Android 9.0 关机流程分析
极力推荐文章:欢迎收藏 Android 干货分享 阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android 本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以 ...
- 【转载】Android 中 View 绘制流程分析
创建Window 在Activity的attach方法中通过调用PolicyManager.makeNewWindo创建Window,将一个View add到WindowManager时,Window ...
- Android View 绘制刷新流程分析
Android中对View的更新有很多种方式,使用时要区分不同的应用场合.1.不使用多线程和双缓冲 这种情况最简单,一般只是希望在View发生改变时对UI进行重绘.你只需显式地调用View对 ...
随机推荐
- 【高斯消元】CDOJ1785 曜酱的线性代数课堂(三)
高斯消元求行列式板子. #include<cstdio> #include<cmath> #include<algorithm> #include<cstri ...
- udev详解
转:http://www.360doc.com/content/10/0215/11/551936_15865336.shtml 如果你使用Linux比较长时间了,那你就知道,在对待设备文件这块,Li ...
- synchronized和lock区别
synchronized 快速回顾: 1.当代码块 加上 synchrozized之后,代码会发生什么改变? 答案:有两条改变.一个是原子性(atomicity),一个是可见性(visibility) ...
- druid+spring配置
web.xml配置 <!-- Druid,监控数据库,以及WEB访问连接信息 --> <!-- 配置好后访问 http://ip:port/projectName/druid/ind ...
- SIP消息类型和消息格式
转自:http://blog.chinaunix.net/uid-1797566-id-2840904.html sip消息类型和消息格式 SIP是一个基于文本的协议,使用的是UTF-8字符集. SI ...
- CSS -- 文字竖直居中
元素的height 和 lineheight 设置为一样即可.
- 报错:this class is not key value coding-compliant for the key closeLotTextField解决方法
几种情况下都会报这种错误: 1,加载自定义的tableViewCell的时候总是死在: XInstrumentOpenCell *cell = [tableViewdequeueReusableCel ...
- Nginx" upstream prematurely closed connection while reading response header from upstream"问题排查
问题背景 我们这边是一个基于Nginx的API网关(以下标记为A),最近两天有调用方反馈,偶尔会出现502错误,我们从Nginx的error日志里看,就会发现有" upstream prem ...
- flask上传文件时request.files为空的解决办法
在做上传文件的时候遇到request.files是空 原因在于html中的表单form没有指明 enctype="multipart/form-data" <form met ...
- MyEclipse安装后需要进行的配置
摘自: http://hi.baidu.com/timesten/item/c826983a6f9654ffde2221c0 MyEclipse安装后需要进行的配置 在MyEclipse中编写Web ...