使用震动喇叭,在home界面通过音量键调音量,结果调的是媒体音量而不是来电铃声的音量
时间:10-02
整理:3721RD
点击:
[DESCRIPTION]
问题:使用震动喇叭,打开mtk_VIBSPK_SUPPORT,通过音量键在home界面调节音量,经常出现按一下没有提示音的情况,观察音量图标,发现调的是media的音量等级,而不是ring的音量等级。进入setting,把震动关掉,此问题就不再复现。只要是在震动的时候去home见面调音量键,就可以必现这个问题。
[SOLUTION]
原因:这是因为震动的时候会播放一个silence,stream type用的是music,当在home界面调音量的时候,会去底层get stream type,如果此时在震动,则会get到music的stream type,所以会变成调节的是media的音量等级。
解法:请做以下修改(以下修改处以"AAAA"标识):
1)修改/alps/system/core/include/system/audio.h
/* Audio stream types */
typedef enum {
AUDIO_STREAM_DEFAULT = -1,
AUDIO_STREAM_VOICE_CALL = 0,
AUDIO_STREAM_SYSTEM = 1,
AUDIO_STREAM_RING = 2,
AUDIO_STREAM_MUSIC = 3,
AUDIO_STREAM_ALARM = 4,
AUDIO_STREAM_NOTIFICATION = 5,
AUDIO_STREAM_bluetooth_SCO = 6,
AUDIO_STREAM_ENFORCED_AUDIBLE = 7, /* Sounds that cannot be muted by user and must be routed to speaker */
AUDIO_STREAM_DTMF = 8,
AUDIO_STREAM_TTS = 9,
//#ifdef MTK_AUDIO
AUDIO_STREAM_FM = 10,
AUDIO_STREAM_MATV = 11,
AUDIO_STREAM_BOOT = 12, //only used for bootanimation and output fROM speaker and heADSet
AUDIO_STREAM_VIBSPK = 13,//AAAA,此处新增一个这种streamtype
//#endif
AUDIO_STREAM_CNT,
AUDIO_STREAM_MAX = AUDIO_STREAM_CNT - 1,
} audio_stream_type_t;
2)修改/alps/hardware/libhardware_legacy/include/hardware_legacy/AudioSystemLegacy.h
class AudioSystem {
public:
#if 1
enum stream_type {
DEFAULT =-1,
VOICE_CALL = 0,
SYSTEM = 1,
RING = 2,
MUSIC = 3,
ALARM = 4,
NOTIFICATION = 5,
BLUETOOTH_SCO = 6,
ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be routed to speaker
DTMF = 8,
TTS = 9,
//#ifndef android_DEFAULT_CODE
#if 1
FM = 10,
MATV = 11,
BOOT = 12, //only used for bootanimation and output from speakerand headset
VIBSPK = 13,//AAAA,此处新增一个这种streamtype
#endif
NUM_STREAM_TYPES
};
3)修改/alps/mediatek/platform/common/hardware/audio/AudioMTKPolicyManager.cpp
AudioMTKPolicyManager::routing_strategy AudioMTKPolicyManager::getStrategy(
AudioSystem::stream_type stream) {
// stream to strategy mapping
switch (stream) {
case AudioSystem::VOICE_CALL:
case AudioSystem::BLUETOOTH_SCO:
return STRATEGY_PHONE;
case AudioSystem::RING:
case AudioSystem::ALARM:
return STRATEGY_SONIFICATION;
case AudioSystem::NOTIFICATION:
return STRATEGY_SONIFICATION_RESPECTFUL;
case AudioSystem::DTMF:
return STRATEGY_DTMF;
#ifdef MTK_AUDIO
// FM and MATV strategy
case AudioSystem::FM:
#ifdef FM_ANALOG_IN_SUPPORT
return STRATEGY_PROPRIETARY_ANLG; #else
return STRATEGY_PROPRIETARY_DGTL; #endif
case AudioSystem::MATV:
#ifdef MATV_AUDIO_SUPPORT
if( matv_use_analog_input == 1)
return STRATEGY_PROPRIETARY_ANLG_V2;
else
return STRATEGY_PROPRIETARY_DGTL_V2; #endif
#endif //#ifndef ANDROID_DEFAULT_CODE
default:
//ALOGE("unknown stream type");
case AudioSystem::SYSTEM:
// NOTE: SYSTEM stream uses MEDIA strategy because muting music and switching outputs
// while key CLIcks are played produces a poor result
case AudioSystem::TTS:
case AudioSystem::MUSIC:
#ifdef MTK_AUDIO
case AudioSystem::BOOT:
case AudioSystem::VIBSPK: //AAAA,添加此处
#endif
return STRATEGY_MEDIA;
case AudioSystem::ENFORCED_AUDIBLE:
return STRATEGY_ENFORCED_AUDIBLE;
}
}
const AudioMTKPolicyManager::VolumeCurvePoint
*AudioMTKPolicyManager::sVolumeProfiles[AUDIO_STREAM_CNT]
[AudioMTKPolicyManager::DEVICE_CATEGORY_CNT] = {
。
{
// AUDIO_STREAM_ATV
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},
{
// AUDIO_STREAM_BOOT
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},
{//AAAA,添加以下
// AUDIO_STREAM_VIBSPK
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
}//AAAA,添加以上
#endif
};
4)
修改/alps/mediatek/platform/common/hardware/audio/AudioPolicyManagerBase.cpp
修改/alps/hardware/libhardware_legacy/audio/AudioPolicyManagerBase.cpp
const AudioPolicyManagerBase::VolumeCurvePoint
*AudioPolicyManagerBase::sVolumeProfiles[AUDIO_STREAM_CNT]
[AudioPolicyManagerBase::DEVICE_CATEGORY_CNT] = {
。
{
// AUDIO_STREAM_ATV
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},
{
// AUDIO_STREAM_BOOT
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},
{ // AUDIO_STREAM_VIBSPK //AAAA,添加以下
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},//AAAA,添加以上
};
5)修改/alps/mediatek/protect-bsp/php?mod=tag&id=6090" target="_blank" class="relatedlink">Frameworks/av/media/liBMTkplayer/VibSpkAudioPlayer.cpp
VibSpkAudioPlayer *VibSpkAudioPlayer::getInstance() {
if(VibSpkAudioPlayerInstance == NULL)
{
SXLOGD("GetInstance, Constructor\n");
VibSpkAudioPlayerInstance = new VibSpkAudioPlayer(AUDIO_STREAM_VIBSPK, 0, false);//AAAA,修改此处
//VibSpkAudioPlayerInstance = new VibSpkAudioPlayer(AUDIO_STREAM_NOTIFICATION, 0, false);
SXLOGD("GetInstance, Constructor done\n");
}
return VibSpkAudioPlayerInstance;
}
如果以上修改OK的话,请申请patch:ALPS00845976
问题:使用震动喇叭,打开mtk_VIBSPK_SUPPORT,通过音量键在home界面调节音量,经常出现按一下没有提示音的情况,观察音量图标,发现调的是media的音量等级,而不是ring的音量等级。进入setting,把震动关掉,此问题就不再复现。只要是在震动的时候去home见面调音量键,就可以必现这个问题。
[SOLUTION]
原因:这是因为震动的时候会播放一个silence,stream type用的是music,当在home界面调音量的时候,会去底层get stream type,如果此时在震动,则会get到music的stream type,所以会变成调节的是media的音量等级。
解法:请做以下修改(以下修改处以"AAAA"标识):
1)修改/alps/system/core/include/system/audio.h
/* Audio stream types */
typedef enum {
AUDIO_STREAM_DEFAULT = -1,
AUDIO_STREAM_VOICE_CALL = 0,
AUDIO_STREAM_SYSTEM = 1,
AUDIO_STREAM_RING = 2,
AUDIO_STREAM_MUSIC = 3,
AUDIO_STREAM_ALARM = 4,
AUDIO_STREAM_NOTIFICATION = 5,
AUDIO_STREAM_bluetooth_SCO = 6,
AUDIO_STREAM_ENFORCED_AUDIBLE = 7, /* Sounds that cannot be muted by user and must be routed to speaker */
AUDIO_STREAM_DTMF = 8,
AUDIO_STREAM_TTS = 9,
//#ifdef MTK_AUDIO
AUDIO_STREAM_FM = 10,
AUDIO_STREAM_MATV = 11,
AUDIO_STREAM_BOOT = 12, //only used for bootanimation and output fROM speaker and heADSet
AUDIO_STREAM_VIBSPK = 13,//AAAA,此处新增一个这种streamtype
//#endif
AUDIO_STREAM_CNT,
AUDIO_STREAM_MAX = AUDIO_STREAM_CNT - 1,
} audio_stream_type_t;
2)修改/alps/hardware/libhardware_legacy/include/hardware_legacy/AudioSystemLegacy.h
class AudioSystem {
public:
#if 1
enum stream_type {
DEFAULT =-1,
VOICE_CALL = 0,
SYSTEM = 1,
RING = 2,
MUSIC = 3,
ALARM = 4,
NOTIFICATION = 5,
BLUETOOTH_SCO = 6,
ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be routed to speaker
DTMF = 8,
TTS = 9,
//#ifndef android_DEFAULT_CODE
#if 1
FM = 10,
MATV = 11,
BOOT = 12, //only used for bootanimation and output from speakerand headset
VIBSPK = 13,//AAAA,此处新增一个这种streamtype
#endif
NUM_STREAM_TYPES
};
3)修改/alps/mediatek/platform/common/hardware/audio/AudioMTKPolicyManager.cpp
AudioMTKPolicyManager::routing_strategy AudioMTKPolicyManager::getStrategy(
AudioSystem::stream_type stream) {
// stream to strategy mapping
switch (stream) {
case AudioSystem::VOICE_CALL:
case AudioSystem::BLUETOOTH_SCO:
return STRATEGY_PHONE;
case AudioSystem::RING:
case AudioSystem::ALARM:
return STRATEGY_SONIFICATION;
case AudioSystem::NOTIFICATION:
return STRATEGY_SONIFICATION_RESPECTFUL;
case AudioSystem::DTMF:
return STRATEGY_DTMF;
#ifdef MTK_AUDIO
// FM and MATV strategy
case AudioSystem::FM:
#ifdef FM_ANALOG_IN_SUPPORT
return STRATEGY_PROPRIETARY_ANLG; #else
return STRATEGY_PROPRIETARY_DGTL; #endif
case AudioSystem::MATV:
#ifdef MATV_AUDIO_SUPPORT
if( matv_use_analog_input == 1)
return STRATEGY_PROPRIETARY_ANLG_V2;
else
return STRATEGY_PROPRIETARY_DGTL_V2; #endif
#endif //#ifndef ANDROID_DEFAULT_CODE
default:
//ALOGE("unknown stream type");
case AudioSystem::SYSTEM:
// NOTE: SYSTEM stream uses MEDIA strategy because muting music and switching outputs
// while key CLIcks are played produces a poor result
case AudioSystem::TTS:
case AudioSystem::MUSIC:
#ifdef MTK_AUDIO
case AudioSystem::BOOT:
case AudioSystem::VIBSPK: //AAAA,添加此处
#endif
return STRATEGY_MEDIA;
case AudioSystem::ENFORCED_AUDIBLE:
return STRATEGY_ENFORCED_AUDIBLE;
}
}
const AudioMTKPolicyManager::VolumeCurvePoint
*AudioMTKPolicyManager::sVolumeProfiles[AUDIO_STREAM_CNT]
[AudioMTKPolicyManager::DEVICE_CATEGORY_CNT] = {
。
{
// AUDIO_STREAM_ATV
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},
{
// AUDIO_STREAM_BOOT
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},
{//AAAA,添加以下
// AUDIO_STREAM_VIBSPK
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
}//AAAA,添加以上
#endif
};
4)
修改/alps/mediatek/platform/common/hardware/audio/AudioPolicyManagerBase.cpp
修改/alps/hardware/libhardware_legacy/audio/AudioPolicyManagerBase.cpp
const AudioPolicyManagerBase::VolumeCurvePoint
*AudioPolicyManagerBase::sVolumeProfiles[AUDIO_STREAM_CNT]
[AudioPolicyManagerBase::DEVICE_CATEGORY_CNT] = {
。
{
// AUDIO_STREAM_ATV
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},
{
// AUDIO_STREAM_BOOT
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},
{ // AUDIO_STREAM_VIBSPK //AAAA,添加以下
sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EARPIECE
},//AAAA,添加以上
};
5)修改/alps/mediatek/protect-bsp/php?mod=tag&id=6090" target="_blank" class="relatedlink">Frameworks/av/media/liBMTkplayer/VibSpkAudioPlayer.cpp
VibSpkAudioPlayer *VibSpkAudioPlayer::getInstance() {
if(VibSpkAudioPlayerInstance == NULL)
{
SXLOGD("GetInstance, Constructor\n");
VibSpkAudioPlayerInstance = new VibSpkAudioPlayer(AUDIO_STREAM_VIBSPK, 0, false);//AAAA,修改此处
//VibSpkAudioPlayerInstance = new VibSpkAudioPlayer(AUDIO_STREAM_NOTIFICATION, 0, false);
SXLOGD("GetInstance, Constructor done\n");
}
return VibSpkAudioPlayerInstance;
}
如果以上修改OK的话,请申请patch:ALPS00845976