jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java
author darcy
Mon, 05 May 2014 23:19:00 -0700
changeset 24548 9c007a986347
parent 18215 b2afd66ce6db
permissions -rw-r--r--
8042256: Fix raw and unchecked lint warnings in com.sun.media.sound Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18215
b2afd66ce6db 8006328: Improve robustness of sound classes
serb
parents: 5506
diff changeset
     2
 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.media.sound;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.sound.sampled.AudioFileFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.sound.sampled.AudioFormat;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * AIFF file format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @author Jan Borgersen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
18215
b2afd66ce6db 8006328: Improve robustness of sound classes
serb
parents: 5506
diff changeset
    38
final class AiffFileFormat extends AudioFileFormat {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    static final int AIFF_MAGIC         = 1179603533;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    // for writing AIFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    static final int AIFC_MAGIC                 = 0x41494643;   // 'AIFC'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    static final int AIFF_MAGIC2                = 0x41494646;   // 'AIFF'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static final int FVER_MAGIC                 = 0x46564552;   // 'FVER'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    static final int FVER_TIMESTAMP             = 0xA2805140;   // timestamp of last AIFF-C update
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    static final int COMM_MAGIC                 = 0x434f4d4d;   // 'COMM'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    static final int SSND_MAGIC                 = 0x53534e44;   // 'SSND'
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    // compression codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    static final int AIFC_PCM                   = 0x4e4f4e45;   // 'NONE' PCM
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    static final int AIFC_ACE2                  = 0x41434532;   // 'ACE2' ACE 2:1 compression
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    static final int AIFC_ACE8                  = 0x41434538;   // 'ACE8' ACE 8:3 compression
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    static final int AIFC_MAC3                  = 0x4d414333;   // 'MAC3' MACE 3:1 compression
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    static final int AIFC_MAC6                  = 0x4d414336;   // 'MAC6' MACE 6:1 compression
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    static final int AIFC_ULAW                  = 0x756c6177;   // 'ulaw' ITU G.711 u-Law
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static final int AIFC_IMA4                  = 0x696d6134;   // 'ima4' IMA ADPCM
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    // $$fb static approach not good, but needed for estimation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    static final int AIFF_HEADERSIZE    = 54;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    //$$fb 2001-07-13: added management of header size in this class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /** header size in bytes */
18215
b2afd66ce6db 8006328: Improve robustness of sound classes
serb
parents: 5506
diff changeset
    65
    private final int headerSize=AIFF_HEADERSIZE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /** comm chunk size in bytes, inclusive magic and length field */
18215
b2afd66ce6db 8006328: Improve robustness of sound classes
serb
parents: 5506
diff changeset
    68
    private final int commChunkSize=26;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /** FVER chunk size in bytes, inclusive magic and length field */
18215
b2afd66ce6db 8006328: Improve robustness of sound classes
serb
parents: 5506
diff changeset
    71
    private final int fverChunkSize=0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    AiffFileFormat( AudioFileFormat aff ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    AiffFileFormat(Type type, int byteLength, AudioFormat format, int frameLength) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        super(type, byteLength, format, frameLength);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    int getHeaderSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        return headerSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    int getCommChunkSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return commChunkSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    int getFverChunkSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        return fverChunkSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    int getSsndChunkOffset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        return getHeaderSize()-16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
}