Merge "audio: allow audio port cache update even when audio patches contain invalidated sources/sinks" into lmp-mr1-dev
automerge: d7310bd
* commit 'd7310bd1499c0b48594a8fbbcbe0c7e80c1e5832':
audio: allow audio port cache update even when audio patches contain invalidated sources/sinks
This commit is contained in:
@@ -46,9 +46,9 @@ import android.provider.Settings;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AudioManager provides access to volume and ringer mode control.
|
* AudioManager provides access to volume and ringer mode control.
|
||||||
@@ -3650,11 +3650,13 @@ public class AudioManager {
|
|||||||
newPorts.clear();
|
newPorts.clear();
|
||||||
status = AudioSystem.listAudioPorts(newPorts, portGeneration);
|
status = AudioSystem.listAudioPorts(newPorts, portGeneration);
|
||||||
if (status != SUCCESS) {
|
if (status != SUCCESS) {
|
||||||
|
Log.w(TAG, "updateAudioPortCache: listAudioPorts failed");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
newPatches.clear();
|
newPatches.clear();
|
||||||
status = AudioSystem.listAudioPatches(newPatches, patchGeneration);
|
status = AudioSystem.listAudioPatches(newPatches, patchGeneration);
|
||||||
if (status != SUCCESS) {
|
if (status != SUCCESS) {
|
||||||
|
Log.w(TAG, "updateAudioPortCache: listAudioPatches failed");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
} while (patchGeneration[0] != portGeneration[0]);
|
} while (patchGeneration[0] != portGeneration[0]);
|
||||||
@@ -3663,20 +3665,35 @@ public class AudioManager {
|
|||||||
for (int j = 0; j < newPatches.get(i).sources().length; j++) {
|
for (int j = 0; j < newPatches.get(i).sources().length; j++) {
|
||||||
AudioPortConfig portCfg = updatePortConfig(newPatches.get(i).sources()[j],
|
AudioPortConfig portCfg = updatePortConfig(newPatches.get(i).sources()[j],
|
||||||
newPorts);
|
newPorts);
|
||||||
if (portCfg == null) {
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
newPatches.get(i).sources()[j] = portCfg;
|
newPatches.get(i).sources()[j] = portCfg;
|
||||||
}
|
}
|
||||||
for (int j = 0; j < newPatches.get(i).sinks().length; j++) {
|
for (int j = 0; j < newPatches.get(i).sinks().length; j++) {
|
||||||
AudioPortConfig portCfg = updatePortConfig(newPatches.get(i).sinks()[j],
|
AudioPortConfig portCfg = updatePortConfig(newPatches.get(i).sinks()[j],
|
||||||
newPorts);
|
newPorts);
|
||||||
if (portCfg == null) {
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
newPatches.get(i).sinks()[j] = portCfg;
|
newPatches.get(i).sinks()[j] = portCfg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (Iterator<AudioPatch> i = newPatches.iterator(); i.hasNext(); ) {
|
||||||
|
AudioPatch newPatch = i.next();
|
||||||
|
boolean hasInvalidPort = false;
|
||||||
|
for (AudioPortConfig portCfg : newPatch.sources()) {
|
||||||
|
if (portCfg == null) {
|
||||||
|
hasInvalidPort = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (AudioPortConfig portCfg : newPatch.sinks()) {
|
||||||
|
if (portCfg == null) {
|
||||||
|
hasInvalidPort = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasInvalidPort) {
|
||||||
|
// Temporarily remove patches with invalid ports. One who created the patch
|
||||||
|
// is responsible for dealing with the port change.
|
||||||
|
i.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sAudioPortsCached = newPorts;
|
sAudioPortsCached = newPorts;
|
||||||
sAudioPatchesCached = newPatches;
|
sAudioPatchesCached = newPatches;
|
||||||
|
|||||||
Reference in New Issue
Block a user