函數(shù)調(diào)用過(guò)程 從AudioTrack開(kāi)始跟蹤,。 AudioTrack::set --> output = AudioSystem::getOutput ---------AudioTrack.cpp --> aps->getOutput ---------AudioSystem.cpp --> ( mpAudioPolicy->get_output --------AudioPolicyService.cpp <==> ap_get_output ) --> ( lap->apm->getOutput ---------audio_policy_hal.cpp <== >AudioPolicyManagerBase::getOutput ) --> ( mpClientInterface->openOutput ------AudioPolicyManagerBase.cpp<==> aps_open_output ) --> af->openOutput ----------AudioPolicyService.cpp -->AudioFlinger::openOutput -->hwDevHal->open_output_stream -----------AudioFlinger.cpp <==> adev_open_output_stream) --> 在此最終獲得到了 *stream_out = &out->stream 。 -----------tinyalsa_hal.c 這里會(huì)返回到AudioFlinger,,這里最終看到AudioFlinger::openOutput函數(shù)的結(jié)尾你會(huì)發(fā)現(xiàn)output其實(shí)是通過(guò)audio_io_handle_t id = nextUniqueId();獲得的一個(gè)整數(shù),,在 if (status == NO_ERROR && outStream != NULL)條件成立后會(huì)走以下關(guān)鍵幾步: AudioStreamOut *output = new AudioStreamOut(outHwDev, outStream, flags); thread = new MixerThread(this, output, id, *pDevices); mPlaybackThreads.add(id, thread); return id; 其實(shí)就是將從hal層獲取到的stream_out作為參數(shù)new一個(gè)AudioStreamOut 對(duì)象指針,再將output指針作為參數(shù)new一個(gè)mixer thread,,最終將id 和 thread以鍵值對(duì)的關(guān)系保存,。這個(gè)最終會(huì)在 AudioFlinger::createTrack()函數(shù)中用到調(diào)用語(yǔ)句:PlaybackThread *thread = checkPlaybackThread_l(output);
|
|