Skip to content

Commit 38189c8

Browse files
Simplifications based on IntelliJ: Analyzer --> Inspect code
These simplifcations seem totally safe. I think they are the same as previously submitted.
1 parent aea1720 commit 38189c8

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ private void initAudioInputStream() throws StreamPlayerException {
305305
status = Status.OPENED;
306306
generateEvent(Status.OPENED, getEncodedStreamPosition(), null);
307307

308-
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException ¢) {
309-
logger.log(Level.INFO, ¢.getMessage(), ¢);
310-
throw new StreamPlayerException(¢);
308+
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {
309+
logger.log(Level.INFO, e.getMessage(), e);
310+
throw new StreamPlayerException(e);
311311
}
312312

313313
logger.info("Exited initAudioInputStream\n");
@@ -328,7 +328,7 @@ private void determineProperties() {
328328
audioProperties = new HashMap<>();
329329
else {
330330
// Tritonus SPI compliant audio file format.
331-
audioProperties = ((TAudioFileFormat) audioFileFormat).properties();
331+
audioProperties = audioFileFormat.properties();
332332

333333
// Clone the Map because it is not mutable.
334334
audioProperties = deepCopy(audioProperties);
@@ -357,7 +357,7 @@ private void determineProperties() {
357357
audioProperties.put("audio.channels", audioFormat.getChannels());
358358
// Tritonus SPI compliant audio format.
359359
if (audioFormat instanceof TAudioFormat)
360-
audioProperties.putAll(((TAudioFormat) audioFormat).properties());
360+
audioProperties.putAll(audioFormat.properties());
361361

362362
// Add SourceDataLine
363363
audioProperties.put("basicplayer.sourcedataline", sourceDataLine);
@@ -436,7 +436,7 @@ private void createLine() throws LineUnavailableException, StreamPlayerException
436436
// Calculate the Sample Size in bits
437437
int nSampleSizeInBits = sourceFormat.getSampleSizeInBits();
438438
if (sourceFormat.getEncoding() == AudioFormat.Encoding.ULAW || sourceFormat.getEncoding() == AudioFormat.Encoding.ALAW
439-
|| nSampleSizeInBits <= 0 || nSampleSizeInBits != 8)
439+
|| nSampleSizeInBits != 8)
440440
nSampleSizeInBits = 16;
441441

442442
final AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
@@ -1047,11 +1047,11 @@ private Mixer getMixer(final String name) {
10471047
final Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();
10481048

10491049
if (name != null && mixerInfos != null)
1050-
for (int i = 0; i < mixerInfos.length; i++)
1051-
if (mixerInfos[i].getName().equals(name)) {
1052-
mixer = AudioSystem.getMixer(mixerInfos[i]);
1053-
break;
1054-
}
1050+
for (Mixer.Info mixerInfo : mixerInfos)
1051+
if (mixerInfo.getName().equals(name)) {
1052+
mixer = AudioSystem.getMixer(mixerInfo);
1053+
break;
1054+
}
10551055
return mixer;
10561056
}
10571057

@@ -1162,9 +1162,9 @@ public int getPositionByte() {
11621162
final int positionByte = AudioSystem.NOT_SPECIFIED;
11631163
if (audioProperties != null) {
11641164
if (audioProperties.containsKey("mp3.position.byte"))
1165-
return ((Integer) audioProperties.get("mp3.position.byte")).intValue();
1165+
return (Integer) audioProperties.get("mp3.position.byte");
11661166
if (audioProperties.containsKey("ogg.position.byte"))
1167-
return ((Integer) audioProperties.get("ogg.position.byte")).intValue();
1167+
return (Integer) audioProperties.get("ogg.position.byte");
11681168
}
11691169
return positionByte;
11701170
}
@@ -1235,7 +1235,7 @@ public void setPan(final double fPan) {
12351235
*/
12361236
public void setGain(final double fGain) {
12371237
if (isPlaying() || isPaused() && hasControl(FloatControl.Type.MASTER_GAIN, gainControl))
1238-
gainControl.setValue((float) (20 * Math.log10(fGain != 0.0 ? fGain : 0.0000)));
1238+
gainControl.setValue((float) (20 * Math.log10(fGain)));
12391239
}
12401240

12411241
/**
@@ -1277,8 +1277,7 @@ public void setEqualizer(final float[] array, final int stop) {
12771277
return;
12781278
// Map<?, ?> map = ((PropertiesContainer) audioInputStream).properties()
12791279
final float[] equalizer = (float[]) ((PropertiesContainer) audioInputStream).properties().get("mp3.equalizer");
1280-
for (int i = 0; i < stop; i++)
1281-
equalizer[i] = array[i];
1280+
if (stop >= 0) System.arraycopy(array, 0, equalizer, 0, stop);
12821281

12831282
}
12841283

0 commit comments

Comments
 (0)