Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit b56a726

Browse files
committed
Fixed compile errors in amlogic grabber
1 parent d403dea commit b56a726

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

libsrc/grabber/amlogic/AmlogicGrabber.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,6 @@ AmlogicGrabber::AmlogicGrabber(const unsigned width, const unsigned height) :
2424
_height(height),
2525
_amlogicCaptureDev(-1)
2626
{
27-
_amlogicCaptureDev = open("/dev/amvideocap0", O_RDONLY, 0);
28-
if (_amlogicCaptureDev == -1)
29-
{
30-
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Failed to open the AMLOGIC device (" << errno << ")" << std::endl;
31-
return;
32-
}
33-
34-
if (ioctl(_amlogicCaptureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_WIDTH, _width) == -1 ||
35-
ioctl(_amlogicCaptureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_HEIGHT, _height) == -1)
36-
{
37-
// Failed to configure frame width
38-
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Failed to configure capture size (" << errno << ")" << std::endl;
39-
}
4027
}
4128

4229
AmlogicGrabber::~AmlogicGrabber()
@@ -70,18 +57,37 @@ void AmlogicGrabber::setVideoMode(const VideoMode videoMode)
7057
void AmlogicGrabber::grabFrame(Image<ColorRgb> & image)
7158
{
7259
// resize the given image if needed
73-
if (image.width() != unsigned(_rectangle.width) || image.height() != unsigned(_rectangle.height))
60+
if (image.width() != _width || image.height() != _height)
7461
{
75-
image.resize(_rectangle.width, _rectangle.height);
62+
image.resize(_width, _height);
7663
}
7764

65+
_amlogicCaptureDev = open("/dev/amvideocap0", O_RDONLY, 0);
66+
if (_amlogicCaptureDev == -1)
67+
{
68+
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Failed to open the AMLOGIC device (" << errno << ")" << std::endl;
69+
return;
70+
}
71+
72+
if (ioctl(_amlogicCaptureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_WIDTH, _width) == -1 ||
73+
ioctl(_amlogicCaptureDev, AMVIDEOCAP_IOW_SET_WANTFRAME_HEIGHT, _height) == -1)
74+
{
75+
// Failed to configure frame width
76+
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Failed to configure capture size (" << errno << ")" << std::endl;
77+
return;
78+
}
79+
80+
std::cout << "AMLOGIC grabber created (size " << _width << "x" << _height << ")" << std::endl;
7881
// Read the snapshot into the memory
7982
void * image_ptr = image.memptr();
8083
const size_t bytesToRead = _width * _height * sizeof(ColorRgb);
81-
const size_t bytesRead = pread(amlogicCaptureDev, image_ptr, bytesToRead, 0)
84+
const size_t bytesRead = pread(_amlogicCaptureDev, image_ptr, bytesToRead, 0);
8285
if (bytesToRead != bytesRead)
8386
{
8487
// Read of snapshot failed
8588
std::cerr << "[" << __PRETTY_FUNCTION__ << "] Capture failed to grab entire image [bytesToRead(" << bytesToRead << ") != bytesRead(" << bytesRead << ")]" << std::endl;
8689
}
90+
91+
close(_amlogicCaptureDev);
92+
_amlogicCaptureDev = -1;
8793
}

libsrc/grabber/amlogic/AmlogicGrabber.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// Utils includes
77
#include <utils/Image.h>
8-
#include <utils/ColorRgba.h>
8+
#include <utils/ColorRgb.h>
99
#include <utils/VideoMode.h>
1010

1111
///
@@ -38,7 +38,7 @@ class AmlogicGrabber
3838
/// @param[out] image The snapped screenshot (should be initialized with correct width and
3939
/// height)
4040
///
41-
void grabFrame(Image<ColorRgba> & image);
41+
void grabFrame(Image<ColorRgb> & image);
4242

4343
private:
4444

libsrc/grabber/amlogic/AmlogicWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeig
1818
_priority(1000),
1919
_timer(),
2020
_image(grabWidth, grabHeight),
21-
_frameGrabber(new DispmanxFrameGrabber(grabWidth, grabHeight)),
21+
_frameGrabber(new AmlogicGrabber(grabWidth, grabHeight)),
2222
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
2323
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0}),
2424
_hyperion(hyperion)

libsrc/grabber/amlogic/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SET(AmlogicHEADERS
1212

1313
SET(AmlogicSOURCES
1414
${CURRENT_SOURCE_DIR}/AmlogicWrapper.cpp
15-
${CURRENT_SOURCE_DIR}/AmlogicFrameGrabber.cpp
15+
${CURRENT_SOURCE_DIR}/AmlogicGrabber.cpp
1616
)
1717

1818
QT4_WRAP_CPP(AmlogicHEADERS_MOC ${AmlogicQT_HEADERS})

0 commit comments

Comments
 (0)