If i start playing a song on librespot-android, and then go to my spotify app to change the source of the song, librespot-android crashes :
2022-01-06 23:23:07.091 20210-20258/xyz.gianlu.librespot.android E/AndroidRuntime: FATAL EXCEPTION: player-audio-sink
Process: xyz.gianlu.librespot.android, PID: 20210
java.lang.IllegalStateException: Unable to retrieve AudioTrack pointer for stop()
at android.media.AudioTrack.native_stop(Native Method)
at android.media.AudioTrack.stop(AudioTrack.java:2881)
at xyz.gianlu.librespot.android.sink.AndroidSinkOutput.stop(AndroidSinkOutput.java:99)
at xyz.gianlu.librespot.player.mixing.AudioSink.run(AudioSink.java:160)
at java.lang.Thread.run(Thread.java:920)
If i start playing a song on librespot-android, and then go to my spotify app to change the source of the song, librespot-android crashes :
This is caused by the line :
if (track != null) track.stop();
(AndroidSinkOutput.java:99)I tried to fix the issue, and i have a bizarre behavior ; this code :
does not crash the player. Maybe i was lucky, or maybe getPlayState() actualizes something inside the AudioTrack ?
Anyway, the state here prints '1' in this case, i.e.
AudioTrack.PLAYSTATE_STOPPED
; so a correct fix should be :I'm not sure if it is the "good way" though...