我是靠谱客的博主 强健大门,最近开发中收集的这篇文章主要介绍视频流分析 三6 HAL硬件抽象层7 Alsa Lib和Alsa Driver8 播放流程分析9 暂停流程分析,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

6 HAL硬件抽象层

HAL Layer代码位置:~hardwarealsa_sound*.*;
~hardwarelibhardware_legacyincludehardware_legacy*.*
~hardwaremx5xmodulesalsaalsa_imx5x.cpp
~hardwarealsa_soundAudioHardwareALSA.cpp
~hardwarealsa_soundALSAStreamOps.cpp
~hardwarealsa_soundAudioStreamOutALSA.cpp
~hardwarealsa_soundAudioStreamInALSA.cpp
~hardwarealsa_soundALSAControl.cpp
~hardwarealsa_soundALSAMixer.cpp
~hardwarelibhardware_legacyincludehardware_legacyAudioHardwareBase.h
~hardwarelibhardware_legacyincludehardware_legacyAudioHardwareInterface.h
~hardwarelibhardware_legacyincludehardware_legacyAudioPolicyInterface.h
~hardwarelibhardware_legacyincludehardware_legacyAudioPolicyManagerBase.h

7 Alsa Lib和Alsa Driver

        一般来讲,在ALSA的架构中,存在Alsa Lib和Alsa Driver,主要是用于衔接用户空间和内核空间的函数库。

Alsa Lib Layer代码位置:~externalalsa-libsrcpcm*.*
~externalalsa-libsrcpcmpcm.c
~externalalsa-libsrcpcmPcm_empty.c
~externalalsa-libsrcpcmPcm_asym.c
~externalalsa-libsrcpcmPcm_plug.c
~externalalsa-libsrcpcmpcm_dmix.c
~externalalsa-libsrcpcmPcm_hw.c
~externalalsa-libsrcpcmPcmparams.c
~externalalsa-libsrcpcmPcmpcm_direct.c
~externalalsa-libsrcpcmPcmpcm_local.h
Alsa Driver Layer代码位置:~kernel_imxsoundcore*.*
~kernel_imxsoundcorePcm_native.c
~kernel_imxsoundcorePcm_lib.c
~kernel_imxsoundcoreSoc-core.c
~kernel_imxsoundSocSoc-dapm.c

8 播放流程分析

MediaPlaybackService.java----ServiceStub—play(mService:MediaPlaybackService)
MediaPlaybackService.java----MediaPlaybackService—play(mPlayer:MultiPlayer)
MediaPlaybackService.java---- MultiPlayer—start
MediaPlayer.java----MediaPlayer—start
MediaPlayer.java----MediaPlayer—_start
Android_media_MediaPlayer.cpp---- android_media_MediaPlayer_start(mp:MediaPlayer)
Android_media_MediaPlayer.cpp----mp->start
MediaPlayer.cpp----start(mPlayer: IMediaPlayer)
IMediaPlayer.cpp----start
IMediaPlayer.cpp----remote()->transact(START, data, &reply)
IMediaPlayer.cpp----BnMediaPlayer::onTransact
IMediaPlayer.cpp----START--reply->writeInt32(start());
MediaPlayerService.cpp----MediaPlayerService::Client::start ()(p:MediaPlayerBase)
MediaPlayerService.cpp----MediaPlayerService::AudioOutput::start ()
MediaPlayerService.cpp----mTrack->pause()(mTrack:AudioTrack--TrackHandle)
AudioFlinger.cpp----AudioFlinger::TrackHandle::start()(mTrack: Track)
AudioFlinger.cpp----AudioFlinger::PlaybackThread::Track::start()
AudioFlinger.cpp----AudioSystem::startOutput
AudioFlinger.cpp----AudioSystem::startOutput
AudioSystem.cpp---- aps-> startOutput(aps:AudioPolicyService)
AudioPolicyService----mpPolicyManager->startOutput(mpPolicyManager: AudioPolicyManagerBase)
AudioPolicyManagerBase.cpp----AudioPolicyManagerBase::startOutput
AudioPolicyManagerBase.cpp----AudioPolicyManagerBase::setOutputDevice

9 暂停流程分析

