mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1249437 - Remove workaround of volume control r=alwu
This commit is contained in:
parent
8dec676f3a
commit
0c08312576
@ -1361,24 +1361,12 @@ AudioManager::VolumeStreamState::SetVolumeIndexToActiveDevices(uint32_t aIndex)
|
||||
|
||||
// AudioPolicyManager::setStreamVolumeIndex() set volumes of all active
|
||||
// devices for stream.
|
||||
nsresult rv = SetVolumeIndex(aIndex, device);
|
||||
nsresult rv;
|
||||
rv = SetVolumeIndexToConsistentDeviceIfNeeded(aIndex, device);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Workaround to make audio volume control consisitent.
|
||||
// Active devices of AUDIO_STREAM_NOTIFICATION are affected by
|
||||
// AUDIO_STREAM_MUSIC's activity. It makes audio volume control inconsistent.
|
||||
// See Bug 1196724
|
||||
if (device != AUDIO_DEVICE_OUT_SPEAKER &&
|
||||
mStreamType == AUDIO_STREAM_NOTIFICATION) {
|
||||
// Rescaling of index is not necessary.
|
||||
rv = SetVolumeIndex(aIndex, AUDIO_DEVICE_OUT_SPEAKER);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1393,7 +1381,7 @@ AudioManager::VolumeStreamState::SetVolumeIndexToAliasStreams(uint32_t aIndex,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = SetVolumeIndex(aIndex, aDevice);
|
||||
nsresult rv = SetVolumeIndexToConsistentDeviceIfNeeded(aIndex, aDevice);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1413,6 +1401,27 @@ AudioManager::VolumeStreamState::SetVolumeIndexToAliasStreams(uint32_t aIndex,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
AudioManager::VolumeStreamState::SetVolumeIndexToConsistentDeviceIfNeeded(uint32_t aIndex, uint32_t aDevice)
|
||||
{
|
||||
nsresult rv;
|
||||
if (aDevice == AUDIO_DEVICE_OUT_SPEAKER || aDevice == AUDIO_DEVICE_OUT_EARPIECE) {
|
||||
// Set AUDIO_DEVICE_OUT_SPEAKER and AUDIO_DEVICE_OUT_EARPIECE to same volume.
|
||||
rv = SetVolumeIndex(aIndex, AUDIO_DEVICE_OUT_SPEAKER);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
rv = SetVolumeIndex(aIndex, AUDIO_DEVICE_OUT_EARPIECE);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
// No alias device
|
||||
rv = SetVolumeIndex(aIndex, aDevice);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
AudioManager::VolumeStreamState::SetVolumeIndex(uint32_t aIndex,
|
||||
uint32_t aDevice,
|
||||
|
@ -87,6 +87,7 @@ public:
|
||||
nsresult SetVolumeIndexToActiveDevices(uint32_t aIndex);
|
||||
// Set volume index to all alias streams for device. Alias streams have same volume.
|
||||
nsresult SetVolumeIndexToAliasStreams(uint32_t aIndex, uint32_t aDevice);
|
||||
nsresult SetVolumeIndexToConsistentDeviceIfNeeded(uint32_t aIndex, uint32_t aDevice);
|
||||
nsresult SetVolumeIndex(uint32_t aIndex, uint32_t aDevice, bool aUpdateCache = true);
|
||||
// Restore volume index to all devices. Called when AudioFlinger is restarted.
|
||||
void RestoreVolumeIndexToAllDevices();
|
||||
|
Loading…
Reference in New Issue
Block a user