Skip to content

Commit 4991e4a

Browse files
authored
Merge pull request #26 from HelgeStenstrom/codeInspectionAgain
Simplifications based on IntelliJ: Analyzer --> Inspect code
2 parents 90e8688 + d57d413 commit 4991e4a

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

src/main/java/com/goxr3plus/streamplayer/enums/AudioType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ public enum AudioType {
2222
/**
2323
* Audio is UNKOWN
2424
*/
25-
UNKNOWN;
25+
UNKNOWN
2626
}

src/main/java/com/goxr3plus/streamplayer/enums/Status.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ public enum Status {
7676
PAN,
7777

7878
/** player gain has changed. */
79-
GAIN;
79+
GAIN
8080

8181
}

src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java

+15-16
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ private void initAudioInputStream() throws StreamPlayerException {
326326
status = Status.OPENED;
327327
generateEvent(Status.OPENED, getEncodedStreamPosition(), null);
328328

329-
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException ¢) {
330-
logger.log(Level.INFO, ¢.getMessage(), ¢);
331-
throw new StreamPlayerException(¢);
329+
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {
330+
logger.log(Level.INFO, e.getMessage(), e);
331+
throw new StreamPlayerException(e);
332332
}
333333

334334
logger.info("Exited initAudioInputStream\n");
@@ -349,7 +349,7 @@ private void determineProperties() {
349349
audioProperties = new HashMap<>();
350350
else {
351351
// Tritonus SPI compliant audio file format.
352-
audioProperties = ((TAudioFileFormat) audioFileFormat).properties();
352+
audioProperties = audioFileFormat.properties();
353353

354354
// Clone the Map because it is not mutable.
355355
audioProperties = deepCopy(audioProperties);
@@ -378,7 +378,7 @@ private void determineProperties() {
378378
audioProperties.put("audio.channels", audioFormat.getChannels());
379379
// Tritonus SPI compliant audio format.
380380
if (audioFormat instanceof TAudioFormat)
381-
audioProperties.putAll(((TAudioFormat) audioFormat).properties());
381+
audioProperties.putAll(audioFormat.properties());
382382

383383
// Add SourceDataLine
384384
audioProperties.put("basicplayer.sourcedataline", sourceDataLine);
@@ -457,7 +457,7 @@ private void createLine() throws LineUnavailableException, StreamPlayerException
457457
// Calculate the Sample Size in bits
458458
int nSampleSizeInBits = sourceFormat.getSampleSizeInBits();
459459
if (sourceFormat.getEncoding() == AudioFormat.Encoding.ULAW || sourceFormat.getEncoding() == AudioFormat.Encoding.ALAW
460-
|| nSampleSizeInBits <= 0 || nSampleSizeInBits != 8)
460+
|| nSampleSizeInBits != 8)
461461
nSampleSizeInBits = 16;
462462

463463
final AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
@@ -1068,11 +1068,11 @@ private Mixer getMixer(final String name) {
10681068
final Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
10691069

10701070
if (name != null && mixerInfos != null)
1071-
for (int i = 0; i < mixerInfos.length; i++)
1072-
if (mixerInfos[i].getName().equals(name)) {
1073-
mixer = AudioSystem.getMixer(mixerInfos[i]);
1074-
break;
1075-
}
1071+
for (Mixer.Info mixerInfo : mixerInfos)
1072+
if (mixerInfo.getName().equals(name)) {
1073+
mixer = AudioSystem.getMixer(mixerInfo);
1074+
break;
1075+
}
10761076
return mixer;
10771077
}
10781078

@@ -1183,9 +1183,9 @@ public int getPositionByte() {
11831183
final int positionByte = AudioSystem.NOT_SPECIFIED;
11841184
if (audioProperties != null) {
11851185
if (audioProperties.containsKey("mp3.position.byte"))
1186-
return ((Integer) audioProperties.get("mp3.position.byte")).intValue();
1186+
return (Integer) audioProperties.get("mp3.position.byte");
11871187
if (audioProperties.containsKey("ogg.position.byte"))
1188-
return ((Integer) audioProperties.get("ogg.position.byte")).intValue();
1188+
return (Integer) audioProperties.get("ogg.position.byte");
11891189
}
11901190
return positionByte;
11911191
}
@@ -1256,7 +1256,7 @@ public void setPan(final double fPan) {
12561256
*/
12571257
public void setGain(final double fGain) {
12581258
if (isPlaying() || isPaused() && hasControl(FloatControl.Type.MASTER_GAIN, gainControl))
1259-
gainControl.setValue((float) (20 * Math.log10(fGain != 0.0 ? fGain : 0.0000)));
1259+
gainControl.setValue((float) (20 * Math.log10(fGain)));
12601260
}
12611261

12621262
/**
@@ -1298,8 +1298,7 @@ public void setEqualizer(final float[] array, final int stop) {
12981298
return;
12991299
// Map<?, ?> map = ((PropertiesContainer) audioInputStream).properties()
13001300
final float[] equalizer = (float[]) ((PropertiesContainer) audioInputStream).properties().get("mp3.equalizer");
1301-
for (int i = 0; i < stop; i++)
1302-
equalizer[i] = array[i];
1301+
if (stop >= 0) System.arraycopy(array, 0, equalizer, 0, stop);
13031302

13041303
}
13051304

0 commit comments

Comments
 (0)