SlideShare una empresa de Scribd logo
1 de 13
안드로이드의 모든것 분석과 포팅 정리




Android Audio System
(AudioHardware class)




                                  박철희
                           1/10
1.AudioHardware class 위치 및 역활      안드로이드의 모든것 분석과 포팅 정리




Application                      역할:
Framework

                                 Device control
                                 (play,stop,routing)

Native
Framework




HAL




Kernel



                                                  2/10
2.AudioHardware class구조(msm7x30)                                                 안드로이드의 모든것 분석과 포팅 정리



                                                                               setParameters, getParameters
                                                                               openOutputStream,
                                               AudioHardwareInterface          openOutputSession,
      setVoiceVolume ,                                                         openInputStream
      setMode,
      setMasterVolume,
      openOutputStream,
      openOutputSession,
                                                 AudioHardwareBase             isModeInCall, isInCall
      openInputStream




   AudioStreamOut                                   AudioHardware                                  AudioStreamIn



                                    AudioStreamOutMSM72xx
                                                                 AudioStreamInMSM72xx

                                   AudioSessionOutMSM7xxx



                                                                                setParameters,
setParameters,                                                                  getParameters,
getParameters,                                                                  read // read audio buffer in from audio
Write // write audio buffer to driver.                                          driver
Returns number of bytes written
                                                                                                        3
3.AudioHardware class 초기화                                                         안드로이드의 모든것 분석과 포팅 정리



    1)AudioHardware class
   AudioFlinger.cpp
   AudioFlinger::AudioFlinger()
     : BnAudioFlinger(),
        mAudioHardware(0), mFmEnabled(false), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1)
   {

                 AudioHardwareInterface* mAudioHardware = AudioHardwareInterface::create();
             …
   }



AudioHardwareinterface.cpp                                                 AudioHardware.cpp(7x30)
AudioHardwareInterface* AudioHardwareInterface::create()                   AudioHardware::AudioHardware() :
{                                                                          {
    hw = createAudioHardware();                                             control =
}                                                                          msm_mixer_open("/dev/snd/controlC0", 0);


                                                                           //장착된 device들을 가져와서
                                                                           device_list 구조체에 넣는다.(소스 참조)
   AudioHardware.cpp(7x30)
   extern "C" AudioHardwareInterface* createAudioHardware(void)            //이 device_list 는 device id를 구할 때
   {                                                                       사용된다.
     return new AudioHardware();                                           }
   }


                                                                                                       4/10
3.AudioHardware class 초기화                                                          안드로이드의 모든것 분석과 포팅 정리



 2) AudioStreamOutMSM72xx
AudioPolicyManagerBase.cpp
AudioPolicyManagerBase::AudioPolicyManagerBase(AudioPolicyClientInterface *clientInterface)
{
  …
  mHardwareOutput = mpClientInterface->openOutput(…);
}

AudioFlinger.cpp
int AudioFlinger::openOutput
{
 AudioStreamOut *output = mAudioHardware->openOutputStream(*pDevices,…)

}
AudioHardware.cpp(7x30)
AudioStreamOut* AudioHardware::openOutputStream
{
  …
 AudioStreamOutMSM72xx* out = new AudioStreamOutMSM72xx();
 status_t lStatus = out->set(this, devices, format, channels, sampleRate);
}

AudioHardware.cpp(7x30)
status_t AudioHardware::AudioStreamOutMSM72xx::set
{
 if (pFormat) *pFormat = lFormat;
    if (pChannels) *pChannels = lChannels;
    if (pRate) *pRate = lRate;
    mDevices = devices;
                                                                                              5/10
3.AudioHardware class 초기화                                                          안드로이드의 모든것 분석과 포팅 정리



      3) AudioStreamInMSM72xx
AudioPolicyManagerBase.cpp
audio_io_handle_t AudioPolicyManagerBase::getInput(…){

     input = mpClientInterface->openInput(&inputDesc->mDevice,…);
}


AudioPolicyService.cpp
audio_io_handle_t AudioPolicyService::openInput(…)
{
  sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
  return af->openInput(pDevices, pSamplingRate, (uint32_t *)pFormat, pChannels, acoustics);
}

