28    itsFd(fd), itsLength(length), itsBytesUsed(0), itsDmaBufFd(dmafd)
 
   33#ifdef JEVOIS_PLATFORM_A33 
   35    itsAddr = mmap(NULL, 
length, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_SHARED, fd, offset);
 
   37    itsAddr = mmap(NULL, 
length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset);
 
   39    if (itsAddr == MAP_FAILED) 
PLFATAL(
"Unable to map buffer");
 
   44    itsAddr = 
reinterpret_cast<void *
>(
new char[
length]);
 
 
   53    if (munmap(itsAddr, itsLength) < 0) 
PLERROR(
"munmap failed");
 
   57    delete [] 
reinterpret_cast<char *
>(itsAddr);
 
   60  if (itsDmaBufFd > 0) close(itsDmaBufFd);
 
 
   66#ifdef JEVOIS_PLATFORM_A33 
   67  int const syscall = 0xf0002;
 
   75                    : 
"r" (begin), 
"r" (end), 
"r" (syscall)
 
   80  (void)begin; (void)end;
 
 
   87#ifdef JEVOIS_PLATFORM_A33 
   94    std::ofstream ofs(
"/proc/sys/vm/drop_caches");
 
   95    if (ofs.is_open() == 
false) { 
LERROR(
"Cannot flush cache -- IGNORED"); 
return; }
 
   96    ofs << 
"1" << std::endl;
 
   99    clearcache(
reinterpret_cast<char *
>(itsAddr), 
reinterpret_cast<char *
>(itsAddr) + itsLength);
 
 
void clearcache(char *begin, char *end)
 
size_t bytesUsed() const
Get the number of bytes used, valid only for MJPEG images.
 
~VideoBuf()
Destructor unmaps the memory.
 
VideoBuf(int const fd, size_t const length, unsigned int offset, int const dmafd)
Construct and allocate MMAP'd memory.
 
void setBytesUsed(size_t n)
Set the number of bytes used, eg, for MJPEG images that application code compressed into the buffer.
 
size_t length() const
Get the allocated memory length.
 
void sync()
Sync the data.
 
void * data() const
Get a pointer to the buffer data.
 
int dmaFd() const
Get the dma_buf fd associated with this buffer, which was given at construction.
 
#define PLERROR(msg)
Like LERROR but appends errno and strerror(errno), to be used when some system call fails.
 
#define PLFATAL(msg)
Like LDEBUG but appends errno and strerror(errno), to be used when some system call fails.
 
#define LERROR(msg)
Convenience macro for users to print out console or syslog messages, ERROR level.