Fix issue 2304669: VoiceIME: starting and canceling voice IME yields persistent "error 8" state on future attempts and breaks voice search.
Fixed AudioPolicyManager::getInput() broken in change ddb78e7753be03937ad57ce7c3c842c52bdad65e
so that an invalid IO handle (0) is returned in case of failure.
Applied the same correction to getOutput().
diff --git a/libaudio-qsd8k/AudioPolicyManager.cpp b/libaudio-qsd8k/AudioPolicyManager.cpp
index 9660854..e79769f 100644
--- a/libaudio-qsd8k/AudioPolicyManager.cpp
+++ b/libaudio-qsd8k/AudioPolicyManager.cpp
@@ -751,12 +751,15 @@
outputDesc->mFlags);
// only accept an output with the requeted parameters
- if ((samplingRate != 0 && samplingRate != outputDesc->mSamplingRate) ||
+ if (output == 0 ||
+ (samplingRate != 0 && samplingRate != outputDesc->mSamplingRate) ||
(format != 0 && format != outputDesc->mFormat) ||
(channels != 0 && channels != outputDesc->mChannels)) {
LOGV("getOutput() failed opening direct output: samplingRate %d, format %d, channels %d",
samplingRate, format, channels);
- mpClientInterface->closeOutput(output);
+ if (output != 0) {
+ mpClientInterface->closeOutput(output);
+ }
delete outputDesc;
return 0;
}
@@ -1000,12 +1003,15 @@
inputDesc->mAcoustics);
// only accept input with the exact requested set of parameters
- if ((samplingRate != inputDesc->mSamplingRate) ||
+ if (input == 0 ||
+ (samplingRate != inputDesc->mSamplingRate) ||
(format != inputDesc->mFormat) ||
(channels != inputDesc->mChannels)) {
- LOGV("getOutput() failed opening input: samplingRate %d, format %d, channels %d",
+ LOGV("getInput() failed opening input: samplingRate %d, format %d, channels %d",
samplingRate, format, channels);
- mpClientInterface->closeInput(input);
+ if (input != 0) {
+ mpClientInterface->closeInput(input);
+ }
delete inputDesc;
return 0;
}
@@ -1036,7 +1042,7 @@
// use Voice Recognition mode or not for this input based on input source
int vr_enabled = inputDesc->mInputSource == AUDIO_SOURCE_VOICE_RECOGNITION ? 1 : 0;
param.addInt(String8("vr_mode"), vr_enabled);
- LOGV("AudioPolicyManager::getInput(%d), setting vr_mode to %d", inputDesc->mInputSource, vr_enabled);
+ LOGV("AudioPolicyManager::startInput(%d), setting vr_mode to %d", inputDesc->mInputSource, vr_enabled);
mpClientInterface->setParameters(input, param.toString());
@@ -1518,11 +1524,11 @@
device = AudioSystem::DEVICE_IN_VOICE_CALL;
break;
default:
- LOGW("getInput() invalid input source %d", inputSource);
+ LOGW("getDeviceForInputSource() invalid input source %d", inputSource);
device = 0;
break;
}
- LOGW("getDeviceForInputSource()input source %d, device %08x", inputSource, device);
+ LOGV("getDeviceForInputSource()input source %d, device %08x", inputSource, device);
return device;
}