int AudioFlinger::openInput(…)                                          status_t AudioHardware::AudioStreamInMSM72xx::set
{                                                                       {
  …                                                                       //각 입력되는 format에 맞게
  AudioStreamIn *input = mAudioHardware->                                mDevices, mFormat, mChannels 등을 설정 함.
                     openInputStream(*pDevices,…);                       else if(*pFormat == AUDIO_HW_IN_FORMAT)
}                                                                       {
                                                                          ..
                                                                          mDevices = devices;
    AudioStreamIn* AudioHardware::openInputStream(…)                      mFormat = AUDIO_HW_IN_FORMAT;
    {                                                                     mChannels = *pChannels;
     AudioStreamInMSM72xx* in = new AudioStreamInMSM72xx();               …
      status_t lStatus = in->set(this, devices, format, channels,
                             sampleRate, acoustic_flags);
    }                                                                   }

                                                                                                       6/10
4. AudioHardware class method 분석                                        안드로이드의 모든것 분석과 포팅 정리


 1) setVoiceVolume
PhoneWindowManager.java
handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode);


 void handleVolumeKey(int stream, int keycode) {
audioService.adjustStreamVolume(stream,
      keycode == KeyEvent.KEYCODE_VOLUME_UP ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER,0);
}


AudioService.java
public void adjustStreamVolume{
sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME, STREAM_VOLUME_ALIAS[streamType], SENDMSG_NOOP, 0, 0,
                streamState, 0);
}

public void handleMessage(Message msg) {
 case MSG_SET_SYSTEM_VOLUME:
             setSystemVolume((VolumeStreamState) msg.obj);
             break;
}

private void setSystemVolume(VolumeStreamState streamState){
 setStreamVolumeIndex(streamState.mStreamType, streamState.mIndex);
}

private void setStreamVolumeIndex(int stream, int index) {
     AudioSystem.setStreamVolumeIndex(stream, (index + 5)/10);
}
                                                                                        7/10
4. AudioHardware class method 분석                                                      안드로이드의 모든것 분석과 포팅 정리

Android_media_AudioSystem.cpp
android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env, jobject thiz, jint stream, jint index)
{
  return check_AudioSystem_Command(
       AudioSystem::setStreamVolumeIndex(static_cast <AudioSystem::stream_type>(stream), index));
}

AudioSystem.cpp
status_t AudioSystem::setStreamVolumeIndex(stream_type stream, int index)
{
   const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
   if (aps == 0) return PERMISSION_DENIED;
   return aps->setStreamVolumeIndex(stream, index);
}

AudioPolicyService.cpp
status_t AudioPolicyService::setStreamVolumeIndex()
{
 return mpPolicyManager->setStreamVolumeIndex(stream, index);
}

AudioPolicyManagerBase.cpp
status_t AudioPolicyManagerBase::setStreamVolumeIndex(){
status_t volStatus = checkAndSetVolume(stream, index, mOutputs.keyAt(i), mOutputs.valueAt(i)->device());
}

status_t AudioPolicyManagerBase::checkAndSetVolume{
 if (stream == AudioSystem::VOICE_CALL ||
       stream == AudioSystem::BLUETOOTH_SCO) {
 mpClientInterface->setVoiceVolume(voiceVolume, delayMs);
}

                                                                                                           8/10
4. AudioHardware class method 분석                                         안드로이드의 모든것 분석과 포팅 정리

AudioPolicyService.cpp
status_t AudioPolicyService::setVoiceVolume(float volume, int delayMs)
{
   return mAudioCommandThread->voiceVolumeCommand(volume, delayMs);
}

status_t AudioPolicyService::AudioCommandThread::voiceVolumeCommand
{
 command->mCommand = SET_VOICE_VOLUME;
}

bool AudioPolicyService::AudioCommandThread::threadLoop()
{
 case SET_VOICE_VOLUME: {
 command->mStatus = AudioSystem::setVoiceVolume(data->mVolume);
}

AudioSystem.cpp
status_t AudioSystem::setVoiceVolume(float value)
{
   const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
   if (af == 0) return PERMISSION_DENIED;
   return af->setVoiceVolume(value);
}

AudioFlinger.cpp
status_t AudioFlinger::setVoiceVolume(float value)
{
 status_t ret = mAudioHardware->setVoiceVolume(value);
}


                                                                                   9/10
4. AudioHardware class method 분석                                      안드로이드의 모든것 분석과 포팅 정리

AudioHardware.cpp
status_t AudioHardware::setVoiceVolume(float v)
{
  if(msm_set_voice_rx_vol(vol)) {
      LOGE("msm_set_voice_rx_vol(%d) failed errno = %d",vol,errno);
      return -1;
    }
}

Hw.c(vendor/qcom…)
{
  int msm_set_voice_rx_vol(int volume)
  {
             struct snd_ctl_elem_value val;

             val.id.numid = NUMID_VOICE_VOL;
             val.value.integer.value[0] = DIR_RX;
             val.value.integer.value[1] = volume;

             return msm_mixer_elem_write(&val);
    }
}

static int msm_mixer_elem_write(struct snd_ctl_elem_value *val)
{
      rc = ioctl(control->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, val);
}




                                                                               10/10
4. AudioHardware class method 분석                                                        안드로이드의 모든것 분석과 포팅 정리


 2) setVolume
QwertyKeyListener.java
public boolean onKeyDown{
return super.onKeyDown(view, content, keyCode, event);
}

phoneWindow.java
protected boolean onKeyDown{

audioManager.adjustSuggestedStreamVolume(
                keyCode == KeyEvent.KEYCODE_VOLUME_UP
                    ? AudioManager.ADJUST_RAISE
                    : AudioManager.ADJUST_LOWER,
                mVolumeControlStreamType,
               AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);}




AudioManager.java
public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) {
     IAudioService service = getService();
     try {
        service.adjustSuggestedStreamVolume(direction, suggestedStreamType, flags);
     } catch (RemoteException e) {
        Log.e(TAG, "Dead object in adjustVolume", e);
     }
  }


                                                                                                 11/10
