解决开机打印“03-07 12:02:23.039 E/AudioHardwareMSM8660( 130): unknown stream”的问题。

./hardware/qcom/media/audio/msm8660/AudioPolicyManager.cpp

 759 void AudioPolicyManager::setOutputDevice(audio_io_handle_t output, uint32_t device, bool force, int delayMs)

 760 {  //设置输出设备  DEVICE_OUT_AUX_DIGITAL = 0x400,

。。。。。。。

783     // Doing this check here allows the caller to call setOutputDevice() without conditions

 784     if ((device == 0 || device == prevDevice) && !force) {

 785         LOGV("setOutputDevice() setting same device %x or null device for output %d", device, output);

 786         return;

 787     }

// setParameters会调用doRouting遍历路由,将DEVICE_OUT_AUX_DIGITAL映射为SND_DEVICE_HDMI

840     mpClientInterface->setParameters(mHardwareOutput, param.toString(), delayMs);

 841     // update stream volumes according to new device

843     AudioPolicyManagerBase::applyStreamVolumes(output, device, delayMs);

 

}

 

hardware/libhardware_legacy/audio/AudioPolicyManagerBase.cpp

2182 void AudioPolicyManagerBase::applyStreamVolumes(audio_io_handle_t output, uint32_t device, int delayMs, bool force)

2183 { //11种流类型设置音量

2184     LOGV("applyStreamVolumes() for output %d and device %x", output, device);

2185

2186     for (int stream = 0; stream < AudioSystem::NUM_STREAM_TYPES; stream++) {

2187         checkAndSetVolume(stream, mStreams[stream].mIndexCur, output, device, delayMs, force);

2188     }

2189 }

2190

 

./hardware/qcom/media/audio/msm8660/AudioPolicyManager.cpp

883 status_t AudioPolicyManager::checkAndSetVolume(int stream, int index, audio_io_handle_t output, uint32_t device, int delayMs, bool force)

 884 {

901     float volume = computeVolume(stream, index, output, device);

 902     // do not set volume if the float value did not change

 903     if ((volume != mOutputs.valueFor(output)->mCurVolume[stream]) || (stream == AudioSystem::VOICE_CALL) || (stream == AudioSystem::FM) || force) {

 905         mOutputs.valueFor(output)->mCurVolume[stream] = volume;

907         if (stream == AudioSystem::VOICE_CALL ||

 908             stream == AudioSystem::DTMF ||

 909             stream == AudioSystem::BLUETOOTH_SCO) {

 910             float voiceVolume = -1.0;

 911             // offset value to reflect actual hardware volume that never reaches 0

 912             // 1% corresponds roughly to first step in VOICE_CALL stream volume setting (see AudioService.java)

 913             volume = 0.01 + 0.99 * volume;

 914             if (stream == AudioSystem::VOICE_CALL) {

 915                 voiceVolume = (float)index/(float)mStreams[stream].mIndexMax;

 916             } else if (stream == AudioSystem::BLUETOOTH_SCO) {

 917                 voiceVolume = 1.0;

 918             }

 919             if (voiceVolume >= 0 && output == mHardwareOutput) {

 920                

 921                 mpClientInterface->setVoiceVolume(voiceVolume, delayMs);

 922             }

 923         }

 934         mpClientInterface->setStreamVolume((AudioSystem::stream_type)stream, volume, output, delayMs);

 935     }

 936

然后经过AudioPolicyService AudioSystem AudioFlinger ,最终调用到AudioHardwareMSM8660,具体见3.

 

 

1221 status_t AudioHardware::setVoiceVolume(float v)

1222 {

1223     int session_id = 0;

1224     if (v < 0.0) {

1225         LOGW("setVoiceVolume(%f) under 0.0, assuming 0.0\n", v);

1226         v = 0.0;

1227     } else if (v > 1.0) {

1228         LOGW("setVoiceVolume(%f) over 1.0, assuming 1.0\n", v);

1229         v = 1.0;

1230     }

1233     if(isStreamOnAndActive(VOICE_CALL)) {

1234         session_id = voice_session_id;

1235     } else if (isStreamOnAndActive(VOIP_CALL)) {

1236         session_id = voip_session_id;

1237     } else { //由于VOICE_CALL并没有active,(在遍历路由时决定是否active)所以。。。

1238         LOGE(" unknown stream ");

1239         return -1;

1240     }

 

1254 }

 

在设置输出设备为DEVICE_OUT_AUX_DIGITAL时,会对11种流类型设置音量,其中对VOICE_CALL类型设置音量时,由于系统没有VOICE_CALL,没有active,所以打印“unknown stream

你可能感兴趣的:(IO,Stream,session,float,audio,output)