From 8ba97026a413b6187e2282b2c1e5f2f54ea3bfb4 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 27 Jul 2019 16:28:51 +0000 Subject: [PATCH] Synchronize on activeAudioPlayers when changing them --- .../player/service/JukeboxJavaService.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/service/JukeboxJavaService.java b/airsonic-main/src/main/java/org/airsonic/player/service/JukeboxJavaService.java index b22194a4..98dc7ffb 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/service/JukeboxJavaService.java +++ b/airsonic-main/src/main/java/org/airsonic/player/service/JukeboxJavaService.java @@ -255,17 +255,19 @@ public class JukeboxJavaService { return airsonicPlayer.getPlayQueue().getIndex(); } }); - // Close any other player using the same mixer. - String mixer = airsonicPlayer.getJavaJukeboxMixer(); - if (StringUtils.isBlank(mixer)) { - mixer = DEFAULT_MIXER_ENTRY_KEY; - } - List playersForSameMixer = activeAudioPlayersPerMixer.get(mixer); - playersForSameMixer.forEach(player -> { - if (player != audioPlayer) { - player.close(); + synchronized (activeAudioPlayers) { + // Close any other player using the same mixer. + String mixer = airsonicPlayer.getJavaJukeboxMixer(); + if (StringUtils.isBlank(mixer)) { + mixer = DEFAULT_MIXER_ENTRY_KEY; } - }); + List playersForSameMixer = activeAudioPlayersPerMixer.get(mixer); + playersForSameMixer.forEach(player -> { + if (player != audioPlayer) { + player.close(); + } + }); + } audioPlayer.play(); } }