4. AudioHardware class method 분석                                                   안드로이드의 모든것 분석과 포팅 정리


AudioService.java
public void adjustSuggestedStreamVolume{
adjustStreamVolume(streamType, direction, flags);
}

public void adjustStreamVolume{

sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME,
                       STREAM_VOLUME_ALIAS[streamType], SENDMSG_NOOP, 0, 0,
                       streamState, 0);


 AudioService.java
 public void handleMessage(Message msg) {
    switch (baseMsgWhat) {
            case MSG_SET_SYSTEM_VOLUME:
              setSystemVolume((VolumeStreamState) msg.obj);
              break;
 }
                            AudioFlinger의 setStreamVolume을 호출해서 Volume setting함.


 status_t AudioFlinger::PlaybackThread::setStreamVolume(int stream, float value)
 {
  mStreamTypes[stream].volume = value;
 }

                  AudioFlinger::MixerThread::threadLoop()에서 prepareTracks_l
                  이 수행 됨.


                                                                                            12/10
4. AudioHardware class method 분석                                            안드로이드의 모든것 분석과 포팅 정리


uint32_t AudioFlinger::MixerThread::prepareTracks_l
{

    float typeVolume = mStreamTypes[track->type()].volume; setStreamVolume 에서 설정한 volume값을 가져와서

    //volume 값 설정
    float v = masterVolume * typeVolume;
    vl = (uint32_t)(v * cblk->volume[0]) << 12;
    vr = (uint32_t)(v * cblk->volume[1]) << 12;

    param = AudioMixer::VOLUME;

    //AudioMixer.cpp의 setparameter에서 처리 해줌.
    mAudioMixer->setParameter(param, AudioMixer::VOLUME0, (void *)left);
    mAudioMixer->setParameter(param, AudioMixer::VOLUME1, (void *)right);
    mAudioMixer->setParameter(param, AudioMixer::AUXLEVEL, (void *)aux);
    …
}




                                                                                         13/10

Más contenido relacionado

La actualidad más candente

Android Multimedia Framework
Android Multimedia FrameworkAndroid Multimedia Framework
Android Multimedia FrameworkPicker Weng
 
Android media framework overview
Android media framework overviewAndroid media framework overview
Android media framework overviewJerrin George
 
ExoPlayer for Application developers
ExoPlayer for Application developersExoPlayer for Application developers
ExoPlayer for Application developersHassan Abid
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)Nanik Tolaram
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on AndroidGary Bisson
 
MediaPlayer Playing Flow
MediaPlayer Playing FlowMediaPlayer Playing Flow
MediaPlayer Playing FlowJavid Hsu
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia FrameworkOpersys inc.
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Opersys inc.
 

La actualidad más candente (20)

Android Multimedia Framework
Android Multimedia FrameworkAndroid Multimedia Framework
Android Multimedia Framework
 
Android media framework overview
Android media framework overviewAndroid media framework overview
Android media framework overview
 
Embedded Android : System Development - Part IV
Embedded Android : System Development - Part IVEmbedded Android : System Development - Part IV
Embedded Android : System Development - Part IV
 
ExoPlayer for Application developers
ExoPlayer for Application developersExoPlayer for Application developers
ExoPlayer for Application developers
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 
Accessing Hardware on Android
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on Android
 
Low Level View of Android System Architecture
Low Level View of Android System ArchitectureLow Level View of Android System Architecture
Low Level View of Android System Architecture
 
MediaPlayer Playing Flow
MediaPlayer Playing FlowMediaPlayer Playing Flow
MediaPlayer Playing Flow
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
Embedded Android : System Development - Part I
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part I
 
