Loading services/core/java/com/android/server/audio/AudioService.java +23 −15 Original line number Diff line number Diff line Loading @@ -4035,25 +4035,27 @@ public class AudioService extends IAudioService.Stub { mIndexMap.put(device, index); changed = oldIndex != index; if (changed) { // Apply change to all streams using this one as alias // if changing volume of current device, also change volume of current // Apply change to all streams using this one as alias if: // - the index actually changed OR // - there is no volume index stored for this device on alias stream. // If changing volume of current device, also change volume of current // device on aliased stream boolean currentDevice = (device == getDeviceForStream(mStreamType)); int numStreamTypes = AudioSystem.getNumStreamTypes(); final boolean currentDevice = (device == getDeviceForStream(mStreamType)); final int numStreamTypes = AudioSystem.getNumStreamTypes(); for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) { final VolumeStreamState aliasStreamState = mStreamStates[streamType]; if (streamType != mStreamType && mStreamVolumeAlias[streamType] == mStreamType) { int scaledIndex = rescaleIndex(index, mStreamType, streamType); mStreamStates[streamType].setIndex(scaledIndex, device, caller); mStreamVolumeAlias[streamType] == mStreamType && (changed || !aliasStreamState.hasIndexForDevice(device))) { final int scaledIndex = rescaleIndex(index, mStreamType, streamType); aliasStreamState.setIndex(scaledIndex, device, caller); if (currentDevice) { mStreamStates[streamType].setIndex(scaledIndex, aliasStreamState.setIndex(scaledIndex, getDeviceForStream(streamType), caller); } } } } } if (changed) { oldIndex = (oldIndex + 5) / 10; index = (index + 5) / 10; Loading Loading @@ -4086,6 +4088,12 @@ public class AudioService extends IAudioService.Stub { } } public boolean hasIndexForDevice(int device) { synchronized (VolumeStreamState.class) { return (mIndexMap.get(device, -1) != -1); } } public int getMaxIndex() { return mIndexMax; } Loading Loading
services/core/java/com/android/server/audio/AudioService.java +23 −15 Original line number Diff line number Diff line Loading @@ -4035,25 +4035,27 @@ public class AudioService extends IAudioService.Stub { mIndexMap.put(device, index); changed = oldIndex != index; if (changed) { // Apply change to all streams using this one as alias // if changing volume of current device, also change volume of current // Apply change to all streams using this one as alias if: // - the index actually changed OR // - there is no volume index stored for this device on alias stream. // If changing volume of current device, also change volume of current // device on aliased stream boolean currentDevice = (device == getDeviceForStream(mStreamType)); int numStreamTypes = AudioSystem.getNumStreamTypes(); final boolean currentDevice = (device == getDeviceForStream(mStreamType)); final int numStreamTypes = AudioSystem.getNumStreamTypes(); for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) { final VolumeStreamState aliasStreamState = mStreamStates[streamType]; if (streamType != mStreamType && mStreamVolumeAlias[streamType] == mStreamType) { int scaledIndex = rescaleIndex(index, mStreamType, streamType); mStreamStates[streamType].setIndex(scaledIndex, device, caller); mStreamVolumeAlias[streamType] == mStreamType && (changed || !aliasStreamState.hasIndexForDevice(device))) { final int scaledIndex = rescaleIndex(index, mStreamType, streamType); aliasStreamState.setIndex(scaledIndex, device, caller); if (currentDevice) { mStreamStates[streamType].setIndex(scaledIndex, aliasStreamState.setIndex(scaledIndex, getDeviceForStream(streamType), caller); } } } } } if (changed) { oldIndex = (oldIndex + 5) / 10; index = (index + 5) / 10; Loading Loading @@ -4086,6 +4088,12 @@ public class AudioService extends IAudioService.Stub { } } public boolean hasIndexForDevice(int device) { synchronized (VolumeStreamState.class) { return (mIndexMap.get(device, -1) != -1); } } public int getMaxIndex() { return mIndexMax; } Loading