1 /*
2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
28 import java.io.DataInputStream;
29 import java.io.IOException;
30 import java.io.InputStream;
31
32 import javax.sound.sampled.AudioFileFormat;
33 import javax.sound.sampled.spi.AudioFileWriter;
34
35 /**
36 * Abstract File Writer class.
37 *
38 * @author Jan Borgersen
39 */
40 abstract class SunFileWriter extends AudioFileWriter {
41
42 // buffer size for write
43 protected static final int bufferSize = 16384;
44
45 // buffer size for temporary input streams
46 protected static final int bisBufferSize = 4096;
47
48 final AudioFileFormat.Type types[];
49
50 /**
51 * Constructs a new SunParser object.
52 */
53 SunFileWriter(AudioFileFormat.Type types[]) {
54 this.types = types;
55 }
56
57 // METHODS TO IMPLEMENT AudioFileWriter
58
59 @Override
60 public final AudioFileFormat.Type[] getAudioFileTypes(){
61 AudioFileFormat.Type[] localArray = new AudioFileFormat.Type[types.length];
62 System.arraycopy(types, 0, localArray, 0, types.length);
63 return localArray;
64 }
65
66 // HELPER METHODS
67
68 /**
69 * rllong
70 * Protected helper method to read 64 bits and changing the order of
71 * each bytes.
72 * @return 32 bits swapped value.
73 * @exception IOException
147 }
148
149 /**
150 * InputStream wrapper class which prevent source stream from being closed.
151 * The class is usefull for use with SequenceInputStream to prevent
152 * closing of the source input streams.
153 */
154 final class NoCloseInputStream extends InputStream {
155 private final InputStream in;
156
157 NoCloseInputStream(InputStream in) {
158 this.in = in;
159 }
160
161 @Override
162 public int read() throws IOException {
163 return in.read();
164 }
165
166 @Override
167 public int read(byte b[]) throws IOException {
168 return in.read(b);
169 }
170
171 @Override
172 public int read(byte b[], int off, int len) throws IOException {
173 return in.read(b, off, len);
174 }
175
176 @Override
177 public long skip(long n) throws IOException {
178 return in.skip(n);
179 }
180
181 @Override
182 public int available() throws IOException {
183 return in.available();
184 }
185
186 @Override
187 public void close() throws IOException {
188 // don't propagate the call
189 }
190
191 @Override
192 public void mark(int readlimit) {
|
1 /*
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
28 import java.io.DataInputStream;
29 import java.io.IOException;
30 import java.io.InputStream;
31
32 import javax.sound.sampled.AudioFileFormat;
33 import javax.sound.sampled.spi.AudioFileWriter;
34
35 /**
36 * Abstract File Writer class.
37 *
38 * @author Jan Borgersen
39 */
40 abstract class SunFileWriter extends AudioFileWriter {
41
42 // buffer size for write
43 protected static final int bufferSize = 16384;
44
45 // buffer size for temporary input streams
46 protected static final int bisBufferSize = 4096;
47
48 final AudioFileFormat.Type[] types;
49
50 /**
51 * Constructs a new SunParser object.
52 */
53 SunFileWriter(AudioFileFormat.Type[] types) {
54 this.types = types;
55 }
56
57 // METHODS TO IMPLEMENT AudioFileWriter
58
59 @Override
60 public final AudioFileFormat.Type[] getAudioFileTypes(){
61 AudioFileFormat.Type[] localArray = new AudioFileFormat.Type[types.length];
62 System.arraycopy(types, 0, localArray, 0, types.length);
63 return localArray;
64 }
65
66 // HELPER METHODS
67
68 /**
69 * rllong
70 * Protected helper method to read 64 bits and changing the order of
71 * each bytes.
72 * @return 32 bits swapped value.
73 * @exception IOException
147 }
148
149 /**
150 * InputStream wrapper class which prevent source stream from being closed.
151 * The class is usefull for use with SequenceInputStream to prevent
152 * closing of the source input streams.
153 */
154 final class NoCloseInputStream extends InputStream {
155 private final InputStream in;
156
157 NoCloseInputStream(InputStream in) {
158 this.in = in;
159 }
160
161 @Override
162 public int read() throws IOException {
163 return in.read();
164 }
165
166 @Override
167 public int read(byte[] b) throws IOException {
168 return in.read(b);
169 }
170
171 @Override
172 public int read(byte[] b, int off, int len) throws IOException {
173 return in.read(b, off, len);
174 }
175
176 @Override
177 public long skip(long n) throws IOException {
178 return in.skip(n);
179 }
180
181 @Override
182 public int available() throws IOException {
183 return in.available();
184 }
185
186 @Override
187 public void close() throws IOException {
188 // don't propagate the call
189 }
190
191 @Override
192 public void mark(int readlimit) {
|