Merge "AudioManager: fix AudioPort gain query" into lmp-preview-dev

This commit is contained in:
Eric Laurent
2014-06-04 00:27:50 +00:00
committed by Android (Google) Code Review
2 changed files with 5 additions and 9 deletions

View File

@@ -3184,15 +3184,11 @@ public class AudioManager {
do {
newPorts.clear();
status = AudioSystem.listAudioPorts(newPorts, portGeneration);
Log.i(TAG, "updateAudioPortCache AudioSystem.listAudioPorts() status: "+
status+" num ports: "+ newPorts.size() +" portGeneration: "+portGeneration[0]);
if (status != SUCCESS) {
return status;
}
newPatches.clear();
status = AudioSystem.listAudioPatches(newPatches, patchGeneration);
Log.i(TAG, "updateAudioPortCache AudioSystem.listAudioPatches() status: "+
status+" num patches: "+ newPatches.size() +" patchGeneration: "+patchGeneration[0]);
if (status != SUCCESS) {
return status;
}
@@ -3200,14 +3196,16 @@ public class AudioManager {
for (int i = 0; i < newPatches.size(); i++) {
for (int j = 0; j < newPatches.get(i).sources().length; j++) {
AudioPortConfig portCfg = updatePortConfig(newPatches.get(i).sources()[j], newPorts);
AudioPortConfig portCfg = updatePortConfig(newPatches.get(i).sources()[j],
newPorts);
if (portCfg == null) {
return ERROR;
}
newPatches.get(i).sources()[j] = portCfg;
}
for (int j = 0; j < newPatches.get(i).sinks().length; j++) {
AudioPortConfig portCfg = updatePortConfig(newPatches.get(i).sinks()[j], newPorts);
AudioPortConfig portCfg = updatePortConfig(newPatches.get(i).sinks()[j],
newPorts);
if (portCfg == null) {
return ERROR;
}
@@ -3238,8 +3236,6 @@ public class AudioManager {
// compare handles because the port returned by JNI is not of the correct
// subclass
if (ports.get(k).handle().equals(port.handle())) {
Log.i(TAG, "updatePortConfig match found for port handle: "+
port.handle().id()+" port: "+ k);
port = ports.get(k);
break;
}

View File

@@ -133,7 +133,7 @@ public class AudioPort {
* Get the gain descriptor at a given index
*/
AudioGain gain(int index) {
if (index < mGains.length) {
if (index < 0 || index >= mGains.length) {
return null;
}
return mGains[index];