Added logging to X11Grabber (#71)

* Added logging to X11Grabber

* Added logging to Amlogic grabber.

* Fixed mistake in amlogicgrabber.h

* fixed compile issue

* Trigger

* cleaned up log messages
This commit is contained in:
XfableX
2016-06-30 00:48:53 +10:00
committed by brindosch
parent e5332c44de
commit 6327a38582
4 changed files with 23 additions and 17 deletions

18
libsrc/grabber/amlogic/AmlogicGrabber.cpp Normal file → Executable file
View File

@@ -3,7 +3,7 @@
#include <algorithm>
#include <cassert>
#include <iostream>
#include <utils/Logger.h>
// Linux includes
#include <errno.h>
#include <fcntl.h>
@@ -30,7 +30,7 @@ AmlogicGrabber::AmlogicGrabber(const unsigned width, const unsigned height) :
_height(std::max(160u, height)),
_amlogicCaptureDev(-1)
{
std::cout << "AMLOGICGRABBER INFO: [" << __PRETTY_FUNCTION__ << "] constructed(" << _width << "x" << _height << ")" << std::endl;
Info(_log, "[%s] constructed(%s x %s)",__PRETTY_FUNCTION__,_width,_height);
}
AmlogicGrabber::~AmlogicGrabber()
@@ -39,7 +39,7 @@ AmlogicGrabber::~AmlogicGrabber()
{
if (close(_amlogicCaptureDev) == -1)
{
std::cerr << "AMLOGICGRABBER ERROR: [" << __PRETTY_FUNCTION__ << "] Failed to close device (" << errno << ")" << std::endl;
Error(_log, "[%s] Failed to close device (%s)",__PRETTY_FUNCTION__,errno);
}
_amlogicCaptureDev = -1;
}
@@ -69,7 +69,7 @@ bool AmlogicGrabber::isVideoPlaying()
int video_fd = open(videoDevice.c_str(), O_RDONLY);
if (video_fd < 0)
{
std::cerr << "AMLOGICGRABBER ERROR: Failed to open video device(" << videoDevice << "): " << strerror(errno) << std::endl;
Error(_log, "Failed to open video device(%s): %s",videoDevice.c_str(),strerror(errno));
return false;
}
@@ -77,7 +77,7 @@ bool AmlogicGrabber::isVideoPlaying()
int videoDisabled;
if (ioctl(video_fd, AMSTREAM_IOC_GET_VIDEO_DISABLE, &videoDisabled) == -1)
{
std::cerr << "AMLOGICGRABBER ERROR: Failed to retrieve video state from device: " << strerror(errno) << std::endl;
Error(_log, "Failed to retrieve video state from device: %s",strerror(errno));
close(video_fd);
return false;
}
@@ -111,7 +111,7 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
// If the device is still not open, there is something wrong
if (_amlogicCaptureDev == -1)
{
std::cerr << "AMLOGICGRABBER ERROR:[" << __PRETTY_FUNCTION__ << "] Failed to open the AMLOGIC device (" << errno << "): " << strerror(errno) << std::endl;
Error(_log,"[%s] Failed to open the AMLOGIC device ():",__PRETTY_FUNCTION__,errno,strerror(errno));
return -1;
}
}
@@ -121,7 +121,7 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
ioctl(_amlogicCaptureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_HEIGHT, _height) == -1)
{
// Failed to configure frame width
std::cerr << "AMLOGICGRABBER ERROR: [" << __PRETTY_FUNCTION__ << "] Failed to configure capture size (" << errno << "): " << strerror(errno) << std::endl;
Error(_log,"[%s] Failed to configure capture size (%s)",__PRETTY_FUNCTION__,errno,strerror(errno));
close(_amlogicCaptureDev);
_amlogicCaptureDev = -1;
return -1;
@@ -134,7 +134,7 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
const ssize_t bytesRead = pread(_amlogicCaptureDev, image_ptr, bytesToRead, 0);
if (bytesRead == -1)
{
std::cerr << "AMLOGICGRABBER ERROR: [" << __PRETTY_FUNCTION__ << "] Read of device failed (erno=" << errno << "): " << strerror(errno) << std::endl;
Error(_log,"[%s] Read of device failed (erno=%s): %s",__PRETTY_FUNCTION__,errno,strerror(errno));
close(_amlogicCaptureDev);
_amlogicCaptureDev = -1;
return -1;
@@ -142,7 +142,7 @@ int AmlogicGrabber::grabFrame(Image<ColorBgr> & image)
else if (bytesToRead != bytesRead)
{
// Read of snapshot failed
std::cerr << "AMLOGICGRABBER ERROR: [" << __PRETTY_FUNCTION__ << "] Capture failed to grab entire image [bytesToRead(" << bytesToRead << ") != bytesRead(" << bytesRead << ")]" << std::endl;
Error(_log,"[%s] Capture failed to grab entire image [bytesToRead(%s) != bytesRead(%s)]",__PRETTY_FUNCTION__,bytesToRead,bytesRead);
close(_amlogicCaptureDev);
_amlogicCaptureDev = -1;
return -1;