[voice ]Only call getVolume when necessary (#3280)
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>pull/3284/head
parent
a3dc57784a
commit
ab96a6ba55
|
@ -123,17 +123,18 @@ public class AudioManagerImpl implements AudioManager, ConfigOptionProvider {
|
||||||
AudioSink sink = getSink(sinkId);
|
AudioSink sink = getSink(sinkId);
|
||||||
if (sink != null) {
|
if (sink != null) {
|
||||||
PercentType oldVolume = null;
|
PercentType oldVolume = null;
|
||||||
try {
|
|
||||||
// get current volume
|
|
||||||
oldVolume = getVolume(sinkId);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.debug("An exception occurred while getting the volume of sink '{}' : {}", sink.getId(),
|
|
||||||
e.getMessage(), e);
|
|
||||||
}
|
|
||||||
// set notification sound volume
|
// set notification sound volume
|
||||||
if (volume != null) {
|
if (volume != null) {
|
||||||
try {
|
try {
|
||||||
setVolume(volume, sinkId);
|
// get current volume
|
||||||
|
oldVolume = sink.getVolume();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.debug("An exception occurred while getting the volume of sink '{}' : {}", sink.getId(),
|
||||||
|
e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
sink.setVolume(volume);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.debug("An exception occurred while setting the volume of sink '{}' : {}", sink.getId(),
|
logger.debug("An exception occurred while setting the volume of sink '{}' : {}", sink.getId(),
|
||||||
e.getMessage(), e);
|
e.getMessage(), e);
|
||||||
|
@ -147,7 +148,7 @@ public class AudioManagerImpl implements AudioManager, ConfigOptionProvider {
|
||||||
if (volume != null && oldVolume != null) {
|
if (volume != null && oldVolume != null) {
|
||||||
// restore volume only if it was set before
|
// restore volume only if it was set before
|
||||||
try {
|
try {
|
||||||
setVolume(oldVolume, sinkId);
|
sink.setVolume(oldVolume);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.debug("An exception occurred while setting the volume of sink '{}' : {}", sink.getId(),
|
logger.debug("An exception occurred while setting the volume of sink '{}' : {}", sink.getId(),
|
||||||
e.getMessage(), e);
|
e.getMessage(), e);
|
||||||
|
|
|
@ -255,17 +255,18 @@ public class VoiceManagerImpl implements VoiceManager, ConfigOptionProvider, Dia
|
||||||
}
|
}
|
||||||
|
|
||||||
PercentType oldVolume = null;
|
PercentType oldVolume = null;
|
||||||
try {
|
|
||||||
// get current volume
|
|
||||||
oldVolume = audioManager.getVolume(sinkId);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.debug("An exception occurred while getting the volume of sink '{}' : {}", sink.getId(),
|
|
||||||
e.getMessage(), e);
|
|
||||||
}
|
|
||||||
// set notification sound volume
|
// set notification sound volume
|
||||||
if (volume != null) {
|
if (volume != null) {
|
||||||
try {
|
try {
|
||||||
audioManager.setVolume(volume, sinkId);
|
// get current volume
|
||||||
|
oldVolume = sink.getVolume();
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.debug("An exception occurred while getting the volume of sink '{}' : {}", sink.getId(),
|
||||||
|
e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
sink.setVolume(volume);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.debug("An exception occurred while setting the volume of sink '{}' : {}", sink.getId(),
|
logger.debug("An exception occurred while setting the volume of sink '{}' : {}", sink.getId(),
|
||||||
e.getMessage(), e);
|
e.getMessage(), e);
|
||||||
|
@ -277,7 +278,7 @@ public class VoiceManagerImpl implements VoiceManager, ConfigOptionProvider, Dia
|
||||||
if (volume != null && oldVolume != null) {
|
if (volume != null && oldVolume != null) {
|
||||||
// restore volume only if it was set before
|
// restore volume only if it was set before
|
||||||
try {
|
try {
|
||||||
audioManager.setVolume(oldVolume, sinkId);
|
sink.setVolume(oldVolume);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.debug("An exception occurred while setting the volume of sink '{}' : {}", sink.getId(),
|
logger.debug("An exception occurred while setting the volume of sink '{}' : {}", sink.getId(),
|
||||||
e.getMessage(), e);
|
e.getMessage(), e);
|
||||||
|
|
Loading…
Reference in New Issue