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, "0") > 0) && (atoi(value) == 1);    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()) != 0) {        // 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[0], "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(1),      mMode(AUDIO_MODE_INVALID),      mBtNrecIsOff(false),      mIsLowRamDevice(true),      mIsDeviceTypeKnown(false),      mGlobalEffectEnableTime(0){    getpid_cached = getpid();    char value[PROPERTY_VALUE_MAX];    bool doLog = (property_get("ro.test_harness", value, "0") > 0) && (atoi(value) == 1);    if (doLog) {        mLogMemoryDealer = new MemoryDealer(kLogMemorySize, "LogWriters");    }#ifdef TEE_SINK    (void) property_get("ro.debuggable", value, "0");    int debuggable = atoi(value);    int teeEnabled = 0;    if (debuggable) {        (void) property_get("af.tee", value, "0");        teeEnabled = atoi(value);    }    if (teeEnabled & 1)        mTeeSinkInputEnabled = true;    if (teeEnabled & 2)        mTeeSinkOutputEnabled = true;    if (teeEnabled & 4)        mTeeSinkTrackEnabled = true;#endif}

设置硬件的各种属性状态。

更多相关文章

  1. android短信获取小代码
  2. Android(安卓)App 性能优化
  3. Android(安卓)4.0 截屏(Screenshot)代码流程小结
  4. android Looper学习
  5. Android(安卓)远程图片获取和本地缓存(三)
  6. Android实现导航栏的左右滑动效果
  7. android TextView 垂直自动滚动字幕实现
  8. android 串口jni 开发流程
  9. Android源码修改后的语音录音代码

随机推荐

  1. 剑指Offer(六)旋转数组的最小数字(Java版 )
  2. 数据结构学习----线性表(Java版的实现)
  3. Ubuntu 中 java 环境 (sunjdk) 的配置 (
  4. 为什么gradle不会覆盖不同Android风格的J
  5. 最近一个月的面试记录总结
  6. java_easyui体系之更换主题
  7. Zookeeper官网文档—第三章 2.Zookeeper
  8. Java Mail发送邮件
  9. php 调用java 接口
  10. Java虚拟机:类的初始化