mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fixed json value lookup
Only close the amlogic device every 20th succesfull reads. Former-commit-id: 46c0cf1465b8c8b33d696bb2aeac5cabb1cb2819
This commit is contained in:
parent
a3db06e90e
commit
ad876b0d8c
@ -122,6 +122,8 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
|
|||||||
{
|
{
|
||||||
// Failed to configure frame width
|
// Failed to configure frame width
|
||||||
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Failed to configure capture size (" << errno << "): " << strerror(errno) << std::endl;
|
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Failed to configure capture size (" << errno << "): " << strerror(errno) << std::endl;
|
||||||
|
close(_amlogicCaptureDev);
|
||||||
|
_amlogicCaptureDev = -1;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,18 +135,27 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
|
|||||||
if (bytesRead == -1)
|
if (bytesRead == -1)
|
||||||
{
|
{
|
||||||
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Read of device failed (erno=" << errno << "): " << strerror(errno) << std::endl;
|
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Read of device failed (erno=" << errno << "): " << strerror(errno) << std::endl;
|
||||||
|
close(_amlogicCaptureDev);
|
||||||
|
_amlogicCaptureDev = -1;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (bytesToRead != bytesRead)
|
else if (bytesToRead != bytesRead)
|
||||||
{
|
{
|
||||||
// Read of snapshot failed
|
// Read of snapshot failed
|
||||||
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Capture failed to grab entire image [bytesToRead(" << bytesToRead << ") != bytesRead(" << bytesRead << ")]" << std::endl;
|
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Capture failed to grab entire image [bytesToRead(" << bytesToRead << ") != bytesRead(" << bytesRead << ")]" << std::endl;
|
||||||
|
close(_amlogicCaptureDev);
|
||||||
|
_amlogicCaptureDev = -1;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now we always close the device again
|
// For now we always close the device now and again
|
||||||
close(_amlogicCaptureDev);
|
static int readCnt = 0;
|
||||||
_amlogicCaptureDev = -1;
|
++readCnt;
|
||||||
|
if (readCnt > 20)
|
||||||
|
{
|
||||||
|
close(_amlogicCaptureDev);
|
||||||
|
_amlogicCaptureDev = -1;
|
||||||
|
readCnt = 0;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ int main(int argc, char** argv)
|
|||||||
FramebufferWrapper * fbGrabber = nullptr;
|
FramebufferWrapper * fbGrabber = nullptr;
|
||||||
if (config.isMember("framebuffergrabber") || config.isMember("framegrabber"))
|
if (config.isMember("framebuffergrabber") || config.isMember("framegrabber"))
|
||||||
{
|
{
|
||||||
const Json::Value & grabberConfig = config.isMember("framebuffergrabber")? config["framebuffergrabber"] : config.isMember("framegrabber");
|
const Json::Value & grabberConfig = config.isMember("framebuffergrabber")? config["framebuffergrabber"] : config["framegrabber"];
|
||||||
fbGrabber = new FramebufferWrapper(
|
fbGrabber = new FramebufferWrapper(
|
||||||
grabberConfig.get("device", "/dev/fb0").asString(),
|
grabberConfig.get("device", "/dev/fb0").asString(),
|
||||||
grabberConfig["width"].asUInt(),
|
grabberConfig["width"].asUInt(),
|
||||||
|
Loading…
Reference in New Issue
Block a user