final int index = i;
threads[index] = new Thread(new Runnable()
{
public void run()
{
final IMediaReader reader = ToolFactory.makeReader(
"fixtures/testfile_videoonly_20sec.flv");
try
{
reader.setBufferedImageTypeToGenerate(BufferedImage.TYPE_3BYTE_BGR);
reader.setAddDynamicStreams(false);
reader.setQueryMetaData(true);
if (ADD_VIEWER)
{
final IMediaViewer viewer = ToolFactory.makeViewer();
reader.addListener(viewer);
}
reader.addListener(ToolFactory.makeWriter(
MultiThreadedWritingExhaustiveTest.class.getName()
+ "_" + mModel.toString()
+ "_" + mTestNumber + "_" + index + ".flv", reader));
while (reader.readPacket() == null)
++numPackets[index];
}
catch (OutOfMemoryError e)
{
// This test will cause this error on small JVMs, and that's OK
// we'll just let this thread abort and keep going. There are other
// tests in this suite that look at memory allocation errors.
log.debug("Thread {} exited with memory exception WHICH IS OK: {}",
index, e);
numPackets[index] = -1;
}
finally
{
try {
reader.close();
} catch (RuntimeException e) {
log.debug("Got and ignoring: {}", e);
}
log.debug("thread exited with {} packets processed",
numPackets[index]);