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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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,
|
// pre-empted while another thread changes doIO and notifies,
|
||||||
// before we wait (so we sleep in wait forever).
|
// before we wait (so we sleep in wait forever).
|
||||||
synchronized(lock) {
|
synchronized(lock) {
|
||||||
if (!doIO) {
|
while (!doIO && thread == curThread) {
|
||||||
try {
|
try {
|
||||||
lock.wait();
|
lock.wait();
|
||||||
} catch(InterruptedException ie) {
|
} catch (InterruptedException ignored) {
|
||||||
} finally {
|
|
||||||
if (thread != curThread) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (doIO) {
|
while (doIO && thread == curThread) {
|
||||||
if (newFramePosition >= 0) {
|
if (newFramePosition >= 0) {
|
||||||
clipBytePosition = newFramePosition * frameSize;
|
clipBytePosition = newFramePosition * frameSize;
|
||||||
newFramePosition = -1;
|
newFramePosition = -1;
|
||||||
|
@ -223,8 +223,6 @@ sun/security/ssl/X509KeyManager/PreferredKey.java 8176354 generic-
|
|||||||
# jdk_sound
|
# jdk_sound
|
||||||
javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java 8178401 windows-all
|
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/DirectAudio/bug6372428.java 8055097 generic-all
|
||||||
javax/sound/sampled/Clip/bug5070081.java 8055097 generic-all
|
javax/sound/sampled/Clip/bug5070081.java 8055097 generic-all
|
||||||
javax/sound/sampled/DataLine/LongFramePosition.java 8055097 generic-all
|
javax/sound/sampled/DataLine/LongFramePosition.java 8055097 generic-all
|
||||||
|
@ -33,10 +33,9 @@ import javax.sound.sampled.Mixer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 4946913
|
* @bug 4946913 8178403
|
||||||
* @summary DirectClip doesn't kill the thread correctly, sometimes
|
* @summary DirectClip doesn't kill the thread correctly, sometimes
|
||||||
* @run main/othervm ClipCloseLoss
|
* @run main/othervm ClipCloseLoss
|
||||||
* @key intermittent
|
|
||||||
*/
|
*/
|
||||||
public class ClipCloseLoss {
|
public class ClipCloseLoss {
|
||||||
static int frameCount = 441000; // lets say 10 seconds
|
static int frameCount = 441000; // lets say 10 seconds
|
||||||
@ -47,7 +46,7 @@ public class ClipCloseLoss {
|
|||||||
static int success = 0;
|
static int success = 0;
|
||||||
static boolean failed = false;
|
static boolean failed = false;
|
||||||
|
|
||||||
public static void run(Mixer m) {
|
public static void run(Mixer m, long sleep) {
|
||||||
Clip clip = null;
|
Clip clip = null;
|
||||||
try {
|
try {
|
||||||
if (m == null) {
|
if (m == null) {
|
||||||
@ -69,6 +68,8 @@ public class ClipCloseLoss {
|
|||||||
clip.open(new AudioInputStream(bais, format, frameCount));
|
clip.open(new AudioInputStream(bais, format, frameCount));
|
||||||
|
|
||||||
out(" clip.close()");
|
out(" clip.close()");
|
||||||
|
// emulates a different delay between open() and close()
|
||||||
|
Thread.sleep(sleep);
|
||||||
//long t = System.currentTimeMillis();
|
//long t = System.currentTimeMillis();
|
||||||
clip.close();
|
clip.close();
|
||||||
//if (System.currentTimeMillis() - t > 1950) {
|
//if (System.currentTimeMillis() - t > 1950) {
|
||||||
@ -107,13 +108,15 @@ public class ClipCloseLoss {
|
|||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
if (isSoundcardInstalled()) {
|
if (isSoundcardInstalled()) {
|
||||||
bais.mark(0);
|
bais.mark(0);
|
||||||
run(null);
|
|
||||||
Mixer.Info[] infos = AudioSystem.getMixerInfo();
|
Mixer.Info[] infos = AudioSystem.getMixerInfo();
|
||||||
for (int i = 0; i<infos.length; i++) {
|
for (int sleep = 0; sleep < 100; ++sleep) {
|
||||||
try {
|
run(null, sleep);
|
||||||
Mixer m = AudioSystem.getMixer(infos[i]);
|
for (int i = 0; i < infos.length; i++) {
|
||||||
run(m);
|
try {
|
||||||
} catch (Exception e) {
|
Mixer m = AudioSystem.getMixer(infos[i]);
|
||||||
|
run(m, sleep);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out("Waiting 1 second to dispose of all threads");
|
out("Waiting 1 second to dispose of all threads");
|
||||||
|
Loading…
Reference in New Issue
Block a user