Android Things : Building Embedded Devices
Android Things : Building Embedded DevicesAndroid Things : Building Embedded Devices
Android Things : Building Embedded Devices
 
Android Binder: Deep Dive
Android Binder: Deep DiveAndroid Binder: Deep Dive
Android Binder: Deep Dive
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Android Multimedia Support
Android Multimedia SupportAndroid Multimedia Support
Android Multimedia Support
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
 
I2c drivers
I2c driversI2c drivers
I2c drivers
 
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)
 

Destacado

Android Audio & OpenSL
Android Audio & OpenSLAndroid Audio & OpenSL
Android Audio & OpenSLYoss Cohen
 
Surface flingerservice(서피스 출력 요청 jb)
Surface flingerservice(서피스 출력 요청 jb)Surface flingerservice(서피스 출력 요청 jb)
Surface flingerservice(서피스 출력 요청 jb)fefe7270
 
08 android multimedia_framework_overview
08 android multimedia_framework_overview08 android multimedia_framework_overview
08 android multimedia_framework_overviewArjun Reddy
 
Android Tools for Qualcomm Snapdragon Processors
Android Tools for Qualcomm Snapdragon Processors Android Tools for Qualcomm Snapdragon Processors
Android Tools for Qualcomm Snapdragon Processors Qualcomm Developer Network
 
USB Host APIで遊んでみた
USB Host APIで遊んでみたUSB Host APIで遊んでみた
USB Host APIで遊んでみたMakoto Yamazaki
 
Bluetooth Controlled High Power Audio Amplifier- Final Presentaion
Bluetooth Controlled High Power Audio Amplifier- Final PresentaionBluetooth Controlled High Power Audio Amplifier- Final Presentaion
Bluetooth Controlled High Power Audio Amplifier- Final PresentaionSagar Mali
 
Android Gadgets, Bluetooth Low Energy, and the WunderBar
Android Gadgets, Bluetooth Low Energy, and the WunderBarAndroid Gadgets, Bluetooth Low Energy, and the WunderBar
Android Gadgets, Bluetooth Low Energy, and the WunderBarrelayr
 
Android Training (Media)
Android Training (Media)Android Training (Media)
Android Training (Media)Khaled Anaqwa
 
Android audio system(오디오 출력-트랙활성화)
Android audio system(오디오 출력-트랙활성화)Android audio system(오디오 출력-트랙활성화)
Android audio system(오디오 출력-트랙활성화)fefe7270
 
Camera camcorder framework overview(ginger bread)
Camera camcorder framework overview(ginger bread)Camera camcorder framework overview(ginger bread)
Camera camcorder framework overview(ginger bread)fefe7270
 
Surface flingerservice(서피스플링거서비스초기화 ics)
Surface flingerservice(서피스플링거서비스초기화 ics)Surface flingerservice(서피스플링거서비스초기화 ics)
Surface flingerservice(서피스플링거서비스초기화 ics)fefe7270
 
Surface flingerservice(서피스플링거서비스초기화)
Surface flingerservice(서피스플링거서비스초기화)Surface flingerservice(서피스플링거서비스초기화)
Surface flingerservice(서피스플링거서비스초기화)fefe7270
 
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)fefe7270
 
Surface flingerservice(서피스 플링거 연결 jb)
Surface flingerservice(서피스 플링거 연결 jb)Surface flingerservice(서피스 플링거 연결 jb)
Surface flingerservice(서피스 플링거 연결 jb)fefe7270
 
Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)fefe7270
 
2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...
2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...
2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...Омские ИТ-субботники
 

Destacado (16)

Android Audio & OpenSL
Android Audio & OpenSLAndroid Audio & OpenSL
Android Audio & OpenSL
 
Surface flingerservice(서피스 출력 요청 jb)
Surface flingerservice(서피스 출력 요청 jb)Surface flingerservice(서피스 출력 요청 jb)
Surface flingerservice(서피스 출력 요청 jb)
 
08 android multimedia_framework_overview
08 android multimedia_framework_overview08 android multimedia_framework_overview
08 android multimedia_framework_overview
 
Android Tools for Qualcomm Snapdragon Processors
Android Tools for Qualcomm Snapdragon Processors Android Tools for Qualcomm Snapdragon Processors
Android Tools for Qualcomm Snapdragon Processors
 
USB Host APIで遊んでみた
USB Host APIで遊んでみたUSB Host APIで遊んでみた
USB Host APIで遊んでみた
 
