Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3520601
  • 博文数量: 864
  • 博客积分: 14125
  • 博客等级: 上将
  • 技术积分: 10634
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-27 16:53
个人简介

https://github.com/zytc2009/BigTeam_learning

文章分类

全部博文(864)

文章存档

2023年(1)

2021年(1)

2019年(3)

2018年(1)

2017年(10)

2015年(3)

2014年(8)

2013年(3)

2012年(69)

2011年(103)

2010年(357)

2009年(283)

2008年(22)

分类: Java

2010-11-20 16:38:02

Android Audio Architecture 图如下所示
Android Audio 数据流详解 - forest - forest

详细调用路径如下

1.       音频播放

示例代码

MediaPlayer mp = new MediaPlayer();

mp.setDataSource(PATH_TO_FILE);

mp.prepare();

mp.start();

 

1.1 MediaPlayer mp = new MediaPlayer()

函数调用

文件

MediaPlayer:: MediaPlayer

MediaPlayer.Java

MediaPlayer::native_setup

MediaPlayer.Java

android_media_MediaPlayer_native_setup

android_media_MediaPlayer.cpp

MediaPlayer::MediaPlayer

MediaPlayer.cpp

 

1.2 mp.setDataSource(PATH_TO_FILE)

函数调用

文件

MediaPlayer:: setDataSource

MediaPlayer.Java

MediaPlayer::setDataSource

MediaPlayer.Java

android_media_MediaPlayer_setDataSource

android_media_MediaPlayer.cpp

MediaPlayer:: setDataSource

MediaPlayer.cpp

MediaPlayer::getMediaPlayerService

MediaPlayer.cpp

IMediaPlayerService

IMediaPlayerService.h

MediaPlayerService:: [f1] 

MediaPlayerService.cpp

MediaPlayerService::create

MediaPlayerService.cpp

MediaPlayerService::Client::Client

MediaPlayerService.cpp

MediaPlayerService::Client::setDataSource

MediaPlayerService.cpp

[f2] 

MediaPlayerService.cpp

MediaPlayerService::Client::createPlayer

MediaPlayerService.cpp

createPlayer

MediaPlayerService.cpp

          PVPlayer

PVPlayer.h

MidiFile

MidiFile.cpp

VorbisPlayer

VorbisPlayer.cpp

      AudioOutput::AudioOutput

MediaPlayerService.cpp

 

1.3 mp.prepare()

函数调用

文件

MediaPlayer:: prepare

MediaPlayer.Java

MediaPlayer:: prepare

MediaPlayer.Java

android_media_MediaPlayer_ prepare

android_media_MediaPlayer.cpp

MediaPlayer:: prepare

MediaPlayer.cpp

PVPlayer:: prepare

PVPlayer.h

MidiFile:: prepare

MidiFile.cpp

VorbisPlayer:: prepare

VorbisPlayer.cpp

  VorbisPlayer::createOutputTrack

VorbisPlayer.cpp

    AudioOutput::open

MediaPlayerService.cpp

      AudioTrack::AudioTrack

AudioTrack.cpp

        AudioSystem::get_audio_flinger

AudioSystem.cpp

        AudioFlinger::createTrack

AudioFlinger.cpp

 

1.4 mp.start()

函数调用

文件

MediaPlayer:: start

MediaPlayer.Java

MediaPlayer:: start

MediaPlayer.Java

android_media_MediaPlayer_ start

android_media_MediaPlayer.cpp

MediaPlayer:: start

MediaPlayer.cpp

PVPlayer:: start

PVPlayer.h

MidiFile:: p start

MidiFile.cpp

VorbisPlayer:: start

VorbisPlayer.cpp

  AudioTrack::start

AudioTrack.cpp


 [f1]systemserver进程创建,在文件system_init.cpp里的函数system_init()调用MediaPlayerService::instantiate创建

 [f2]返回3player

PV_PLAYER:播放mp3

SONIVOX_PLAYER:播放midi

VORBIS_PLAYER:播放ogg,


简单说来,轨迹如下:

Java端发起调用,MediaPlayer会转至MediaPlayerService, 然后会调用相应的解码工具解码后创建AudioTrack,所有待输出的AudioTrack在AudioFlinger::AudioMixer里合 成,然后通过AudioHAL(AudioHardwareInterface的实际实现者)传至实际的硬件来实现播放

阅读(1357) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~