JDK-4849790 : Closing audio sampling line can hang system
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.sound
  • Affected Version: 1.3.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2003-04-17
  • Updated: 2003-04-17
  • Resolved: 2003-04-17
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 04/16/2003


FULL PRODUCT VERSION :
[d:\test\multrun]java -version
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01a)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
AND
[d:\test\multrun]java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_b01)
Java HotSpot(TM) Client VM (build 1.4.1_b01, mixed mode)


FULL OPERATING SYSTEM VERSION :
Windows 2000 workstation

ADDITIONAL OPERATING SYSTEMS :

Windows 4.0 Server service pack6

EXTRA RELEVANT SYSTEM CONFIGURATION :
Problem can be seen more on a single processor machine than
on a dual processor system

A DESCRIPTION OF THE PROBLEM :
Sometimes when calling
javax.sound.sampled.TargetDataLine.close the system hangs.
I am writting a multithreaded research prototype using
audio routines from the university of california.  The
SoundCapture class method has a stopCapture method that
calls TargetDataLine.close.   On occation when this is done
the thread hangs or is blocked.  This happends more
frequently >15% of the time when there are few system calls
or thread yield.  It also happens more frequently on single
processor machines.

REPRODUCIBILITY :
This bug can be reproduced occasionally.

---------- BEGIN SOURCE ----------
public void stopCapture() throws IOException {
	_isAudioCaptureActive = false;
	// Free up audio system resources.
	// For capture from file:
        /** @todo Remove Debug */
        System.out.print("00");
	if (_audioInputStream != null) {
	    _audioInputStream.close();
	}
        System.out.print("11");
	if (_properFormatAudioInputStream != null) {
	    _properFormatAudioInputStream.close();
	}
        System.out.print("22");
	// For real-time capture:
	if (_targetLine != null) {
            System.out.print("aa");

	    if (_targetLine.isOpen() == true) {
                System.out.print("bb");
		_targetLine.stop();
                System.out.print("cc");
		_targetLine.close();  //This is the call the hangs
                System.out.print("dd");
		_targetLine = null;
                System.out.print("ee");
	    }
	}
        System.out.println("33");

    }

---------- END SOURCE ----------

CUSTOMER WORKAROUND :
The problem can be reduced to about 1% occurrence with
frequent thread yields and system calls.  Also a kludge
could be to spawn a thread to do the close and then let
that thread do the job or hang without affecting the rest
of the program
(Review ID: 166443) 
======================================================================

Comments
EVALUATION ###@###.### 2003-04-17 This bug was already filed with #4842416.
17-04-2003