Bluetooth Controlled High Power Audio Amplifier- Final Presentaion
Bluetooth Controlled High Power Audio Amplifier- Final PresentaionBluetooth Controlled High Power Audio Amplifier- Final Presentaion
Bluetooth Controlled High Power Audio Amplifier- Final Presentaion
 
Android Gadgets, Bluetooth Low Energy, and the WunderBar
Android Gadgets, Bluetooth Low Energy, and the WunderBarAndroid Gadgets, Bluetooth Low Energy, and the WunderBar
Android Gadgets, Bluetooth Low Energy, and the WunderBar
 
Android Training (Media)
Android Training (Media)Android Training (Media)
Android Training (Media)
 
Android audio system(오디오 출력-트랙활성화)
Android audio system(오디오 출력-트랙활성화)Android audio system(오디오 출력-트랙활성화)
Android audio system(오디오 출력-트랙활성화)
 
Camera camcorder framework overview(ginger bread)
Camera camcorder framework overview(ginger bread)Camera camcorder framework overview(ginger bread)
Camera camcorder framework overview(ginger bread)
 
Surface flingerservice(서피스플링거서비스초기화 ics)
Surface flingerservice(서피스플링거서비스초기화 ics)Surface flingerservice(서피스플링거서비스초기화 ics)
Surface flingerservice(서피스플링거서비스초기화 ics)
 
Surface flingerservice(서피스플링거서비스초기화)
Surface flingerservice(서피스플링거서비스초기화)Surface flingerservice(서피스플링거서비스초기화)
Surface flingerservice(서피스플링거서비스초기화)
 
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
Surface flingerservice(그래픽 공유 버퍼 생성 및 등록)
 
Surface flingerservice(서피스 플링거 연결 jb)
Surface flingerservice(서피스 플링거 연결 jb)Surface flingerservice(서피스 플링거 연결 jb)
Surface flingerservice(서피스 플링거 연결 jb)
 
Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)Surface flingerservice(서피스 상태 변경 jb)
Surface flingerservice(서피스 상태 변경 jb)
 
2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...
2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...
2016-08-20 01 Дмитрий Рабецкий, Сергей Сорокин. Опыт работы с Android Medi...
 

Similar a Android audio system(audio_hardwareinterace)

The unconventional devices for the Android video streaming
The unconventional devices for the Android video streamingThe unconventional devices for the Android video streaming
The unconventional devices for the Android video streamingMatteo Bonifazi
 
망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18종인 전
 
Developing natural user interface applications with real sense devices
Developing natural user interface applications with real sense devicesDeveloping natural user interface applications with real sense devices
Developing natural user interface applications with real sense devicespeteohanlon
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsashukiller7
 
The unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidThe unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidAlessandro Martellucci
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...Publicis Sapient Engineering
 
CMU monitoring tool - proto
CMU monitoring tool - protoCMU monitoring tool - proto
CMU monitoring tool - protoGoutam Adwant
 
9 password security
9   password security9   password security
9 password securitydrewz lin
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
 
Automating Analysis and Exploitation of Embedded Device Firmware
Automating Analysis and Exploitation of Embedded Device FirmwareAutomating Analysis and Exploitation of Embedded Device Firmware
Automating Analysis and Exploitation of Embedded Device FirmwareMalachi Jones
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15종인 전
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
Kinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialKinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialTsukasa Sugiura
 

Similar a Android audio system(audio_hardwareinterace) (20)

Integrando sua app Android com Chromecast
Integrando sua app Android com ChromecastIntegrando sua app Android com Chromecast
Integrando sua app Android com Chromecast
 
The unconventional devices for the Android video streaming
The unconventional devices for the Android video streamingThe unconventional devices for the Android video streaming
The unconventional devices for the Android video streaming
 
망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18망고100 보드로 놀아보자 18
망고100 보드로 놀아보자 18
 
Developing natural user interface applications with real sense devices
Developing natural user interface applications with real sense devicesDeveloping natural user interface applications with real sense devices
Developing natural user interface applications with real sense devices
 
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbsSystem Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
System Calls.pptxnsjsnssbhsbbebdbdbshshsbshsbbs
 
The unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidThe unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in Android
 
Android For All The Things
Android For All The ThingsAndroid For All The Things
Android For All The Things
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
 
srgoc
srgocsrgoc
srgoc
 
CMU monitoring tool - proto
CMU monitoring tool - protoCMU monitoring tool - proto
CMU monitoring tool - proto
 
9 password security
9   password security9   password security
9 password security
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
MPI
MPIMPI
MPI
 
Scmad Chapter13
Scmad Chapter13Scmad Chapter13
Scmad Chapter13
 
Os lab final
Os lab finalOs lab final
Os lab final
 
