Changed some gst threading behaviour to prevent unescaped thread interruptions.
This commit is contained in:
parent
337ed9c076
commit
53e4f47029
@ -22,7 +22,7 @@ public class GStreamerPlayer implements IPlayer{
|
|||||||
|
|
||||||
private final PlayBin2 playBin;
|
private final PlayBin2 playBin;
|
||||||
|
|
||||||
private InternalThread internalThread;
|
private final InternalThread internalThread = new InternalThread();
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
private Song currentSong;
|
private Song currentSong;
|
||||||
private final PlayerCallbackInterface callbackInterface;
|
private final PlayerCallbackInterface callbackInterface;
|
||||||
@ -62,9 +62,9 @@ public class GStreamerPlayer implements IPlayer{
|
|||||||
playSong(currentSong);
|
playSong(currentSong);
|
||||||
else
|
else
|
||||||
playSong(playlist.getNext(currentSong));
|
playSong(playlist.getNext(currentSong));
|
||||||
} catch (InterruptedException | StartPlayingException e) {
|
} catch (StartPlayingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
} catch (InterruptedException ignored){}
|
||||||
});
|
});
|
||||||
callbackThing.start();
|
callbackThing.start();
|
||||||
});
|
});
|
||||||
@ -108,8 +108,10 @@ public class GStreamerPlayer implements IPlayer{
|
|||||||
* @throws StartPlayingException
|
* @throws StartPlayingException
|
||||||
*/
|
*/
|
||||||
private void playSong(Song inputSong) throws StartPlayingException {
|
private void playSong(Song inputSong) throws StartPlayingException {
|
||||||
if (playBin.getState() == State.PLAYING)
|
if (playBin.getState() == State.PLAYING) {
|
||||||
|
internalThread.stop();
|
||||||
stop();
|
stop();
|
||||||
|
}
|
||||||
if(playBin.getState() == State.PAUSED && inputSong == currentSong) {
|
if(playBin.getState() == State.PAUSED && inputSong == currentSong) {
|
||||||
resume();
|
resume();
|
||||||
return;
|
return;
|
||||||
@ -125,11 +127,10 @@ public class GStreamerPlayer implements IPlayer{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
playBin.setURI(songFile.toURI());
|
playBin.setURI(songFile.toURI());
|
||||||
internalThread = new InternalThread();
|
|
||||||
thread = new Thread(internalThread, "GSTThread");
|
|
||||||
setVolume(currentVolume);
|
setVolume(currentVolume);
|
||||||
playBin.play();
|
playBin.play();
|
||||||
if(playBin.getState() == State.PLAYING) {
|
if(playBin.getState() == State.PLAYING) {
|
||||||
|
thread = new Thread(internalThread, "GSTThread");
|
||||||
thread.start();
|
thread.start();
|
||||||
while (true) {
|
while (true) {
|
||||||
if (playBin.queryDuration().getSeconds() > 0 || playBin.queryDuration().getNanoSeconds() > 0) break;
|
if (playBin.queryDuration().getSeconds() > 0 || playBin.queryDuration().getNanoSeconds() > 0) break;
|
||||||
|
Loading…
Reference in New Issue
Block a user