Permalink
Browse files

audio: fix for mismatched UseCase Type

- useCase name is compared with static string by length of static string
- But, Some useCase names are equal to each other in front string part
- For example, a "HiFi" and a "HiFi rec" are same in part of "HiFi"
- This patch is matched getUseCaseType() function of alsa_ucm.c file

bug: 7294569
related-to-bug: 7263961
Change-Id: Ia83f705756b750798d408a307f0697f9af9ec5dc
Signed-off-by: Iliyan Malchev <malchev@google.com>
  • Loading branch information...
1 parent 5f24fd9 commit a8b76531e6eef695eae174fd628396a5b4c95b7f @chaheekim chaheekim committed with Iliyan Malchev Oct 1, 2012
Showing with 35 additions and 29 deletions.
  1. +35 −29 alsa_sound/alsa_default.cpp
@@ -1158,65 +1158,71 @@ int getUseCaseType(const char *useCase)
{
ALOGD("use case is %s\n", useCase);
if (!strncmp(useCase, SND_USE_CASE_VERB_HIFI,
- strlen(SND_USE_CASE_VERB_HIFI)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_HIFI)) ||
!strncmp(useCase, SND_USE_CASE_VERB_HIFI_LOWLATENCY_MUSIC,
- strlen(SND_USE_CASE_VERB_HIFI_LOWLATENCY_MUSIC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_HIFI_LOWLATENCY_MUSIC)) ||
!strncmp(useCase, SND_USE_CASE_VERB_HIFI_LOW_POWER,
- strlen(SND_USE_CASE_VERB_HIFI_LOW_POWER)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_HIFI_LOW_POWER)) ||
!strncmp(useCase, SND_USE_CASE_VERB_HIFI_TUNNEL,
- strlen(SND_USE_CASE_VERB_HIFI_TUNNEL)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_HIFI_TUNNEL)) ||
+ !strncmp(useCase, SND_USE_CASE_VERB_HIFI2,
+ MAX_LEN(useCase,SND_USE_CASE_VERB_HIFI2)) ||
!strncmp(useCase, SND_USE_CASE_VERB_DIGITAL_RADIO,
- strlen(SND_USE_CASE_VERB_DIGITAL_RADIO)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_DIGITAL_RADIO)) ||
!strncmp(useCase, SND_USE_CASE_MOD_PLAY_MUSIC,
- strlen(SND_USE_CASE_MOD_PLAY_MUSIC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_PLAY_MUSIC)) ||
!strncmp(useCase, SND_USE_CASE_MOD_PLAY_LOWLATENCY_MUSIC,
- strlen(SND_USE_CASE_MOD_PLAY_LOWLATENCY_MUSIC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_PLAY_LOWLATENCY_MUSIC)) ||
+ !strncmp(useCase, SND_USE_CASE_MOD_PLAY_MUSIC2,
+ MAX_LEN(useCase,SND_USE_CASE_MOD_PLAY_MUSIC2)) ||
!strncmp(useCase, SND_USE_CASE_MOD_PLAY_LPA,
- strlen(SND_USE_CASE_MOD_PLAY_LPA)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_PLAY_LPA)) ||
!strncmp(useCase, SND_USE_CASE_MOD_PLAY_TUNNEL,
- strlen(SND_USE_CASE_MOD_PLAY_TUNNEL)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_PLAY_TUNNEL)) ||
!strncmp(useCase, SND_USE_CASE_MOD_PLAY_FM,
- strlen(SND_USE_CASE_MOD_PLAY_FM))) {
+ MAX_LEN(useCase,SND_USE_CASE_MOD_PLAY_FM))) {
return USECASE_TYPE_RX;
} else if (!strncmp(useCase, SND_USE_CASE_VERB_HIFI_REC,
- strlen(SND_USE_CASE_VERB_HIFI_REC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_HIFI_REC)) ||
!strncmp(useCase, SND_USE_CASE_VERB_HIFI_LOWLATENCY_REC,
- strlen(SND_USE_CASE_VERB_HIFI_LOWLATENCY_REC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_HIFI_LOWLATENCY_REC)) ||
!strncmp(useCase, SND_USE_CASE_VERB_FM_REC,
- strlen(SND_USE_CASE_VERB_FM_REC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_FM_REC)) ||
!strncmp(useCase, SND_USE_CASE_VERB_FM_A2DP_REC,
- strlen(SND_USE_CASE_VERB_FM_A2DP_REC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_FM_A2DP_REC)) ||
!strncmp(useCase, SND_USE_CASE_MOD_CAPTURE_MUSIC,
- strlen(SND_USE_CASE_MOD_CAPTURE_MUSIC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_CAPTURE_MUSIC)) ||
!strncmp(useCase, SND_USE_CASE_MOD_CAPTURE_LOWLATENCY_MUSIC,
- strlen(SND_USE_CASE_MOD_CAPTURE_LOWLATENCY_MUSIC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_CAPTURE_LOWLATENCY_MUSIC)) ||
!strncmp(useCase, SND_USE_CASE_MOD_CAPTURE_FM,
- strlen(SND_USE_CASE_MOD_CAPTURE_FM)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_CAPTURE_FM)) ||
!strncmp(useCase, SND_USE_CASE_MOD_CAPTURE_A2DP_FM,
- strlen(SND_USE_CASE_MOD_CAPTURE_A2DP_FM))) {
+ MAX_LEN(useCase,SND_USE_CASE_MOD_CAPTURE_A2DP_FM))) {
return USECASE_TYPE_TX;
} else if (!strncmp(useCase, SND_USE_CASE_VERB_VOICECALL,
- strlen(SND_USE_CASE_VERB_VOICECALL)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_VOICECALL)) ||
!strncmp(useCase, SND_USE_CASE_VERB_IP_VOICECALL,
- strlen(SND_USE_CASE_VERB_IP_VOICECALL)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_IP_VOICECALL)) ||
!strncmp(useCase, SND_USE_CASE_VERB_DL_REC,
- strlen(SND_USE_CASE_VERB_DL_REC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_DL_REC)) ||
!strncmp(useCase, SND_USE_CASE_VERB_UL_DL_REC,
- strlen(SND_USE_CASE_VERB_UL_DL_REC)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_UL_DL_REC)) ||
+ !strncmp(useCase, SND_USE_CASE_VERB_INCALL_REC,
+ MAX_LEN(useCase,SND_USE_CASE_VERB_INCALL_REC)) ||
!strncmp(useCase, SND_USE_CASE_MOD_PLAY_VOICE,
- strlen(SND_USE_CASE_MOD_PLAY_VOICE)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_PLAY_VOICE)) ||
!strncmp(useCase, SND_USE_CASE_MOD_PLAY_VOIP,
- strlen(SND_USE_CASE_MOD_PLAY_VOIP)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_PLAY_VOIP)) ||
!strncmp(useCase, SND_USE_CASE_MOD_CAPTURE_VOICE_DL,
- strlen(SND_USE_CASE_MOD_CAPTURE_VOICE_DL)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_CAPTURE_VOICE_DL)) ||
!strncmp(useCase, SND_USE_CASE_MOD_CAPTURE_VOICE_UL_DL,
- strlen(SND_USE_CASE_MOD_CAPTURE_VOICE_UL_DL)) ||
+ MAX_LEN(useCase,SND_USE_CASE_MOD_CAPTURE_VOICE_UL_DL)) ||
!strncmp(useCase, SND_USE_CASE_MOD_CAPTURE_VOICE,
- strlen(SND_USE_CASE_MOD_CAPTURE_VOICE)) ||
+ MAX_LEN(useCase, SND_USE_CASE_MOD_CAPTURE_VOICE)) ||
!strncmp(useCase, SND_USE_CASE_VERB_VOLTE,
- strlen(SND_USE_CASE_VERB_VOLTE)) ||
+ MAX_LEN(useCase,SND_USE_CASE_VERB_VOLTE)) ||
!strncmp(useCase, SND_USE_CASE_MOD_PLAY_VOLTE,
- strlen(SND_USE_CASE_MOD_PLAY_VOLTE))) {
+ MAX_LEN(useCase, SND_USE_CASE_MOD_PLAY_VOLTE))) {
return (USECASE_TYPE_RX | USECASE_TYPE_TX);
} else {
ALOGE("unknown use case %s\n", useCase);

0 comments on commit a8b7653

Please sign in to comment.