Fix OutOfMemoryErrors
1. Catch exceptions thrown by ContinuityFixer and skip to the next packet. 2. Restrict the queue size to 10 segments. Otherwise, if the download is faster than the stream is written to hard disk, the queue builds up with segments until the heap exceeds its maximum size
This commit is contained in:
parent
dd316070a5
commit
dba4aa0a02
|
@ -28,7 +28,7 @@ public class BlockingMultiMTSSource extends AbstractMTSSource implements AutoClo
|
|||
if (fixContinuity) {
|
||||
continuityFixer = new ContinuityFixer();
|
||||
}
|
||||
this.sources = new LinkedBlockingQueue<>();
|
||||
this.sources = new LinkedBlockingQueue<>(10);
|
||||
}
|
||||
|
||||
public void addSource(MTSSource source) throws InterruptedException {
|
||||
|
@ -45,7 +45,12 @@ public class BlockingMultiMTSSource extends AbstractMTSSource implements AutoClo
|
|||
packet = switchSourceIfNeeded(packet);
|
||||
|
||||
if (fixContinuity) {
|
||||
continuityFixer.fixContinuity(packet);
|
||||
try {
|
||||
continuityFixer.fixContinuity(packet);
|
||||
} catch(Exception e) {
|
||||
LOG.error("Failed to fix continuity. MTSPacket probably invalid", e);
|
||||
return nextPacketInternal();
|
||||
}
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue