diff options
author | Sven Gothel <[email protected]> | 2014-07-03 16:21:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-03 16:21:36 +0200 |
commit | 556d92b63555a085b25e32b1cd55afce24edd07a (patch) | |
tree | 6be2b02c62a77d5aba81ffbe34c46960608be163 /src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java | |
parent | a90f4a51dffec3247278e3c683ed4462b1dd9ab5 (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/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java index 01346553c..18698f5ea 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/SoundBuffer.java @@ -35,16 +35,16 @@ package com.jogamp.audio.windows.waveout; import java.io.*; class SoundBuffer { - private byte[] data; - private boolean needsByteSwap; + private final byte[] data; + private final boolean needsByteSwap; private int numBytes; - private int bytesPerSample; + private final int bytesPerSample; private int numSamples; private boolean playing; private boolean empty; // Note: needsByteSwap argument makes assumptions about the format - SoundBuffer(int size, int bytesPerSample, boolean needsByteSwap) { + SoundBuffer(final int size, final int bytesPerSample, final boolean needsByteSwap) { this.bytesPerSample = bytesPerSample; this.needsByteSwap = needsByteSwap; data = new byte[size * bytesPerSample]; @@ -55,7 +55,7 @@ class SoundBuffer { return playing; } - void playing(boolean playing) { + void playing(final boolean playing) { this.playing = playing; } @@ -63,11 +63,11 @@ class SoundBuffer { return empty; } - void empty(boolean empty) { + void empty(final boolean empty) { this.empty = empty; } - void fill(InputStream input) throws IOException { + void fill(final InputStream input) throws IOException { synchronized(this) { if (playing) { throw new IllegalStateException("Can not fill a buffer that is playing"); @@ -75,7 +75,7 @@ class SoundBuffer { } empty(true); - int num = input.read(data); + final int num = input.read(data); if (num > 0) { numBytes = num; numSamples = numBytes / bytesPerSample; @@ -96,8 +96,8 @@ class SoundBuffer { // This is called by the mixer and must be extremely fast // FIXME: may want to reconsider use of floating point at this point // FIXME: assumes all sounds are of the same format to avoid normalization - float getSample(int sample) { - int startByte = sample * bytesPerSample; + float getSample(final int sample) { + final int startByte = sample * bytesPerSample; // FIXME: assumes no more than 4 bytes per sample int res = 0; if (needsByteSwap) { @@ -106,7 +106,7 @@ class SoundBuffer { res |= (data[i] & 0xff); } } else { - int endByte = startByte + bytesPerSample - 1; + final int endByte = startByte + bytesPerSample - 1; for (int i = startByte; i <= endByte; i++) { res <<= 8; res |= (data[i] & 0xff); @@ -119,6 +119,6 @@ class SoundBuffer { res = (byte) res; } - return (float) res; + return res; } } |