diff options
author | Sven Gothel <[email protected]> | 2014-07-03 16:27:25 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-03 16:27:25 +0200 |
commit | 0430708fbcbdc5572affb45318eb782adffd13f1 (patch) | |
tree | 61ac401ea90e07ae0a7ac639da1e6a240f1b87cd /src/java/com/jogamp/openal/util | |
parent | 21cd5206625aaa8914e53bdfaab8e7ae4e497a08 (diff) |
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Add final modifier to private fields
- Add final modifier to method parameters
- Add final modifier to local variables
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
- Remove trailing white spaces on all lines
Diffstat (limited to 'src/java/com/jogamp/openal/util')
-rw-r--r-- | src/java/com/jogamp/openal/util/ALHelpers.java | 52 | ||||
-rw-r--r-- | src/java/com/jogamp/openal/util/ALut.java | 51 | ||||
-rw-r--r-- | src/java/com/jogamp/openal/util/WAVData.java | 16 | ||||
-rw-r--r-- | src/java/com/jogamp/openal/util/WAVLoader.java | 12 |
4 files changed, 66 insertions, 65 deletions
diff --git a/src/java/com/jogamp/openal/util/ALHelpers.java b/src/java/com/jogamp/openal/util/ALHelpers.java index 54a5505..7c2b0d4 100644 --- a/src/java/com/jogamp/openal/util/ALHelpers.java +++ b/src/java/com/jogamp/openal/util/ALHelpers.java @@ -48,18 +48,18 @@ public class ALHelpers { * AL sample type. If <code>hasSOFTBufferSamples</code> is true, * it will be called to find the closest-matching format from * <code>AL_SOFT_buffer_samples</code>. - * <p> + * <p> * Returns {@link ALConstants#AL_NONE} if no supported format can be found. - * </p> - * + * </p> + * * @param alChannelLayout AL channel layout, see {@link #getDefaultALChannelLayout(int)} * @param alSampleType AL sample type, see {@link #getALSampleType(int, boolean, boolean)}. - * @param hasSOFTBufferSamples true if having extension <code>AL_SOFT_buffer_samples</code>, otherwise false + * @param hasSOFTBufferSamples true if having extension <code>AL_SOFT_buffer_samples</code>, otherwise false * @param al AL instance * @param alExt ALExt instance * @return AL buffer format */ - public static final int getALFormat(final int alChannelLayout, final int alSampleType, + public static final int getALFormat(final int alChannelLayout, final int alSampleType, final boolean hasSOFTBufferSamples, final AL al, final ALExt alExt) { int format = AL_NONE; @@ -226,7 +226,7 @@ public class ALHelpers { * @param fixedP true for fixed point value, false for floating point value with a sampleSize of 32 (float) or 64 (double) */ public static final int getDefaultALChannelLayout(final int channelCount) { - switch(channelCount) { + switch(channelCount) { case 1: return AL_MONO_SOFT; case 2: return AL_STEREO_SOFT; // case 2: return AL_REAR_SOFT; @@ -237,12 +237,12 @@ public class ALHelpers { } return AL_NONE; } - + /** * Returns the readable name of the given AL channel layout */ public static final String alChannelLayoutName(final int alChannelLayout) { - switch(alChannelLayout) { + switch(alChannelLayout) { case AL_MONO_SOFT: return "Mono"; case AL_STEREO_SOFT: return "Stereo"; case AL_REAR_SOFT: return "Rear"; @@ -260,7 +260,7 @@ public class ALHelpers { * @param signed true if signed number, false for unsigned * @param fixedP true for fixed point value, false for floating point value with a sampleSize of 32 (float) or 64 (double) */ - public static final int getALSampleType(final int sampleSize, boolean signed, boolean fixedP) { + public static final int getALSampleType(final int sampleSize, final boolean signed, final boolean fixedP) { if( fixedP ) { if( signed ) { switch( sampleSize ) { @@ -281,11 +281,11 @@ public class ALHelpers { case 32: return AL_FLOAT_SOFT; case 64: return AL_DOUBLE_SOFT; } - } + } } return AL_NONE; } - + /** * Returns the readable name of the given AL sample type */ @@ -304,22 +304,22 @@ public class ALHelpers { } /** - * Returns the byte size of the given AL sample type + * Returns the byte size of the given AL sample type * @throws IllegalArgumentException for unknown <code>alChannelLayout</code> or <code>alSampleType</code> values. */ public static final int sizeOfALSampleType(final int alSampleType) throws IllegalArgumentException { switch(alSampleType) { - case AL_BYTE_SOFT: - case AL_UNSIGNED_BYTE_SOFT: + case AL_BYTE_SOFT: + case AL_UNSIGNED_BYTE_SOFT: return 1; - case AL_SHORT_SOFT: - case AL_UNSIGNED_SHORT_SOFT: + case AL_SHORT_SOFT: + case AL_UNSIGNED_SHORT_SOFT: return 2; - case AL_INT_SOFT: + case AL_INT_SOFT: case AL_UNSIGNED_INT_SOFT: - case AL_FLOAT_SOFT: + case AL_FLOAT_SOFT: return 4; - case AL_DOUBLE_SOFT: + case AL_DOUBLE_SOFT: return 8; default: throw new IllegalArgumentException("Unknown al-type 0x"+Integer.toHexString(alSampleType)); @@ -349,19 +349,19 @@ public class ALHelpers { switch(alSampleType) { case AL_BYTE_SOFT: - case AL_UNSIGNED_BYTE_SOFT: + case AL_UNSIGNED_BYTE_SOFT: break; case AL_SHORT_SOFT: - case AL_UNSIGNED_SHORT_SOFT: - sampleCount *= 2; + case AL_UNSIGNED_SHORT_SOFT: + sampleCount *= 2; break; case AL_INT_SOFT: case AL_UNSIGNED_INT_SOFT: - case AL_FLOAT_SOFT: - sampleCount *= 4; + case AL_FLOAT_SOFT: + sampleCount *= 4; break; - case AL_DOUBLE_SOFT: - sampleCount *= 8; + case AL_DOUBLE_SOFT: + sampleCount *= 8; break; default: throw new IllegalArgumentException("Unknown al-type 0x"+Integer.toHexString(alSampleType)); diff --git a/src/java/com/jogamp/openal/util/ALut.java b/src/java/com/jogamp/openal/util/ALut.java index c6439d7..311b08b 100644 --- a/src/java/com/jogamp/openal/util/ALut.java +++ b/src/java/com/jogamp/openal/util/ALut.java @@ -4,17 +4,17 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * -* -Redistribution of source code must retain the above copyright notice, +* -Redistribution of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * -* -Redistribution in binary form must reproduce the above copyright notice, +* -Redistribution in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * -* Neither the name of Sun Microsystems, Inc. or the names of contributors may -* be used to endorse or promote products derived from this software without +* Neither the name of Sun Microsystems, Inc. or the names of contributors may +* be used to endorse or promote products derived from this software without * specific prior written permission. -* +* * This software is provided "AS IS," without a warranty of any kind. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR @@ -37,6 +37,7 @@ package com.jogamp.openal.util; import java.io.*; import java.nio.ByteBuffer; + import com.jogamp.openal.*; /** @@ -62,12 +63,12 @@ public final class ALut { if (alc == null) { alc = ALFactory.getALC(); } - String deviceName = null; - ALCdevice d = alc.alcOpenDevice(deviceName); + final String deviceName = null; + final ALCdevice d = alc.alcOpenDevice(deviceName); if (d == null) { throw new ALException("Error opening default OpenAL device"); } - ALCcontext c = alc.alcCreateContext(d, null); + final ALCcontext c = alc.alcCreateContext(d, null); if (c == null) { alc.alcCloseDevice(d); throw new ALException("Error creating OpenAL context"); @@ -102,41 +103,41 @@ public final class ALut { initializingThread = null; } - public static void alutLoadWAVFile(String fileName, - int[] format, - ByteBuffer[] data, - int[] size, - int[] freq, - int[] loop) throws ALException { + public static void alutLoadWAVFile(final String fileName, + final int[] format, + final ByteBuffer[] data, + final int[] size, + final int[] freq, + final int[] loop) throws ALException { try { - WAVData wd = WAVLoader.loadFromFile(fileName); + final WAVData wd = WAVLoader.loadFromFile(fileName); format[0] = wd.format; data[0] = wd.data; size[0] = wd.size; freq[0] = wd.freq; - loop[0] = wd.loop ? AL.AL_TRUE : AL.AL_FALSE; - } catch (Exception e) { + loop[0] = wd.loop ? ALConstants.AL_TRUE : ALConstants.AL_FALSE; + } catch (final Exception e) { throw new ALException(e); } } public static void alutLoadWAVFile(InputStream stream, - int[] format, - ByteBuffer[] data, - int[] size, - int[] freq, - int[] loop) throws ALException { + final int[] format, + final ByteBuffer[] data, + final int[] size, + final int[] freq, + final int[] loop) throws ALException { try { if (!(stream instanceof BufferedInputStream)) { stream = new BufferedInputStream(stream); } - WAVData wd = WAVLoader.loadFromStream(stream); + final WAVData wd = WAVLoader.loadFromStream(stream); format[0] = wd.format; data[0] = wd.data; size[0] = wd.size; freq[0] = wd.freq; - loop[0] = wd.loop ? AL.AL_TRUE : AL.AL_FALSE; - } catch (Exception e) { + loop[0] = wd.loop ? ALConstants.AL_TRUE : ALConstants.AL_FALSE; + } catch (final Exception e) { throw new ALException(e); } } diff --git a/src/java/com/jogamp/openal/util/WAVData.java b/src/java/com/jogamp/openal/util/WAVData.java index 9fab8ba..94dd002 100644 --- a/src/java/com/jogamp/openal/util/WAVData.java +++ b/src/java/com/jogamp/openal/util/WAVData.java @@ -74,7 +74,7 @@ public final class WAVData { /** flag indicating whether or not the sound in the data should loop */ public final boolean loop; - public WAVData(ByteBuffer data, int format, int size, int freq, boolean loop) { + public WAVData(final ByteBuffer data, final int format, final int size, final int freq, final boolean loop) { this.data = data; this.format = format; this.size = size; @@ -98,7 +98,7 @@ public final class WAVData { * @throws IOException If the file can no be found or some other IO error * occurs */ - public static WAVData loadFromStream(InputStream aIn, int initialCapacity, int numChannels, int bits, int sampleRate, ByteOrder byteOrder, boolean loop) + public static WAVData loadFromStream(InputStream aIn, final int initialCapacity, final int numChannels, final int bits, final int sampleRate, final ByteOrder byteOrder, final boolean loop) throws IOException { if( !(aIn instanceof BufferedInputStream) ) { aIn = new BufferedInputStream(aIn); @@ -115,21 +115,21 @@ public final class WAVData { } else if ((bits == 16) && (numChannels == 2)) { format = ALConstants.AL_FORMAT_STEREO16; } - ByteBuffer buffer = IOUtil.copyStream2ByteBuffer(aIn, initialCapacity); - int size = buffer.limit(); + final ByteBuffer buffer = IOUtil.copyStream2ByteBuffer(aIn, initialCapacity); + final int size = buffer.limit(); // Must byte swap in case endianess mismatch if ( bits == 16 && ByteOrder.nativeOrder() != byteOrder ) { - int len = buffer.remaining(); + final int len = buffer.remaining(); for (int i = 0; i < len; i += 2) { - byte a = buffer.get(i); - byte b = buffer.get(i+1); + final byte a = buffer.get(i); + final byte b = buffer.get(i+1); buffer.put(i, b); buffer.put(i+1, a); } } - WAVData result = new WAVData(buffer, format, size, sampleRate, loop); + final WAVData result = new WAVData(buffer, format, size, sampleRate, loop); aIn.close(); return result; diff --git a/src/java/com/jogamp/openal/util/WAVLoader.java b/src/java/com/jogamp/openal/util/WAVLoader.java index 5547ed2..bb3507e 100644 --- a/src/java/com/jogamp/openal/util/WAVLoader.java +++ b/src/java/com/jogamp/openal/util/WAVLoader.java @@ -61,9 +61,9 @@ public class WAVLoader { * @throws IOException If the file can no be found or some other IO error * occurs */ - public static WAVData loadFromFile(String filename) throws ALException, IOException { - File soundFile = new File(filename); - InputStream is = new FileInputStream(soundFile); + public static WAVData loadFromFile(final String filename) throws ALException, IOException { + final File soundFile = new File(filename); + final InputStream is = new FileInputStream(soundFile); return loadFromStreamImpl(is); } @@ -78,7 +78,7 @@ public class WAVLoader { * @throws IOException If the file can no be found or some other IO error * occurs */ - public static WAVData loadFromStream(InputStream stream) throws ALException, IOException { + public static WAVData loadFromStream(final InputStream stream) throws ALException, IOException { return loadFromStreamImpl(stream); } @@ -89,7 +89,7 @@ public class WAVLoader { private static final int FMT = 0x666D7420; private static final int DATA = 0x64617461; - private static WAVData loadFromStreamImpl(InputStream aIn) throws ALException, IOException { + private static WAVData loadFromStreamImpl(final InputStream aIn) throws ALException, IOException { /** * references: * http://www.sonicspot.com/guide/wavefiles.html @@ -125,7 +125,7 @@ public class WAVLoader { long chunkLength = 0; while (!foundData) { - int chunkId = (int)bs.readUInt32(true /* msbFirst */, true /* bigEndian */); + final int chunkId = (int)bs.readUInt32(true /* msbFirst */, true /* bigEndian */); chunkLength = bs.readUInt32(true /* msbFirst */, bigEndian); switch (chunkId) { case FMT: |