[c-host] improve capture reinitialization

This commit is contained in:
Geoffrey McRae 2019-03-01 15:57:48 +11:00
parent 39ac07bfde
commit 836e8a5654

View File

@ -111,6 +111,22 @@ bool stopThreads()
return ok; return ok;
} }
static bool captureStart(struct CaptureInterface * iface)
{
DEBUG_INFO("Using : %s", iface->getName());
const unsigned int maxFrameSize = iface->getMaxFrameSize();
if (maxFrameSize > app.frameSize)
{
DEBUG_ERROR("Maximum frame size of %d bytes excceds maximum space available", maxFrameSize);
return false;
}
DEBUG_INFO("Capture Size : %u MiB (%u)", maxFrameSize / 1048576, maxFrameSize);
DEBUG_INFO("==== [ Capture Start ] ====");
return startThreads();
}
int app_main(bool * termSignal) int app_main(bool * termSignal)
{ {
unsigned int shmemSize = os_shmemSize(); unsigned int shmemSize = os_shmemSize();
@ -165,24 +181,11 @@ int app_main(bool * termSignal)
goto fail; goto fail;
} }
DEBUG_INFO("Using : %s", iface->getName()); if (!captureStart(iface))
const unsigned int maxFrameSize = iface->getMaxFrameSize();
if (maxFrameSize > app.frameSize)
{ {
DEBUG_ERROR("Maximum frame size of %d bytes excceds maximum space available", maxFrameSize);
exitcode = -1; exitcode = -1;
goto exit; goto exit;
} }
DEBUG_INFO("Capture Size : %u MiB (%u)", maxFrameSize / 1048576, maxFrameSize);
DEBUG_INFO("==== [ Capture Start ] ====");
if (!startThreads())
{
exitcode = -1;
goto finish;
}
while(!*termSignal) while(!*termSignal)
{ {
@ -211,7 +214,7 @@ int app_main(bool * termSignal)
goto finish; goto finish;
} }
if (!startThreads()) if (!captureStart(iface))
{ {
exitcode = -1; exitcode = -1;
goto finish; goto finish;