AudioManager: fix AudioPort gain query

Fix bug causing AudioPort.gain(int) to always return null.

Also removed debug log from AudioManager.

Bug: 14815883.
Change-Id: Ie65bab233ec8b4d974061e11ec5b8f0de18275d9
This commit is contained in:
Eric Laurent
2014-06-02 19:18:43 -07:00
parent e205192c72
commit b4e0909fc4
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];