Automating Analysis and Exploitation of Embedded Device Firmware
Automating Analysis and Exploitation of Embedded Device FirmwareAutomating Analysis and Exploitation of Embedded Device Firmware
Automating Analysis and Exploitation of Embedded Device Firmware
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
IOMX in Android
IOMX in AndroidIOMX in Android
IOMX in Android
 
Kinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialKinect v2 Introduction and Tutorial
Kinect v2 Introduction and Tutorial
 

Más de fefe7270

Surface flingerservice(서피스플링거서비스초기화 jb)
Surface flingerservice(서피스플링거서비스초기화 jb)Surface flingerservice(서피스플링거서비스초기화 jb)
Surface flingerservice(서피스플링거서비스초기화 jb)fefe7270
 
Surface flingerservice(서피스 플링거 연결 ics)
Surface flingerservice(서피스 플링거 연결 ics)Surface flingerservice(서피스 플링거 연결 ics)
Surface flingerservice(서피스 플링거 연결 ics)fefe7270
 
Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)fefe7270
 
Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)fefe7270
 
Stagefright recorder part1
Stagefright recorder part1Stagefright recorder part1
Stagefright recorder part1fefe7270
 
C++정리 스마트포인터
C++정리 스마트포인터C++정리 스마트포인터
C++정리 스마트포인터fefe7270
 
Android audio system(pcm데이터출력요청-서비스클라이언트)
Android audio system(pcm데이터출력요청-서비스클라이언트)Android audio system(pcm데이터출력요청-서비스클라이언트)
Android audio system(pcm데이터출력요청-서비스클라이언트)fefe7270
 

Más de fefe7270 (7)

Surface flingerservice(서피스플링거서비스초기화 jb)
Surface flingerservice(서피스플링거서비스초기화 jb)Surface flingerservice(서피스플링거서비스초기화 jb)
Surface flingerservice(서피스플링거서비스초기화 jb)
 
Surface flingerservice(서피스 플링거 연결 ics)
Surface flingerservice(서피스 플링거 연결 ics)Surface flingerservice(서피스 플링거 연결 ics)
Surface flingerservice(서피스 플링거 연결 ics)
 
Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)Surface flingerservice(서피스 상태 변경 및 출력 요청)
Surface flingerservice(서피스 상태 변경 및 출력 요청)
 
Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)Surface flingerservice(서피스 플링거 연결)
Surface flingerservice(서피스 플링거 연결)
 
Stagefright recorder part1
Stagefright recorder part1Stagefright recorder part1
Stagefright recorder part1
 
C++정리 스마트포인터
C++정리 스마트포인터C++정리 스마트포인터
C++정리 스마트포인터
 
Android audio system(pcm데이터출력요청-서비스클라이언트)
Android audio system(pcm데이터출력요청-서비스클라이언트)Android audio system(pcm데이터출력요청-서비스클라이언트)
Android audio system(pcm데이터출력요청-서비스클라이언트)
 

Último

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

