Audiosink might be null (#2224)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp
2021-03-06 16:49:44 +01:00
committed by GitHub
parent 4e27285e5f
commit 11c59ccc87
2 changed files with 9 additions and 5 deletions
@@ -44,7 +44,7 @@ public class PlayActionHandler extends BaseActionModuleHandler {
private final AudioManager audioManager;
private final String sound;
private final String sink;
private final @Nullable String sink;
private final @Nullable PercentType volume;
public PlayActionHandler(Action module, AudioManager audioManager) {
@@ -52,7 +52,9 @@ public class PlayActionHandler extends BaseActionModuleHandler {
this.audioManager = audioManager;
this.sound = module.getConfiguration().get(PARAM_SOUND).toString();
this.sink = module.getConfiguration().get(PARAM_SINK).toString();
Object sinkParam = module.getConfiguration().get(PARAM_SINK);
this.sink = sinkParam != null ? sinkParam.toString() : null;
Object volumeParam = module.getConfiguration().get(PARAM_VOLUME);
this.volume = volumeParam instanceof BigDecimal ? new PercentType((BigDecimal) volumeParam) : null;
@@ -39,15 +39,17 @@ public class SayActionHandler extends BaseActionModuleHandler {
private final VoiceManager voiceManager;
private final String text;
private final String sink;
private final @Nullable String sink;
private final @Nullable PercentType volume;
public SayActionHandler(Action module, VoiceManager voiceManager) {
super(module);
this.voiceManager = voiceManager;
text = module.getConfiguration().get(PARAM_TEXT).toString();
sink = module.getConfiguration().get(PARAM_SINK).toString();
this.text = module.getConfiguration().get(PARAM_TEXT).toString();
Object sinkParam = module.getConfiguration().get(PARAM_SINK);
this.sink = sinkParam != null ? sinkParam.toString() : null;
Object volumeParam = module.getConfiguration().get(PARAM_VOLUME);
this.volume = volumeParam instanceof BigDecimal ? new PercentType((BigDecimal) volumeParam) : null;