kaytat / SimpleProtocolPlayer

Audio player for uncompressed PCM data
Apache License 2.0
108 stars 22 forks source link

No socket.close() when exiting normally #30

Open AgentConDier opened 2 years ago

AgentConDier commented 2 years ago

Thanks for this very useful app, I've found it really convenient when messing around with live audio streams in Termux!

The TCP connection isn't closed properly after pressing the Stop button, it stays alive until the app is explicitly stopped from the recent apps screen. This usually isn't noticeable when streaming from PulseAudio, since that allows multiple connections, but in the windows server it could prevent reconnecting after stopping the stream.

How to reproduce:

  1. Open pavucontrol -t 2 (the Recording tab)
  2. Open the app and connect to the stream
  3. Press stop and play repeatedly
  4. Multiple Simple client entries appear
  5. Force-close the app. This should disconnect all of them

Device info: Huawei Mate 20 Pro with Emui 12 (Android 10) Simple Protocol Player 0.5.8.0

I'm pretty sure this is caused by the following line only being executed when an Exception is caught, but not when exiting normally by setting running to false. https://github.com/kaytat/SimpleProtocolPlayer/blob/8345ab801fc112fd8b246c55b8550a9bfabba69e/src/main/java/com/kaytat/simpleprotocolplayer/NetworkReadThread.java#L164