< prev index next >

src/java.desktop/share/classes/com/sun/media/sound/AlawCodec.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 28,56 **** import java.io.IOException; import java.util.Objects; import java.util.Vector; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; /** * A-law encodes linear data, and decodes a-law data to linear data. * * @author Kara Kytle */ ! public final class AlawCodec extends SunCodec { /* Tables used for A-law decoding */ private static final byte[] ALAW_TABH = new byte[256]; private static final byte[] ALAW_TABL = new byte[256]; ! private static final AudioFormat.Encoding[] alawEncodings = { AudioFormat.Encoding.ALAW, AudioFormat.Encoding.PCM_SIGNED }; ! ! private static final short seg_end [] = {0xFF, 0x1FF, 0x3FF, ! 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF}; /** * Initializes the decode tables. */ static { --- 28,57 ---- import java.io.IOException; import java.util.Objects; import java.util.Vector; import javax.sound.sampled.AudioFormat; + import javax.sound.sampled.AudioFormat.Encoding; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; + import javax.sound.sampled.spi.FormatConversionProvider; /** * A-law encodes linear data, and decodes a-law data to linear data. * * @author Kara Kytle */ ! public final class AlawCodec extends FormatConversionProvider { /* Tables used for A-law decoding */ private static final byte[] ALAW_TABH = new byte[256]; private static final byte[] ALAW_TABL = new byte[256]; ! private static final short seg_end[] = { ! 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF ! }; /** * Initializes the decode tables. */ static {
*** 71,87 **** ALAW_TABL[i] = (byte)value; ALAW_TABH[i] = (byte)(value>>8); } } ! /** ! * Constructs a new ALAW codec object. ! */ ! public AlawCodec() { ! ! super(alawEncodings, alawEncodings); } @Override public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat){ --- 72,89 ---- ALAW_TABL[i] = (byte)value; ALAW_TABH[i] = (byte)(value>>8); } } + @Override + public AudioFormat.Encoding[] getSourceEncodings() { + return new Encoding[]{Encoding.ALAW, Encoding.PCM_SIGNED}; + } ! @Override ! public AudioFormat.Encoding[] getTargetEncodings() { ! return getSourceEncodings(); } @Override public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat){
< prev index next >