MediaPlaybackService.java----ServiceStub—pause
MediaPlaybackService.java---- MediaPlaybackService—pause
MediaPlaybackService.java---- MultiPlayer—pause
MediaPlayer.java----MediaPlayer—pause
MediaPlayer.java----MediaPlayer—_pause
Android_media_MediaPlayer.cpp----android_media_MediaPlayer_pause
Android_media_MediaPlayer.cpp----mp->pause
MediaPlayer.cpp----pause
IMediaPlayer.cpp----pause
IMediaPlayer.cpp----remote()->transact(PAUSE, data, &reply)
IMediaPlayer.cpp----BnMediaPlayer::onTransact
IMediaPlayer.cpp----PAUSE--reply->writeInt32(pause());
MediaPlayerService.cpp----MediaPlayerService::Client::pause()
MediaPlayerService.cpp----MediaPlayerService::AudioOutput::pause()
MediaPlayerService.cpp----mTrack->pause()
AudioFlinger.cpp----AudioFlinger::TrackHandle::pause()
AudioFlinger.cpp----AudioFlinger::PlaybackThread::Track::pause()
AudioFlinger.cpp----AudioSystem::stopOutput
AudioSystem.cpp---- aps->stopOutput
AudioPolicyService----mpPolicyManager->stopOutput
AudioPolicyManagerBase.cpp----AudioPolicyManagerBase::stopOutput
AudioPolicyManagerBase.cpp----AudioPolicyManagerBase::setOutputDevice
从setOutputDevice函数中的代码上分析来看,暂停的过程,stopOutput实际上就是将output的device设置为0.主要的代码摘抄如下:
AudioOutputDescriptor *outputDesc = mOutputs.valueFor(output);
Device=getNewDevice(output);//作为参数传入
outputDesc->mDevice = device;//实际上未执行此句代码

此外当拔掉耳机或者断开蓝牙的情况,播放都会暂停。详情请参考

setParameters—setDeviceConnectionState函数的分析。
AudioSystem.java----AudioServiceBroadcastReceiver---- setDeviceConnectionState
AudioSystem.java----setDeviceConnectionState
Android_media_AudioSystem.cpp---- android_media_AudioSystem_setDeviceConnectionState
Android_media_AudioSystem.cpp---- check_AudioSystem_Command
AudioSystem.cpp---- setDeviceConnectionState
AudioPolicyService.cpp----setDeviceConnectionState
AudioPolicyManagerBase.cpp----setDeviceConnectionState
AudioPolicyManagerBase.cpp----setDeviceConnectionState—setParameters
AudioPolicyManagerBase.cpp----setForceUse—setParameters
AudioPolicyManagerBase.cpp----getOutput—setParameters
AudioPolicyManagerBase.cpp----startInput—setParameters
AudioPolicyManagerBase.cpp----stopInput—setParameters
AudioPolicyManagerBase.cpp---- AudioPolicyManagerBase—setParameters
AudioPolicyManagerBase.cpp---- handleA2dpConnection—setParameters
AudioPolicyManagerBase.cpp---- closeA2dpOutputs—setParameters
AudioPolicyManagerBase.cpp---- setOutputDevice—setParameters
AudioPolicyService.cpp----setParameters
AudioPolicyService.cpp----AudioPolicyService::AudioCommandThread::parametersCommand
AudioPolicyService.cpp----insertCommand_l
AudioPolicyService.cpp----AudioCommandThread::threadLoop--AudioSystem::setParameters
AudioSystem.cpp----setParameters-- af->setParameters
AudioFlinger.cpp----setParameters--mAudioHardware->setParameters
AudioHardwareALSA.h----setParameters--ALSAStreamOps::setParameters
ALSAStreamOps.cpp----setParameters
ALSAStreamOps.cpp----mParent->mALSADevice->route
Alsa_imx5x.cpp----s_route
Alsa_imx5x.cpp----setDefaultControls

最后

以上就是强健大门为你收集整理的视频流分析 三6 HAL硬件抽象层7 Alsa Lib和Alsa Driver8 播放流程分析9 暂停流程分析的全部内容,希望文章能够帮你解决视频流分析 三6 HAL硬件抽象层7 Alsa Lib和Alsa Driver8 播放流程分析9 暂停流程分析所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部