Skip to content

Commit

Permalink
Merge pull request #25 from goxr3plus/revert-24-simplificationsBasedO…
Browse files Browse the repository at this point in the history
…nCodeAnalysis

Revert "Simplifications based on IntelliJ: Analyze --> Inspect code"
  • Loading branch information
goxr3plus committed Sep 3, 2019
2 parents 6717a98 + b7d1194 commit aea1720
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public enum AudioType {
/**
* Audio is UNKOWN
*/
UNKNOWN
UNKNOWN;
}
2 changes: 1 addition & 1 deletion src/main/java/com/goxr3plus/streamplayer/enums/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ public enum Status {
PAN,

/** player gain has changed. */
GAIN
GAIN;

}
27 changes: 14 additions & 13 deletions src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ private void initAudioInputStream() throws StreamPlayerException {
status = Status.OPENED;
generateEvent(Status.OPENED, getEncodedStreamPosition(), null);

} catch (LineUnavailableException | UnsupportedAudioFileException | IOException e) {
logger.log(Level.INFO, e.getMessage(), e);
throw new StreamPlayerException(e);
} catch (LineUnavailableException | UnsupportedAudioFileException | IOException ¢) {
logger.log(Level.INFO, ¢.getMessage(), ¢);
throw new StreamPlayerException(¢);
}

logger.info("Exited initAudioInputStream\n");
Expand All @@ -328,7 +328,7 @@ private void determineProperties() {
audioProperties = new HashMap<>();
else {
// Tritonus SPI compliant audio file format.
audioProperties = audioFileFormat.properties();
audioProperties = ((TAudioFileFormat) audioFileFormat).properties();
// Clone the Map because it is not mutable.
audioProperties = deepCopy(audioProperties);
Expand Down Expand Up @@ -357,7 +357,7 @@ private void determineProperties() {
audioProperties.put("audio.channels", audioFormat.getChannels());
// Tritonus SPI compliant audio format.
if (audioFormat instanceof TAudioFormat)
audioProperties.putAll(audioFormat.properties());
audioProperties.putAll(((TAudioFormat) audioFormat).properties());
// Add SourceDataLine
audioProperties.put("basicplayer.sourcedataline", sourceDataLine);
Expand Down Expand Up @@ -436,7 +436,7 @@ private void createLine() throws LineUnavailableException, StreamPlayerException
// Calculate the Sample Size in bits
int nSampleSizeInBits = sourceFormat.getSampleSizeInBits();
if (sourceFormat.getEncoding() == AudioFormat.Encoding.ULAW || sourceFormat.getEncoding() == AudioFormat.Encoding.ALAW
|| nSampleSizeInBits != 8)
|| nSampleSizeInBits <= 0 || nSampleSizeInBits != 8)
nSampleSizeInBits = 16;

final AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
Expand Down Expand Up @@ -1047,9 +1047,9 @@ private Mixer getMixer(final String name) {
final Mixer.Info[] mixerInfos = AudioSystem.getMixerInfo();

if (name != null && mixerInfos != null)
for (Mixer.Info mixerInfo : mixerInfos)
if (mixerInfo.getName().equals(name)) {
mixer = AudioSystem.getMixer(mixerInfo);
for (int i = 0; i < mixerInfos.length; i++)
if (mixerInfos[i].getName().equals(name)) {
mixer = AudioSystem.getMixer(mixerInfos[i]);
break;
}
return mixer;
Expand Down Expand Up @@ -1162,9 +1162,9 @@ public int getPositionByte() {
final int positionByte = AudioSystem.NOT_SPECIFIED;
if (audioProperties != null) {
if (audioProperties.containsKey("mp3.position.byte"))
return (Integer) audioProperties.get("mp3.position.byte");
return ((Integer) audioProperties.get("mp3.position.byte")).intValue();
if (audioProperties.containsKey("ogg.position.byte"))
return (Integer) audioProperties.get("ogg.position.byte");
return ((Integer) audioProperties.get("ogg.position.byte")).intValue();
}
return positionByte;
}
Expand Down Expand Up @@ -1235,7 +1235,7 @@ public void setPan(final double fPan) {
*/
public void setGain(final double fGain) {
if (isPlaying() || isPaused() && hasControl(FloatControl.Type.MASTER_GAIN, gainControl))
gainControl.setValue((float) (20 * Math.log10(fGain)));
gainControl.setValue((float) (20 * Math.log10(fGain != 0.0 ? fGain : 0.0000)));
}

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

}

Expand Down

0 comments on commit aea1720

Please sign in to comment.