Skip to content

Commit

Permalink
Fixed json value lookup
Browse files Browse the repository at this point in the history
Only close the amlogic device every 20th succesfull reads.
  • Loading branch information
tvdzwan committed Sep 3, 2015
1 parent ccb9b98 commit 46c0cf1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions libsrc/grabber/amlogic/AmlogicGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
{
// Failed to configure frame width
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Failed to configure capture size (" << errno << "): " << strerror(errno) << std::endl;
close(_amlogicCaptureDev);
_amlogicCaptureDev = -1;
return -1;
}

Expand All @@ -133,18 +135,27 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
if (bytesRead == -1)
{
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Read of device failed (erno=" << errno << "): " << strerror(errno) << std::endl;
close(_amlogicCaptureDev);
_amlogicCaptureDev = -1;
return -1;
}
else if (bytesToRead != bytesRead)
{
// Read of snapshot failed
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Capture failed to grab entire image [bytesToRead(" << bytesToRead << ") != bytesRead(" << bytesRead << ")]" << std::endl;
close(_amlogicCaptureDev);
_amlogicCaptureDev = -1;
return -1;
}

// For now we always close the device again
close(_amlogicCaptureDev);
_amlogicCaptureDev = -1;

// For now we always close the device now and again
static int readCnt = 0;
++readCnt;
if (readCnt > 20)
{
close(_amlogicCaptureDev);
_amlogicCaptureDev = -1;
readCnt = 0;
}
return 0;
}
2 changes: 1 addition & 1 deletion src/hyperiond/hyperiond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ int main(int argc, char** argv)
FramebufferWrapper * fbGrabber = nullptr;
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(
grabberConfig.get("device", "/dev/fb0").asString(),
grabberConfig["width"].asUInt(),
Expand Down

0 comments on commit 46c0cf1

Please sign in to comment.