Android audio system(audio_hardwareinterace)

  • 1. 안드로이드의 모든것 분석과 포팅 정리 Android Audio System (AudioHardware class) 박철희 1/10
  • 2. 1.AudioHardware class 위치 및 역활 안드로이드의 모든것 분석과 포팅 정리 Application 역할: Framework Device control (play,stop,routing) Native Framework HAL Kernel 2/10
  • 3. 2.AudioHardware class구조(msm7x30) 안드로이드의 모든것 분석과 포팅 정리 setParameters, getParameters openOutputStream, AudioHardwareInterface openOutputSession, setVoiceVolume , openInputStream setMode, setMasterVolume, openOutputStream, openOutputSession, AudioHardwareBase isModeInCall, isInCall openInputStream AudioStreamOut AudioHardware AudioStreamIn AudioStreamOutMSM72xx AudioStreamInMSM72xx AudioSessionOutMSM7xxx setParameters, setParameters, getParameters, getParameters, read // read audio buffer in from audio Write // write audio buffer to driver. driver Returns number of bytes written 3
  • 4. 3.AudioHardware class 초기화 안드로이드의 모든것 분석과 포팅 정리 1)AudioHardware class AudioFlinger.cpp AudioFlinger::AudioFlinger() : BnAudioFlinger(), mAudioHardware(0), mFmEnabled(false), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1) { AudioHardwareInterface* mAudioHardware = AudioHardwareInterface::create(); … } AudioHardwareinterface.cpp AudioHardware.cpp(7x30) AudioHardwareInterface* AudioHardwareInterface::create() AudioHardware::AudioHardware() : { { hw = createAudioHardware(); control = } msm_mixer_open("/dev/snd/controlC0", 0); //장착된 device들을 가져와서 device_list 구조체에 넣는다.(소스 참조) AudioHardware.cpp(7x30) extern "C" AudioHardwareInterface* createAudioHardware(void) //이 device_list 는 device id를 구할 때 { 사용된다. return new AudioHardware(); } } 4/10
  • 5. 3.AudioHardware class 초기화 안드로이드의 모든것 분석과 포팅 정리 2) AudioStreamOutMSM72xx AudioPolicyManagerBase.cpp AudioPolicyManagerBase::AudioPolicyManagerBase(AudioPolicyClientInterface *clientInterface) { … mHardwareOutput = mpClientInterface->openOutput(…); } AudioFlinger.cpp int AudioFlinger::openOutput { AudioStreamOut *output = mAudioHardware->openOutputStream(*pDevices,…) } AudioHardware.cpp(7x30) AudioStreamOut* AudioHardware::openOutputStream { … AudioStreamOutMSM72xx* out = new AudioStreamOutMSM72xx(); status_t lStatus = out->set(this, devices, format, channels, sampleRate); } AudioHardware.cpp(7x30) status_t AudioHardware::AudioStreamOutMSM72xx::set { if (pFormat) *pFormat = lFormat; if (pChannels) *pChannels = lChannels; if (pRate) *pRate = lRate; mDevices = devices; 5/10
  • 6. 3.AudioHardware class 초기화 안드로이드의 모든것 분석과 포팅 정리 3) AudioStreamInMSM72xx AudioPolicyManagerBase.cpp audio_io_handle_t AudioPolicyManagerBase::getInput(…){ input = mpClientInterface->openInput(&inputDesc->mDevice,…); } AudioPolicyService.cpp audio_io_handle_t AudioPolicyService::openInput(…) { sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); return af->openInput(pDevices, pSamplingRate, (uint32_t *)pFormat, pChannels, acoustics); } int AudioFlinger::openInput(…) status_t AudioHardware::AudioStreamInMSM72xx::set { { … //각 입력되는 format에 맞게 AudioStreamIn *input = mAudioHardware-> mDevices, mFormat, mChannels 등을 설정 함. openInputStream(*pDevices,…); else if(*pFormat == AUDIO_HW_IN_FORMAT) } { .. mDevices = devices; AudioStreamIn* AudioHardware::openInputStream(…) mFormat = AUDIO_HW_IN_FORMAT; { mChannels = *pChannels; AudioStreamInMSM72xx* in = new AudioStreamInMSM72xx(); … status_t lStatus = in->set(this, devices, format, channels, sampleRate, acoustic_flags); } } 6/10
  • 7. 4. AudioHardware class method 분석 안드로이드의 모든것 분석과 포팅 정리 1) setVoiceVolume PhoneWindowManager.java handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode); void handleVolumeKey(int stream, int keycode) { audioService.adjustStreamVolume(stream, keycode == KeyEvent.KEYCODE_VOLUME_UP ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER,0); } AudioService.java public void adjustStreamVolume{ sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME, STREAM_VOLUME_ALIAS[streamType], SENDMSG_NOOP, 0, 0, streamState, 0); } public void handleMessage(Message msg) { case MSG_SET_SYSTEM_VOLUME: setSystemVolume((VolumeStreamState) msg.obj); break; } private void setSystemVolume(VolumeStreamState streamState){ setStreamVolumeIndex(streamState.mStreamType, streamState.mIndex); } private void setStreamVolumeIndex(int stream, int index) { AudioSystem.setStreamVolumeIndex(stream, (index + 5)/10); } 7/10
  • 8. 4. AudioHardware class method 분석 안드로이드의 모든것 분석과 포팅 정리 Android_media_AudioSystem.cpp android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env, jobject thiz, jint stream, jint index) { return check_AudioSystem_Command( AudioSystem::setStreamVolumeIndex(static_cast <AudioSystem::stream_type>(stream), index)); } AudioSystem.cpp status_t AudioSystem::setStreamVolumeIndex(stream_type stream, int index) { const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service(); if (aps == 0) return PERMISSION_DENIED; return aps->setStreamVolumeIndex(stream, index); } AudioPolicyService.cpp status_t AudioPolicyService::setStreamVolumeIndex() { return mpPolicyManager->setStreamVolumeIndex(stream, index); } AudioPolicyManagerBase.cpp status_t AudioPolicyManagerBase::setStreamVolumeIndex(){ status_t volStatus = checkAndSetVolume(stream, index, mOutputs.keyAt(i), mOutputs.valueAt(i)->device()); } status_t AudioPolicyManagerBase::checkAndSetVolume{ if (stream == AudioSystem::VOICE_CALL || stream == AudioSystem::BLUETOOTH_SCO) { mpClientInterface->setVoiceVolume(voiceVolume, delayMs); } 8/10
  • 9. 4. AudioHardware class method 분석 안드로이드의 모든것 분석과 포팅 정리 AudioPolicyService.cpp status_t AudioPolicyService::setVoiceVolume(float volume, int delayMs) { return mAudioCommandThread->voiceVolumeCommand(volume, delayMs); } status_t AudioPolicyService::AudioCommandThread::voiceVolumeCommand { command->mCommand = SET_VOICE_VOLUME; } bool AudioPolicyService::AudioCommandThread::threadLoop() { case SET_VOICE_VOLUME: { command->mStatus = AudioSystem::setVoiceVolume(data->mVolume); } AudioSystem.cpp status_t AudioSystem::setVoiceVolume(float value) { const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger(); if (af == 0) return PERMISSION_DENIED; return af->setVoiceVolume(value); } AudioFlinger.cpp status_t AudioFlinger::setVoiceVolume(float value) { status_t ret = mAudioHardware->setVoiceVolume(value); } 9/10
  • 10. 4. AudioHardware class method 분석 안드로이드의 모든것 분석과 포팅 정리 AudioHardware.cpp status_t AudioHardware::setVoiceVolume(float v) { if(msm_set_voice_rx_vol(vol)) { LOGE("msm_set_voice_rx_vol(%d) failed errno = %d",vol,errno); return -1; } } Hw.c(vendor/qcom…) { int msm_set_voice_rx_vol(int volume) { struct snd_ctl_elem_value val; val.id.numid = NUMID_VOICE_VOL; val.value.integer.value[0] = DIR_RX; val.value.integer.value[1] = volume; return msm_mixer_elem_write(&val); } } static int msm_mixer_elem_write(struct snd_ctl_elem_value *val) { rc = ioctl(control->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, val); } 10/10
  • 11. 4. AudioHardware class method 분석 안드로이드의 모든것 분석과 포팅 정리 2) setVolume QwertyKeyListener.java public boolean onKeyDown{ return super.onKeyDown(view, content, keyCode, event); } phoneWindow.java protected boolean onKeyDown{ audioManager.adjustSuggestedStreamVolume( keyCode == KeyEvent.KEYCODE_VOLUME_UP ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER, mVolumeControlStreamType, AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_VIBRATE);} AudioManager.java public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) { IAudioService service = getService(); try { service.adjustSuggestedStreamVolume(direction, suggestedStreamType, flags); } catch (RemoteException e) { Log.e(TAG, "Dead object in adjustVolume", e); } } 11/10
  • 12. 4. AudioHardware class method 분석 안드로이드의 모든것 분석과 포팅 정리 AudioService.java public void adjustSuggestedStreamVolume{ adjustStreamVolume(streamType, direction, flags); } public void adjustStreamVolume{ sendMsg(mAudioHandler, MSG_SET_SYSTEM_VOLUME, STREAM_VOLUME_ALIAS[streamType], SENDMSG_NOOP, 0, 0, streamState, 0); AudioService.java public void handleMessage(Message msg) { switch (baseMsgWhat) { case MSG_SET_SYSTEM_VOLUME: setSystemVolume((VolumeStreamState) msg.obj); break; } AudioFlinger의 setStreamVolume을 호출해서 Volume setting함. status_t AudioFlinger::PlaybackThread::setStreamVolume(int stream, float value) { mStreamTypes[stream].volume = value; } AudioFlinger::MixerThread::threadLoop()에서 prepareTracks_l 이 수행 됨. 12/10
  • 13. 4. AudioHardware class method 분석 안드로이드의 모든것 분석과 포팅 정리 uint32_t AudioFlinger::MixerThread::prepareTracks_l { float typeVolume = mStreamTypes[track->type()].volume; setStreamVolume 에서 설정한 volume값을 가져와서 //volume 값 설정 float v = masterVolume * typeVolume; vl = (uint32_t)(v * cblk->volume[0]) << 12; vr = (uint32_t)(v * cblk->volume[1]) << 12; param = AudioMixer::VOLUME; //AudioMixer.cpp의 setparameter에서 처리 해줌. mAudioMixer->setParameter(param, AudioMixer::VOLUME0, (void *)left); mAudioMixer->setParameter(param, AudioMixer::VOLUME1, (void *)right); mAudioMixer->setParameter(param, AudioMixer::AUXLEVEL, (void *)aux); … } 13/10