Try not to write to sink, if the streamer has been stopped

This commit is contained in:
0xboobface 2018-09-09 14:28:29 +02:00
parent 17901901f9
commit 455dea97d9
1 changed files with 7 additions and 5 deletions

View File

@ -65,6 +65,7 @@ public class Streamer {
} }
public void stop() { public void stop() {
streamingShouldStop = true;
try { try {
source.close(); source.close();
} catch (Exception e) { } catch (Exception e) {
@ -75,7 +76,6 @@ public class Streamer {
} catch (Exception e) { } catch (Exception e) {
log.error("Couldn't close sink", e); log.error("Couldn't close sink", e);
} }
streamingShouldStop = true;
buffer.clear(); buffer.clear();
bufferingThread.interrupt(); bufferingThread.interrupt();
streamingThread.interrupt(); streamingThread.interrupt();
@ -232,11 +232,13 @@ public class Streamer {
// Stream packet // Stream packet
// System.out.println("Streaming packet #" + packetCount + ", PID=" + mtsPacket.getPid() + ", pcrCount=" + pcrCount + ", continuityCounter=" + mtsPacket.getContinuityCounter()); // System.out.println("Streaming packet #" + packetCount + ", PID=" + mtsPacket.getPid() + ", pcrCount=" + pcrCount + ", continuityCounter=" + mtsPacket.getContinuityCounter());
if(!streamingShouldStop) {
try { try {
sink.send(packet); sink.send(packet);
} catch (Exception e) { } catch (Exception e) {
log.error("Error sending packet to sink", e); log.error("Error sending packet to sink", e);
} }
}
packetCount++; packetCount++;
} }