Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about Status enum and play() #71

Open
HelgeStenstrom opened this issue Dec 28, 2021 · 0 comments
Open

Question about Status enum and play() #71

HelgeStenstrom opened this issue Dec 28, 2021 · 0 comments
Assignees
Labels

Comments

@HelgeStenstrom
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants