Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JDK 17 java.desktop.jmod - Desktop Module
JDK 17 java.desktop.jmod is the JMOD file for JDK 17 Desktop module.
JDK 17 Desktop module compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\java.desktop.jmod.
JDK 17 Desktop module compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.
JDK 17 Desktop module source code files are stored in \fyicenter\jdk-17.0.5\lib\src.zip\java.desktop.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ com/sun/media/sound/DataPusher.java
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.sun.media.sound;
import java.util.Arrays;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.SourceDataLine;
/**
* Class to write an AudioInputStream to a SourceDataLine.
* Was previously an inner class in various classes like JavaSoundAudioClip
* and sun.audio.AudioDevice.
* It auto-opens and closes the SourceDataLine.
*
* @author Kara Kytle
* @author Florian Bomers
*/
public final class DataPusher implements Runnable {
private static final int AUTO_CLOSE_TIME = 5000;
private final SourceDataLine source;
private final AudioFormat format;
// stream as source data
private final AudioInputStream ais;
// byte array as source data
private final byte[] audioData;
private final int audioDataByteLength;
private int pos;
private int newPos = -1;
private boolean looping;
private Thread pushThread = null;
private int wantedState;
private int threadState;
private final int STATE_NONE = 0;
private final int STATE_PLAYING = 1;
private final int STATE_WAITING = 2;
private final int STATE_STOPPING = 3;
private final int STATE_STOPPED = 4;
private final int BUFFER_SIZE = 16384;
public DataPusher(SourceDataLine sourceLine, AudioFormat format, byte[] audioData, int byteLength) {
this(sourceLine, format, null, audioData, byteLength);
}
public DataPusher(SourceDataLine sourceLine, AudioInputStream ais) {
this(sourceLine, ais.getFormat(), ais, null, 0);
}
private DataPusher(final SourceDataLine source, final AudioFormat format,
final AudioInputStream ais, final byte[] audioData,
final int audioDataByteLength) {
this.source = source;
this.format = format;
this.ais = ais;
this.audioDataByteLength = audioDataByteLength;
this.audioData = audioData == null ? null : Arrays.copyOf(audioData,
audioData.length);
}
public synchronized void start() {
start(false);
}
public synchronized void start(boolean loop) {
try {
if (threadState == STATE_STOPPING) {
// wait that the thread has finished stopping
stop();
}
looping = loop;
newPos = 0;
wantedState = STATE_PLAYING;
if (!source.isOpen()) {
source.open(format);
}
source.flush();
source.start();
if (pushThread == null) {
pushThread = JSSecurityManager.createThread(this,
null, // name
false, // daemon
-1, // priority
true); // doStart
}
notifyAll();
} catch (Exception e) {
if (Printer.err) e.printStackTrace();
}
}
public synchronized void stop() {
if (threadState == STATE_STOPPING
|| threadState == STATE_STOPPED
|| pushThread == null) {
return;
}
wantedState = STATE_WAITING;
if (source != null) {
source.flush();
}
notifyAll();
int maxWaitCount = 50; // 5 seconds
while ((maxWaitCount-- >= 0) && (threadState == STATE_PLAYING)) {
try {
wait(100);
} catch (InterruptedException e) { }
}
}
synchronized void close() {
if (source != null) {
source.close();
}
}
/**
* Write data to the source data line.
*/
@Override
public void run() {
byte[] buffer = null;
boolean useStream = (ais != null);
if (useStream) {
buffer = new byte[BUFFER_SIZE];
} else {
buffer = audioData;
}
while (wantedState != STATE_STOPPING) {
//try {
if (wantedState == STATE_WAITING) {
// wait for 5 seconds - maybe the clip is to be played again
try {
synchronized(this) {
threadState = STATE_WAITING;
wantedState = STATE_STOPPING;
wait(AUTO_CLOSE_TIME);
}
} catch (InterruptedException ie) {}
continue;
}
if (newPos >= 0) {
pos = newPos;
newPos = -1;
}
threadState = STATE_PLAYING;
int toWrite = BUFFER_SIZE;
if (useStream) {
try {
pos = 0; // always write from beginning of buffer
// don't use read(byte[]), because some streams
// may not override that method
toWrite = ais.read(buffer, 0, buffer.length);
} catch (java.io.IOException ioe) {
// end of stream
toWrite = -1;
}
} else {
if (toWrite > audioDataByteLength - pos) {
toWrite = audioDataByteLength - pos;
}
if (toWrite == 0) {
toWrite = -1; // end of "stream"
}
}
if (toWrite < 0) {
if (!useStream && looping) {
pos = 0;
continue;
}
wantedState = STATE_WAITING;
source.drain();
continue;
}
int bytesWritten = source.write(buffer, pos, toWrite);
pos += bytesWritten;
}
threadState = STATE_STOPPING;
source.flush();
source.stop();
source.flush();
source.close();
threadState = STATE_STOPPED;
synchronized (this) {
pushThread = null;
notifyAll();
}
}
} // class DataPusher
⏎ com/sun/media/sound/DataPusher.java
Or download all of them as a single archive file:
File name: java.desktop-17.0.5-src.zip File size: 9152233 bytes Release date: 2022-09-13 Download
⇒ JDK 17 java.instrument.jmod - Instrument Module
2023-09-16, ≈263🔥, 0💬
Popular Posts:
What Is XMLBeans xbean.jar 2.6.0? XMLBeans xbean.jar 2.6.0 is the JAR file for Apache XMLBeans 2.6.0...
JDK 17 jdk.javadoc.jmod is the JMOD file for JDK 17 Java Document tool, which can be invoked by the ...
layout.jar is a component in iText Java library to provide layout functionalities. iText Java librar...
Joda-Time provides a quality replacement for the Java date and time classes. The design allows for m...
JDK 11 jdk.internal.opt.jmod is the JMOD file for JDK 11 Internal Opt module. JDK 11 Internal Opt mo...