📄 dataline.html
字号:
This method blocks until the draining is complete. Because this is a blocking method, it should be used with care. If <code>drain()</code> is invoked on a stopped line that has data in its queue, the method will block until the line is running and the data queue becomes empty. If <code>drain()</code> is invoked by one thread, and another continues to fill the data queue, the operation will not complete. This method always returns when the data line is closed.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/DataLine.html#flush()"><CODE>flush()</CODE></A></DL></DD></DL><HR><A NAME="flush()"><!-- --></A><H3>flush</H3><PRE>public void <B>flush</B>()</PRE><DL><DD>Flushes queued data from the line. The flushed data is discarded. In some cases, not all queued data can be discarded. For example, a mixer can flush data from the buffer for a specific input line, but any unplayed data already in the output buffer (the result of the mix) will still be played. You can invoke this method after pausing a line (the normal case) if you want to skip the "stale" data when you restart playback or capture. (It is legal to flush a line that is not stopped, but doing so on an active line is likely to cause a discontinuity in the data, resulting in a perceptible click.)<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/DataLine.html#stop()"><CODE>stop()</CODE></A>, <A HREF="../../../javax/sound/sampled/DataLine.html#drain()"><CODE>drain()</CODE></A></DL></DD></DL><HR><A NAME="start()"><!-- --></A><H3>start</H3><PRE>public void <B>start</B>()</PRE><DL><DD>Allows a line to engage in data I/O. If invoked on a line that is already running, this method does nothing. Unless the data in the buffer has been flushed, the line resumes I/O starting with the first frame that was unprocessed at the time the line was stopped. When audio capture or playback starts, a <code><A HREF="../../../javax/sound/sampled/LineEvent.Type.html#START"><CODE>START</CODE></A></code> event is generated.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/DataLine.html#stop()"><CODE>stop()</CODE></A>, <A HREF="../../../javax/sound/sampled/DataLine.html#isRunning()"><CODE>isRunning()</CODE></A>, <A HREF="../../../javax/sound/sampled/LineEvent.html"><CODE>LineEvent</CODE></A></DL></DD></DL><HR><A NAME="stop()"><!-- --></A><H3>stop</H3><PRE>public void <B>stop</B>()</PRE><DL><DD>Stops the line. A stopped line should cease I/O activity. If the line is open and running, however, it should retain the resources required to resume activity. A stopped line should retain any audio data in its buffer instead of discarding it, so that upon resumption the I/O can continue where it left off, if possible. (This doesn't guarantee that there will never be discontinuities beyond the current buffer, of course; if the stopped condition continues for too long, input or output samples might be dropped.) If desired, the retained data can be discarded by invoking the <code>flush</code> method. When audio capture or playback stops, a <code><A HREF="../../../javax/sound/sampled/LineEvent.Type.html#STOP"><CODE>STOP</CODE></A></code> event is generated.<DD><DL></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/DataLine.html#start()"><CODE>start()</CODE></A>, <A HREF="../../../javax/sound/sampled/DataLine.html#isRunning()"><CODE>isRunning()</CODE></A>, <A HREF="../../../javax/sound/sampled/DataLine.html#flush()"><CODE>flush()</CODE></A>, <A HREF="../../../javax/sound/sampled/LineEvent.html"><CODE>LineEvent</CODE></A></DL></DD></DL><HR><A NAME="isRunning()"><!-- --></A><H3>isRunning</H3><PRE>public boolean <B>isRunning</B>()</PRE><DL><DD>Indicates whether the line is running. The default is <code>false</code>. An open line begins running when the first data is presented in response to an invocation of the <code>start</code> method, and continues until presentation ceases in response to a call to <code>stop</code> or because playback completes.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if the line is running, otherwise <code>false</code><DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/DataLine.html#start()"><CODE>start()</CODE></A>, <A HREF="../../../javax/sound/sampled/DataLine.html#stop()"><CODE>stop()</CODE></A></DL></DD></DL><HR><A NAME="isActive()"><!-- --></A><H3>isActive</H3><PRE>public boolean <B>isActive</B>()</PRE><DL><DD>Indicates whether the line is engaging in active I/O (such as playback or capture). When an inactive line becomes active, it sends a <code><A HREF="../../../javax/sound/sampled/LineEvent.Type.html#START"><CODE>START</CODE></A></code> event to its listeners. Similarly, when an active line becomes inactive, it sends a <code><A HREF="../../../javax/sound/sampled/LineEvent.Type.html#STOP"><CODE>STOP</CODE></A></code> event.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if the line is actively capturing or rendering sound, otherwise <code>false</code><DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/Line.html#isOpen()"><CODE>Line.isOpen()</CODE></A>, <A HREF="../../../javax/sound/sampled/Line.html#addLineListener(javax.sound.sampled.LineListener)"><CODE>Line.addLineListener(javax.sound.sampled.LineListener)</CODE></A>, <A HREF="../../../javax/sound/sampled/Line.html#removeLineListener(javax.sound.sampled.LineListener)"><CODE>Line.removeLineListener(javax.sound.sampled.LineListener)</CODE></A>, <A HREF="../../../javax/sound/sampled/LineEvent.html"><CODE>LineEvent</CODE></A>, <A HREF="../../../javax/sound/sampled/LineListener.html"><CODE>LineListener</CODE></A></DL></DD></DL><HR><A NAME="getFormat()"><!-- --></A><H3>getFormat</H3><PRE>public <A HREF="../../../javax/sound/sampled/AudioFormat.html">AudioFormat</A> <B>getFormat</B>()</PRE><DL><DD>Obtains the current format (encoding, sample rate, number of channels, etc.) of the data line's audio data.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>current audio data format<DT><B>See Also: </B><DD><A HREF="../../../javax/sound/sampled/AudioFormat.html"><CODE>AudioFormat</CODE></A></DL></DD></DL><HR><A NAME="getBufferSize()"><!-- --></A><H3>getBufferSize</H3><PRE>public int <B>getBufferSize</B>()</PRE><DL><DD>Obtains the maximum number of bytes of data that will fit in the data line's internal buffer. For a source data line, this is the size of the buffer to which data can be written. For a target data line, it is the size of the buffer from which data can be read. Note that the units used are bytes, but will always correspond to an integral number of sample frames of audio data.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the size of the buffer in bytes</DL></DD></DL><HR><A NAME="available()"><!-- --></A><H3>available</H3><PRE>public int <B>available</B>()</PRE><DL><DD>Obtains the number of bytes of data currently available to the application for processing in the data line's internal buffer. For a source data line, this is the amount of data that can be written to the buffer without blocking. For a target data line, this is the amount of data available to be read by the application. For a clip, this value is always 0 because the audio data is loaded into the buffer when the clip is opened, and persists without modification until the clip is closed. <p> Note that the units used are bytes, but will always correspond to an integral number of sample frames of audio data. <p> An application is guaranteed that a read or write operation of up to the number of bytes returned from <code>available()</code> will not block; however, there is no guarantee that attempts to read or write more data will block.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the amount of data available, in bytes</DL></DD></DL><HR><A NAME="getFramePosition()"><!-- --></A><H3>getFramePosition</H3><PRE>public int <B>getFramePosition</B>()</PRE><DL><DD>Obtains the current position in the audio data, in sample frames. The frame position measures the number of sample frames captured by, or rendered from, the line since it was opened.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the number of frames already processed since the line was opened</DL></DD></DL><HR><A NAME="getMicrosecondPosition()"><!-- --></A><H3>getMicrosecondPosition</H3><PRE>public long <B>getMicrosecondPosition</B>()</PRE><DL><DD>Obtains the current position in the audio data, in microseconds. The microsecond position measures the time corresponding to the number of sample frames captured by, or rendered from, the line since it was opened. The level of precision is not guaranteed. For example, an implementation might calculate the microsecond position from the current frame position and the audio sample frame rate. The precision in microseconds would then be limited to the number of microseconds per sample frame.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the number of microseconds of data processed since the line was opened</DL></DD></DL><HR><A NAME="getLevel()"><!-- --></A><H3>getLevel</H3><PRE>public float <B>getLevel</B>()</PRE><DL><DD>Obtains the current volume level for the line. This level is a measure of the signal's current amplitude, and should not be confused with the current setting of a gain control. The range is from 0.0 (silence) to 1.0 (maximum possible amplitude for the sound waveform). The units measure linear amplitude, not decibels.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the current amplitude of the signal in this line, or <code><A HREF="../../../javax/sound/sampled/AudioSystem.html#NOT_SPECIFIED"><CODE>AudioSystem.NOT_SPECIFIED</CODE></A></code></DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/DataLine.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/sound/sampled/Clip.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/sound/sampled/Line.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="DataLine.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: <A HREF="#inner_class_summary">INNER</A> | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -