goxr3plus / java-stream-player

🌌Java Advanced Audio Controller Library (WAV, AU, AIFF, MP3, OGG VORBIS, FLAC, MONKEY's AUDIO and SPEEX audio formats )
GNU General Public License v3.0
145 stars 33 forks source link

private Future<Void> future; is never used #51

Open HelgeStenstrom opened 4 years ago

HelgeStenstrom commented 4 years ago

https://github.com/goxr3plus/java-stream-player/blob/d32a46a1f7d105a2c5350ae5bd04fdc1edd47baa/src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java#L121

This object is never written, but it's read at a few places. I think the intention might have been to assign it to the result of

https://github.com/goxr3plus/java-stream-player/blob/d32a46a1f7d105a2c5350ae5bd04fdc1edd47baa/src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java#L577

For usages of this future, see https://github.com/goxr3plus/java-stream-player/blob/d32a46a1f7d105a2c5350ae5bd04fdc1edd47baa/src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java#L638-L676

goxr3plus commented 4 years ago

Now i remember where i used this, i used to return i future from submit event and wait fot it to finish before the next event happens.

So if one Thread called stop and one other pause at the same time it is assured that firstly stop or pause will run and not together, to avoid deadlocks.

Now i remembered :)

HelgeStenstrom commented 4 years ago

But that is not the way it works now, since the future is not returned from submit. It's not even created, as far as I can see. It's null, and line 643 will never be executed.