Skip to content

Question about Status enum and play() #71

Description

@HelgeStenstrom

What is the purpose of Status.OPENING? It seems to be written to status, but never read.

// 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?

/**
* 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

@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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions