-
-
Notifications
You must be signed in to change notification settings - Fork 35
Description
What is the purpose of Status.OPENING? It seems to be written to status, but never read.
java-stream-player/src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java
Lines 333 to 335 in 7caf2f3
// Notify Status | |
status = Status.OPENING; | |
generateEvent(Status.OPENING, getEncodedStreamPosition(), source); |
There seem to be three values in Status that are never used; neither for write nor for read: INIT, BUFFERING and GAIN. I think they can be removed.
In the play() method, the status is tested. It returns silently if status != Status.OPENED. Is that a desirable feature?
java-stream-player/src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java
Lines 554 to 572 in 7caf2f3
/** | |
* Starts the play back. | |
* | |
* @throws StreamPlayerException the stream player exception | |
*/ | |
@Override | |
public void play() throws StreamPlayerException { | |
if (status == Status.STOPPED) | |
initAudioInputStream(); | |
if (status != Status.OPENED) | |
return; | |
// Shutdown previous Thread Running | |
awaitTermination(); | |
// Open SourceDataLine. | |
try { | |
initLine(); | |
} catch (final LineUnavailableException ex) { |
That is why
Lines 49 to 54 in 7caf2f3
@Test | |
@DisplayName("When play() is called without first calling open(), an exception is thrown") | |
void playingUnopenedSourceThrowsException() { | |
assertThrows(Exception.class, () -> player.play()); | |
} |
fails. What is the best alternative: Changing the behaviour to make the test pass, or remove the test?
OK, there is a third alternative: to change the behaviour such that the error situation is indicated by some other means, and change the test correspondingly.