Source Code Cross Referenced for TargetDataLine.java in  » 6.0-JDK-Core » sound » javax » sound » sampled » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » sound » javax.sound.sampled 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1999-2003 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.sound.sampled;
027
028        /**
029         * A target data line is a type of <code>{@link DataLine}</code> from which 
030         * audio data can be read.  The most common example is a data line that gets
031         * its data from an audio capture device.  (The device is implemented as a
032         * mixer that writes to the target data line.)
033         * <p>
034         * Note that the naming convention for this interface reflects the relationship
035         * between the line and its mixer.  From the perspective of an application,
036         * a target data line may act as a source for audio data.
037         * <p>
038         * The target data line can be obtained from a mixer by invoking the 
039         * <code>{@link Mixer#getLine getLine}</code> 
040         * method of <code>Mixer</code> with an appropriate 
041         * <code>{@link DataLine.Info}</code> object.
042         * <p>
043         * The <code>TargetDataLine</code> interface provides a method for reading the
044         * captured data from the target data line's buffer.Applications 
045         * that record audio should read data from the target data line quickly enough 
046         * to keep the buffer from overflowing, which could cause discontinuities in 
047         * the captured data that are perceived as clicks.  Applications can use the 
048         * <code>{@link DataLine#available available}</code> method defined in the
049         * <code>DataLine</code> interface to determine the amount of data currently
050         * queued in the data line's buffer.  If the buffer does overflow,
051         * the oldest queued data is discarded and replaced by new data.
052         * 
053         * @author Kara Kytle
054         * @version 1.27 07/05/05
055         * @see Mixer
056         * @see DataLine
057         * @see SourceDataLine
058         * @since 1.3
059         */
060        public interface TargetDataLine extends DataLine {
061
062            /**
063             * Opens the line with the specified format and requested buffer size,
064             * causing the line to acquire any required system resources and become 
065             * operational.  
066             * <p>
067             * The buffer size is specified in bytes, but must represent an integral 
068             * number of sample frames.  Invoking this method with a requested buffer 
069             * size that does not meet this requirement may result in an 
070             * IllegalArgumentException.  The actual buffer size for the open line may 
071             * differ from the requested buffer size.  The value actually set may be 
072             * queried by subsequently calling <code>{@link DataLine#getBufferSize}</code>  
073             * <p>
074             * If this operation succeeds, the line is marked as open, and an 
075             * <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched to the 
076             * line's listeners.
077             * <p>
078             * Invoking this method on a line that is already open is illegal
079             * and may result in an <code>IllegalStateException</code>.
080             * <p>
081             * Some lines, once closed, cannot be reopened.  Attempts
082             * to reopen such a line will always result in a 
083             * <code>LineUnavailableException</code>.
084             *
085             * @param format the desired audio format
086             * @param bufferSize the desired buffer size, in bytes.
087             * @throws LineUnavailableException if the line cannot be
088             * opened due to resource restrictions
089             * @throws IllegalArgumentException if the buffer size does not represent
090             * an integral number of sample frames,
091             * or if <code>format</code> is not fully specified or invalid
092             * @throws IllegalStateException if the line is already open
093             * @throws SecurityException if the line cannot be
094             * opened due to security restrictions
095             *
096             * @see #open(AudioFormat)
097             * @see Line#open
098             * @see Line#close
099             * @see Line#isOpen
100             * @see LineEvent
101             */
102            public void open(AudioFormat format, int bufferSize)
103                    throws LineUnavailableException;
104
105            /**
106             * Opens the line with the specified format, causing the line to acquire any 
107             * required system resources and become operational.  
108             *   
109             * <p>
110             * The implementation chooses a buffer size, which is measured in bytes but 
111             * which encompasses an integral number of sample frames.  The buffer size 
112             * that the system has chosen may be queried by subsequently calling <code>{@link DataLine#getBufferSize}</code>  
113             * <p>
114             * If this operation succeeds, the line is marked as open, and an 
115             * <code>{@link LineEvent.Type#OPEN OPEN}</code> event is dispatched to the 
116             * line's listeners.
117             * <p>
118             * Invoking this method on a line that is already open is illegal
119             * and may result in an <code>IllegalStateException</code>.
120             * <p>
121             * Some lines, once closed, cannot be reopened.  Attempts
122             * to reopen such a line will always result in a 
123             * <code>LineUnavailableException</code>.
124             *
125             * @param format the desired audio format
126             * @throws LineUnavailableException if the line cannot be
127             * opened due to resource restrictions
128             * @throws IllegalArgumentException if <code>format</code>
129             * is not fully specified or invalid
130             * @throws IllegalStateException if the line is already open
131             * @throws SecurityException if the line cannot be
132             * opened due to security restrictions
133             *
134             * @see #open(AudioFormat, int)
135             * @see Line#open
136             * @see Line#close
137             * @see Line#isOpen
138             * @see LineEvent
139             */
140            public void open(AudioFormat format)
141                    throws LineUnavailableException;
142
143            /**
144             * Reads audio data from the data line's input buffer.   The requested 
145             * number of bytes is read into the specified array, starting at
146             * the specified offset into the array in bytes.  This method blocks until
147             * the requested amount of data has been read.  However, if the data line 
148             * is closed, stopped, drained, or flushed before the requested amount has 
149             * been read, the method no longer blocks, but returns the number of bytes
150             * read thus far. 
151             * <p>
152             * The number of bytes that can be read without blocking can be ascertained
153             * using the <code>{@link DataLine#available available}</code> method of the
154             * <code>DataLine</code> interface.  (While it is guaranteed that
155             * this number of bytes can be read without blocking, there is no guarantee
156             * that attempts to read additional data will block.)
157             * <p>
158             * The number of bytes to be read must represent an integral number of
159             * sample frames, such that:
160             * <br>
161             * <center><code>[ bytes read ] % [frame size in bytes ] == 0</code></center>
162             * <br>
163             * The return value will always meet this requirement.  A request to read a 
164             * number of bytes representing a non-integral number of sample frames cannot 
165             * be fulfilled and may result in an IllegalArgumentException.
166             *
167             * @param b a byte array that will contain the requested input data when 
168             * this method returns
169             * @param off the offset from the beginning of the array, in bytes
170             * @param len the requested number of bytes to read
171             * @return the number of bytes actually read
172             * @throws IllegalArgumentException if the requested number of bytes does
173             * not represent an integral number of sample frames.
174             * or if <code>len</code> is negative.
175             * @throws ArrayIndexOutOfBoundsException if <code>off</code> is negative,
176             * or <code>off+len</code> is greater than the length of the array
177             * <code>b</code>. 
178             *
179             * @see SourceDataLine#write
180             * @see DataLine#available
181             */
182            public int read(byte[] b, int off, int len);
183
184            /**
185             * Obtains the number of sample frames of audio data that can be read from 
186             * the target data line without blocking.  Note that the return value 
187             * measures sample frames, not bytes.
188             * @return the number of sample frames currently available for reading
189             * @see SourceDataLine#availableWrite
190             */
191            //public int availableRead();
192        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.