-You have a security camera and a vibration sensor installed.
-The security camera feed is constantly saved on to a hard drive, but any data over 5 minutes old is deleted.
-If the motion sensor is tripped, a new permanent video file is created, with the last 5 minutes stuck on to the beginning. Video is now saved onto this new file (after the first 5 minutes).
Analogy > My code:
Camera feed > javax.sound.sampled.TargetDataLine
5 minute save > byte preBuffer
Permanent video file > java.io.ByteArrayOutputStream
I've written some code, it doesn't work, and I'm sure it's horribly done and inefficient: Pastebin
The start and stop triggers are temporary hackish code, but that are irrelevant to my current problem.
So I need a way to save up data from the line, and once triggered, add some of the saved data to a new stream, and record any additional data as it comes.