# HG changeset patch # User serb # Date 1499381679 25200 # Node ID f70b20f6b3f28e31c1577f281114167882bba948 # Parent cc7390224989275a05fabc63861d4182ccd02cc9 8178403: DirectAudio in JavaSound may hang and leak Reviewed-by: prr, alitvinov diff -r cc7390224989 -r f70b20f6b3f2 jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java Thu Jul 06 09:22:45 2017 -0700 +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java Thu Jul 06 15:54:39 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1351,18 +1351,14 @@ // pre-empted while another thread changes doIO and notifies, // before we wait (so we sleep in wait forever). synchronized(lock) { - if (!doIO) { + while (!doIO && thread == curThread) { try { lock.wait(); - } catch(InterruptedException ie) { - } finally { - if (thread != curThread) { - break; - } + } catch (InterruptedException ignored) { } } } - while (doIO) { + while (doIO && thread == curThread) { if (newFramePosition >= 0) { clipBytePosition = newFramePosition * frameSize; newFramePosition = -1; diff -r cc7390224989 -r f70b20f6b3f2 jdk/test/ProblemList.txt --- a/jdk/test/ProblemList.txt Thu Jul 06 09:22:45 2017 -0700 +++ b/jdk/test/ProblemList.txt Thu Jul 06 15:54:39 2017 -0700 @@ -223,8 +223,6 @@ # jdk_sound javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java 8178401 windows-all -javax/sound/sampled/Clip/ClipCloseLoss.java 8178403 generic-all - javax/sound/sampled/DirectAudio/bug6372428.java 8055097 generic-all javax/sound/sampled/Clip/bug5070081.java 8055097 generic-all javax/sound/sampled/DataLine/LongFramePosition.java 8055097 generic-all diff -r cc7390224989 -r f70b20f6b3f2 jdk/test/javax/sound/sampled/Clip/ClipCloseLoss.java --- a/jdk/test/javax/sound/sampled/Clip/ClipCloseLoss.java Thu Jul 06 09:22:45 2017 -0700 +++ b/jdk/test/javax/sound/sampled/Clip/ClipCloseLoss.java Thu Jul 06 15:54:39 2017 -0700 @@ -33,10 +33,9 @@ /** * @test - * @bug 4946913 + * @bug 4946913 8178403 * @summary DirectClip doesn't kill the thread correctly, sometimes * @run main/othervm ClipCloseLoss - * @key intermittent */ public class ClipCloseLoss { static int frameCount = 441000; // lets say 10 seconds @@ -47,7 +46,7 @@ static int success = 0; static boolean failed = false; - public static void run(Mixer m) { + public static void run(Mixer m, long sleep) { Clip clip = null; try { if (m == null) { @@ -69,6 +68,8 @@ clip.open(new AudioInputStream(bais, format, frameCount)); out(" clip.close()"); + // emulates a different delay between open() and close() + Thread.sleep(sleep); //long t = System.currentTimeMillis(); clip.close(); //if (System.currentTimeMillis() - t > 1950) { @@ -107,13 +108,15 @@ public static void main(String[] args) throws Exception { if (isSoundcardInstalled()) { bais.mark(0); - run(null); Mixer.Info[] infos = AudioSystem.getMixerInfo(); - for (int i = 0; i