8178403: DirectAudio in JavaSound may hang and leak
Reviewed-by: prr, alitvinov
This commit is contained in:
parent
c0daae63a2
commit
54ad5390d0
@ -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 @@ final class DirectAudioDevice extends AbstractMixer {
|
||||
// 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;
|
||||
|
@ -223,8 +223,6 @@ sun/security/ssl/X509KeyManager/PreferredKey.java 8176354 generic-
|
||||
# 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
|
||||
|
@ -33,10 +33,9 @@ import javax.sound.sampled.Mixer;
|
||||
|
||||
/**
|
||||
* @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 @@ public class ClipCloseLoss {
|
||||
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 @@ public class ClipCloseLoss {
|
||||
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,15 +108,17 @@ public class ClipCloseLoss {
|
||||
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<infos.length; i++) {
|
||||
for (int sleep = 0; sleep < 100; ++sleep) {
|
||||
run(null, sleep);
|
||||
for (int i = 0; i < infos.length; i++) {
|
||||
try {
|
||||
Mixer m = AudioSystem.getMixer(infos[i]);
|
||||
run(m);
|
||||
run(m, sleep);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
out("Waiting 1 second to dispose of all threads");
|
||||
Thread.sleep(1000);
|
||||
if (getClipThreadCount() > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user