< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/AiffFileWriter.java
Print this page
*** 57,67 ****
*/
public AiffFileWriter() {
super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AIFF});
}
-
// METHODS TO IMPLEMENT AudioFileWriter
@Override
public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) {
--- 57,66 ----
*** 81,91 ****
}
return new AudioFileFormat.Type[0];
}
-
@Override
public int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException {
Objects.requireNonNull(stream);
Objects.requireNonNull(fileType);
Objects.requireNonNull(out);
--- 80,89 ----
*** 100,114 ****
// we must know the total data length to calculate the file length
if( stream.getFrameLength() == AudioSystem.NOT_SPECIFIED ) {
throw new IOException("stream length not specified");
}
! int bytesWritten = writeAiffFile(stream, aiffFileFormat, out);
! return bytesWritten;
}
-
@Override
public int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException {
Objects.requireNonNull(stream);
Objects.requireNonNull(fileType);
Objects.requireNonNull(out);
--- 98,110 ----
// we must know the total data length to calculate the file length
if( stream.getFrameLength() == AudioSystem.NOT_SPECIFIED ) {
throw new IOException("stream length not specified");
}
! return writeAiffFile(stream, aiffFileFormat, out);
}
@Override
public int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException {
Objects.requireNonNull(stream);
Objects.requireNonNull(fileType);
Objects.requireNonNull(out);
*** 171,186 ****
AudioFormat.Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;
AudioFormat streamFormat = stream.getFormat();
AudioFormat.Encoding streamEncoding = streamFormat.getEncoding();
-
- float sampleRate;
int sampleSizeInBits;
- int channels;
- int frameSize;
- float frameRate;
int fileSize;
boolean convert8to16 = false;
if( (AudioFormat.Encoding.ALAW.equals(streamEncoding)) ||
(AudioFormat.Encoding.ULAW.equals(streamEncoding)) ) {
--- 167,177 ----
*** 233,243 ****
(int)stream.getFrameLength() );
return fileFormat;
}
-
private int writeAiffFile(InputStream in, AiffFileFormat aiffFileFormat, OutputStream out) throws IOException {
int bytesRead = 0;
int bytesWritten = 0;
InputStream fileStream = getFileStream(aiffFileFormat, in);
--- 224,233 ----
*** 273,301 ****
AudioFormat format = aiffFileFormat.getFormat();
AudioFormat streamFormat = null;
AudioFormat.Encoding encoding = null;
//$$fb a little bit nicer handling of constants
-
- //int headerSize = 54;
int headerSize = aiffFileFormat.getHeaderSize();
-
//int fverChunkSize = 0;
int fverChunkSize = aiffFileFormat.getFverChunkSize();
- //int commChunkSize = 26;
int commChunkSize = aiffFileFormat.getCommChunkSize();
int aiffLength = -1;
int ssndChunkSize = -1;
- //int ssndOffset = headerSize - 16;
int ssndOffset = aiffFileFormat.getSsndChunkOffset();
short channels = (short) format.getChannels();
short sampleSize = (short) format.getSampleSizeInBits();
! int ssndBlockSize = (channels * sampleSize);
int numFrames = aiffFileFormat.getFrameLength();
long dataSize = -1;
if( numFrames != AudioSystem.NOT_SPECIFIED) {
! dataSize = (long) numFrames * ssndBlockSize / 8;
ssndChunkSize = (int)dataSize + 16;
aiffLength = (int)dataSize+headerSize;
}
float sampleFramesPerSecond = format.getSampleRate();
int compCode = AiffFileFormat.AIFC_PCM;
--- 263,286 ----
AudioFormat format = aiffFileFormat.getFormat();
AudioFormat streamFormat = null;
AudioFormat.Encoding encoding = null;
//$$fb a little bit nicer handling of constants
int headerSize = aiffFileFormat.getHeaderSize();
//int fverChunkSize = 0;
int fverChunkSize = aiffFileFormat.getFverChunkSize();
int commChunkSize = aiffFileFormat.getCommChunkSize();
int aiffLength = -1;
int ssndChunkSize = -1;
int ssndOffset = aiffFileFormat.getSsndChunkOffset();
short channels = (short) format.getChannels();
short sampleSize = (short) format.getSampleSizeInBits();
! int ssndBlockSize = channels * ((sampleSize + 7) / 8);
int numFrames = aiffFileFormat.getFrameLength();
long dataSize = -1;
if( numFrames != AudioSystem.NOT_SPECIFIED) {
! dataSize = (long) numFrames * ssndBlockSize;
ssndChunkSize = (int)dataSize + 16;
aiffLength = (int)dataSize+headerSize;
}
float sampleFramesPerSecond = format.getSampleRate();
int compCode = AiffFileFormat.AIFC_PCM;
*** 401,413 ****
return aiffStream;
}
-
-
-
// HELPER METHODS
private static final int DOUBLE_MANTISSA_LENGTH = 52;
private static final int DOUBLE_EXPONENT_LENGTH = 11;
private static final long DOUBLE_SIGN_MASK = 0x8000000000000000L;
--- 386,395 ----
*** 450,457 ****
long extendedBits63To0 = EXTENDED_INTEGER_MASK | extendedMantissa;
dos.writeShort(extendedBits79To64);
dos.writeLong(extendedBits63To0);
}
-
-
}
--- 432,437 ----
< prev index next >