some more fixes

This commit is contained in:
louis 2014-05-09 16:53:56 +02:00
parent 5d7fb01f67
commit 31f55fb489
12 changed files with 369 additions and 316 deletions

View File

@ -14,7 +14,9 @@ Version 0.1.0
- fixed bug that scraped events are not displayed randomly - fixed bug that scraped events are not displayed randomly
Version 0.1.1 Version 0.1.1
- ...
Version 0.1.2
- update of db api - update of db api
- prepare statements only once - prepare statements only once
- added statement statistic - added statement statistic
@ -23,5 +25,3 @@ Version 0.1.1
- added path detection for libmysql - added path detection for libmysql
- fixed epgd state detection - fixed epgd state detection
- added cppcheck to Makefile - added cppcheck to Makefile
Version 0.1.2

View File

@ -4,10 +4,11 @@
# $Id$ # $Id$
# External image lib to use: imagemagick, graphicsmagick # External image lib to use: imagemagick, graphicsmagick
IMAGELIB = imagemagick IMAGELIB = imagemagick
PLUGIN = scraper2vdr PLUGIN = scraper2vdr
HLIB = -L./lib -lhorchi HLIB = -L./lib -lhorchi
### The version number of this plugin (taken from the main source file): ### The version number of this plugin (taken from the main source file):
@ -36,7 +37,7 @@ APIVERSION = $(call PKGCFG,apiversion)
-include $(PLGCFG) -include $(PLGCFG)
LIBS = $(HLIB) $(shell mysql_config --libs_r) -luuid LIBS = $(HLIB) $(shell mysql_config --libs_r) -luuid -lcrypto
### The name of the distribution archive: ### The name of the distribution archive:

View File

@ -32,7 +32,7 @@ CFLAGS += -fPIC -Wreturn-type -Wall -Wno-parentheses -Wformat -pedantic -Wunused
CFLAGS += $(shell mysql_config --include) CFLAGS += $(shell mysql_config --include)
DEFINES = -DPLGDIR='"."' -DUSEUUID -DUSEMD5 DEFINES = -DPLGDIR='"."' -DUSEUUID -DUSEMD5 -USELIBXML
all: lib $(TEST) $(DEMO) all: lib $(TEST) $(DEMO)
lib: $(LIBTARGET).a lib: $(LIBTARGET).a

View File

@ -25,21 +25,20 @@
# include <archive_entry.h> # include <archive_entry.h>
#endif #endif
#ifdef VDR_PLUGIN
# include <vdr/thread.h>
#endif
#include "common.h" #include "common.h"
#include "config.h" #include "config.h"
#ifdef VDR_PLUGIN cMyMutex logMutex;
cMutex logMutex;
#endif
//*************************************************************************** //***************************************************************************
// Debug // Debug
//*************************************************************************** //***************************************************************************
const char* getLogPrefix()
{
return logPrefix;
}
void tell(int eloquence, const char* format, ...) void tell(int eloquence, const char* format, ...)
{ {
if (EPG2VDRConfig.loglevel < eloquence) if (EPG2VDRConfig.loglevel < eloquence)
@ -49,15 +48,12 @@ void tell(int eloquence, const char* format, ...)
char t[sizeBuffer+100]; *t = 0; char t[sizeBuffer+100]; *t = 0;
va_list ap; va_list ap;
#ifdef VDR_PLUGIN logMutex.Lock();
cMutexLock lock(&logMutex);
#endif
va_start(ap, format); va_start(ap, format);
#ifdef VDR_PLUGIN if (getLogPrefix())
snprintf(t, sizeBuffer, LOG_PREFIX); snprintf(t, sizeBuffer, "%s", getLogPrefix());
#endif
vsnprintf(t+strlen(t), sizeBuffer-strlen(t), format, ap); vsnprintf(t+strlen(t), sizeBuffer-strlen(t), format, ap);
@ -74,12 +70,13 @@ void tell(int eloquence, const char* format, ...)
tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_hour, tm->tm_min, tm->tm_sec,
tp.tv_usec / 1000); tp.tv_usec / 1000);
printf("%s %s\n", buf, t); printf("%s %s\n", buf, t);
} }
else else
syslog(LOG_ERR, "%s", t); syslog(LOG_ERR, "%s", t);
logMutex.Unlock();
va_end(ap); va_end(ap);
} }
@ -959,12 +956,103 @@ int unzip(const char* file, const char* filter, char*& buffer, int& size, char*
#endif #endif
//*************************************************************************** //***************************************************************************
// Class LogDuration // cMyMutex
//*************************************************************************** //***************************************************************************
#ifdef VDR_PLUGIN cMyMutex::cMyMutex (void)
{
locked = 0;
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
pthread_mutex_init(&mutex, &attr);
}
# include <vdr/plugin.h> cMyMutex::~cMyMutex()
{
pthread_mutex_destroy(&mutex);
}
void cMyMutex::Lock(void)
{
pthread_mutex_lock(&mutex);
locked++;
}
void cMyMutex::Unlock(void)
{
if (!--locked)
pthread_mutex_unlock(&mutex);
}
//***************************************************************************
// cMyTimeMs
//***************************************************************************
cMyTimeMs::cMyTimeMs(int Ms)
{
if (Ms >= 0)
Set(Ms);
else
begin = 0;
}
uint64_t cMyTimeMs::Now(void)
{
#define MIN_RESOLUTION 5 // ms
static bool initialized = false;
static bool monotonic = false;
struct timespec tp;
if (!initialized) {
// check if monotonic timer is available and provides enough accurate resolution:
if (clock_getres(CLOCK_MONOTONIC, &tp) == 0) {
// long Resolution = tp.tv_nsec;
// require a minimum resolution:
if (tp.tv_sec == 0 && tp.tv_nsec <= MIN_RESOLUTION * 1000000) {
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) {
monotonic = true;
}
else
tell(0, "cMyTimeMs: clock_gettime(CLOCK_MONOTONIC) failed");
}
else
tell(0, "cMyTimeMs: not using monotonic clock - resolution is too bad (%ld s %ld ns)", tp.tv_sec, tp.tv_nsec);
}
else
tell(0, "cMyTimeMs: clock_getres(CLOCK_MONOTONIC) failed");
initialized = true;
}
if (monotonic) {
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
return (uint64_t(tp.tv_sec)) * 1000 + tp.tv_nsec / 1000000;
tell(0, "cMyTimeMs: clock_gettime(CLOCK_MONOTONIC) failed");
monotonic = false;
// fall back to gettimeofday()
}
struct timeval t;
if (gettimeofday(&t, NULL) == 0)
return (uint64_t(t.tv_sec)) * 1000 + t.tv_usec / 1000;
return 0;
}
void cMyTimeMs::Set(int Ms)
{
begin = Now() + Ms;
}
bool cMyTimeMs::TimedOut(void)
{
return Now() >= begin;
}
uint64_t cMyTimeMs::Elapsed(void)
{
return Now() - begin;
}
//***************************************************************************
// Class LogDuration
//***************************************************************************
LogDuration::LogDuration(const char* aMessage, int aLogLevel) LogDuration::LogDuration(const char* aMessage, int aLogLevel)
{ {
@ -973,23 +1061,21 @@ LogDuration::LogDuration(const char* aMessage, int aLogLevel)
// at last ! // at last !
durationStart = cTimeMs::Now(); durationStart = cMyTimeMs::Now();
} }
LogDuration::~LogDuration() LogDuration::~LogDuration()
{ {
tell(logLevel, "duration '%s' was (%ldms)", tell(logLevel, "duration '%s' was (%ldms)",
message, cTimeMs::Now() - durationStart); message, cMyTimeMs::Now() - durationStart);
} }
void LogDuration::show(const char* label) void LogDuration::show(const char* label)
{ {
tell(logLevel, "elapsed '%s' at '%s' was (%ldms)", tell(logLevel, "elapsed '%s' at '%s' was (%ldms)",
message, label, cTimeMs::Now() - durationStart); message, label, cMyTimeMs::Now() - durationStart);
} }
#endif
//*************************************************************************** //***************************************************************************
// Get Unique ID // Get Unique ID
//*************************************************************************** //***************************************************************************

View File

@ -15,9 +15,10 @@
#include <openssl/md5.h> // MD5_* #include <openssl/md5.h> // MD5_*
#ifdef VDR_PLUGIN //#ifdef VDR_PLUGIN
# include <vdr/tools.h> //# include <vdr/tools.h>
#endif //# include <vdr/thread.h>
//#endif
#ifdef USELIBXML #ifdef USELIBXML
# include <libxslt/transform.h> # include <libxslt/transform.h>
@ -29,10 +30,10 @@
// Misc // Misc
//*************************************************************************** //***************************************************************************
#ifndef VDR_PLUGIN // #ifndef VDR_PLUGIN
inline long min(long a, long b) { return a < b ? a : b; } inline long min(long a, long b) { return a < b ? a : b; }
inline long max(long a, long b) { return a > b ? a : b; } inline long max(long a, long b) { return a > b ? a : b; }
#endif // #endif
enum Misc enum Misc
{ {
@ -69,6 +70,9 @@ const char* toCase(Case cs, char* str);
// Tell // Tell
//*************************************************************************** //***************************************************************************
extern const char* logPrefix;
const char* getLogPrefix();
void __attribute__ ((format(printf, 2, 3))) tell(int eloquence, const char* format, ...); void __attribute__ ((format(printf, 2, 3))) tell(int eloquence, const char* format, ...);
//*************************************************************************** //***************************************************************************
@ -220,7 +224,41 @@ int unzip(const char* file, const char* filter, char*& buffer,
int& size, char* entryName); int& size, char* entryName);
#endif #endif
#ifdef VDR_PLUGIN //***************************************************************************
// cMyMutex
//***************************************************************************
class cMyMutex
{
friend class cCondVar;
private:
pthread_mutex_t mutex;
int locked;
public:
cMyMutex(void);
~cMyMutex();
void Lock(void);
void Unlock(void);
};
//***************************************************************************
// cMyTimeMs
//***************************************************************************
class cMyTimeMs
{
private:
uint64_t begin;
public:
cMyTimeMs(int Ms = 0);
static uint64_t Now(void);
void Set(int Ms = 0);
bool TimedOut(void);
uint64_t Elapsed(void);
};
//*************************************************************************** //***************************************************************************
// Log Duration // Log Duration
@ -241,7 +279,6 @@ class LogDuration
uint64_t durationStart; uint64_t durationStart;
int logLevel; int logLevel;
}; };
#endif
//*************************************************************************** //***************************************************************************
#endif //___COMMON_H #endif //___COMMON_H

View File

@ -39,10 +39,13 @@ cEPG2VDRConfig::cEPG2VDRConfig(void)
seriesPort = 2006; seriesPort = 2006;
storeSeriesToFs = no; storeSeriesToFs = no;
#ifdef VDR_PLUGIN // for VDR_PLUGIN
activeOnEpgd = no; activeOnEpgd = no;
scheduleBoot = no; scheduleBoot = no;
#else
// for epgd
sstrcpy(cachePath, "/var/cache/epgd", sizeof(cachePath)); sstrcpy(cachePath, "/var/cache/epgd", sizeof(cachePath));
sstrcpy(httpPath, "/var/epgd/www", sizeof(httpPath)); sstrcpy(httpPath, "/var/epgd/www", sizeof(httpPath));
sstrcpy(pluginPath, PLGDIR, sizeof(pluginPath)); sstrcpy(pluginPath, PLGDIR, sizeof(pluginPath));
@ -51,7 +54,8 @@ cEPG2VDRConfig::cEPG2VDRConfig(void)
updateThreshold = 200; updateThreshold = 200;
maintanance = no; maintanance = no;
httpPort = 9999; httpPort = 9999;
#endif
//
sstrcpy(dbHost, "localhost", sizeof(dbHost)); sstrcpy(dbHost, "localhost", sizeof(dbHost));
dbPort = 3306; dbPort = 3306;

View File

@ -42,10 +42,13 @@ struct cEPG2VDRConfig
int seriesPort; int seriesPort;
int storeSeriesToFs; int storeSeriesToFs;
#ifdef VDR_PLUGIN // for VDR_PLUGIN
int activeOnEpgd; int activeOnEpgd;
int scheduleBoot; int scheduleBoot;
#else
// for epgd
char cachePath[256+TB]; char cachePath[256+TB];
char httpPath[256+TB]; char httpPath[256+TB];
char pluginPath[256+TB]; char pluginPath[256+TB];
@ -54,7 +57,8 @@ struct cEPG2VDRConfig
int updateThreshold; int updateThreshold;
int maintanance; int maintanance;
int httpPort; int httpPort;
#endif
//
char dbHost[100+TB]; char dbHost[100+TB];
int dbPort; int dbPort;

View File

@ -7,6 +7,7 @@
#include "tabledef.h" #include "tabledef.h"
cDbConnection* connection = 0; cDbConnection* connection = 0;
const char* logPrefix = "demo";
//*************************************************************************** //***************************************************************************
// Init Connection // Init Connection

View File

@ -1,190 +1,190 @@
/* /*
* imgtools.c * imgtools.c
* *
* See the README file for copyright information and how to reach the author. * See the README file for copyright information and how to reach the author.
* *
*/ */
#include "imgtools.h" #include "imgtools.h"
//*************************************************************************** //***************************************************************************
// Image converting stuff // Image converting stuff
//*************************************************************************** //***************************************************************************
int fromJpeg(Imlib_Image& image, unsigned char* buffer, int size) int fromJpeg(Imlib_Image& image, unsigned char* buffer, int size)
{ {
struct jpeg_decompress_struct cinfo; struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr; struct jpeg_error_mgr jerr;
int w, h; int w, h;
DATA8 *ptr, *line[16], *data; DATA8 *ptr, *line[16], *data;
DATA32 *ptr2, *dest; DATA32 *ptr2, *dest;
int x, y; int x, y;
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo); jpeg_create_decompress(&cinfo);
jpeg_mem_src(&cinfo, buffer, size); jpeg_mem_src(&cinfo, buffer, size);
jpeg_read_header(&cinfo, TRUE); jpeg_read_header(&cinfo, TRUE);
cinfo.do_fancy_upsampling = FALSE; cinfo.do_fancy_upsampling = FALSE;
cinfo.do_block_smoothing = FALSE; cinfo.do_block_smoothing = FALSE;
jpeg_start_decompress(&cinfo); jpeg_start_decompress(&cinfo);
w = cinfo.output_width; w = cinfo.output_width;
h = cinfo.output_height; h = cinfo.output_height;
image = imlib_create_image(w, h); image = imlib_create_image(w, h);
imlib_context_set_image(image); imlib_context_set_image(image);
dest = ptr2 = imlib_image_get_data(); dest = ptr2 = imlib_image_get_data();
data = (DATA8*)malloc(w * 16 * cinfo.output_components); data = (DATA8*)malloc(w * 16 * cinfo.output_components);
for (int i = 0; i < cinfo.rec_outbuf_height; i++) for (int i = 0; i < cinfo.rec_outbuf_height; i++)
line[i] = data + (i * w * cinfo.output_components); line[i] = data + (i * w * cinfo.output_components);
for (int l = 0; l < h; l += cinfo.rec_outbuf_height) for (int l = 0; l < h; l += cinfo.rec_outbuf_height)
{ {
jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height); jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
int scans = cinfo.rec_outbuf_height; int scans = cinfo.rec_outbuf_height;
if (h - l < scans) if (h - l < scans)
scans = h - l; scans = h - l;
ptr = data; ptr = data;
for (y = 0; y < scans; y++) for (y = 0; y < scans; y++)
{ {
for (x = 0; x < w; x++) for (x = 0; x < w; x++)
{ {
*ptr2 = (0xff000000) | ((ptr[0]) << 16) | ((ptr[1]) << 8) | (ptr[2]); *ptr2 = (0xff000000) | ((ptr[0]) << 16) | ((ptr[1]) << 8) | (ptr[2]);
ptr += cinfo.output_components; ptr += cinfo.output_components;
ptr2++; ptr2++;
} }
} }
} }
free(data); free(data);
imlib_image_put_back_data(dest); imlib_image_put_back_data(dest);
jpeg_finish_decompress(&cinfo); jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo); jpeg_destroy_decompress(&cinfo);
return success; return success;
} }
long toJpeg(Imlib_Image image, MemoryStruct* data, int quality) long toJpeg(Imlib_Image image, MemoryStruct* data, int quality)
{ {
struct jpeg_compress_struct cinfo = { 0 }; struct jpeg_compress_struct cinfo = { 0 };
struct jpeg_error_mgr jerr; struct jpeg_error_mgr jerr;
DATA32* ptr; DATA32* ptr;
DATA8* buf; DATA8* buf;
long unsigned int size = data->size; long unsigned int size = data->size;
imlib_context_set_image(image); imlib_context_set_image(image);
data->clear(); data->clear();
cinfo.err = jpeg_std_error(&jerr); cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo); jpeg_create_compress(&cinfo);
jpeg_mem_dest(&cinfo, (unsigned char**)(&data->memory), &size); jpeg_mem_dest(&cinfo, (unsigned char**)(&data->memory), &size);
cinfo.image_width = imlib_image_get_width(); cinfo.image_width = imlib_image_get_width();
cinfo.image_height = imlib_image_get_height(); cinfo.image_height = imlib_image_get_height();
cinfo.input_components = 3; cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB; cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo); jpeg_set_defaults(&cinfo);
jpeg_set_quality(&cinfo, quality, TRUE); jpeg_set_quality(&cinfo, quality, TRUE);
jpeg_start_compress(&cinfo, TRUE); jpeg_start_compress(&cinfo, TRUE);
// get data pointer // get data pointer
if (!(ptr = imlib_image_get_data_for_reading_only())) if (!(ptr = imlib_image_get_data_for_reading_only()))
return 0; return 0;
// allocate a small buffer to convert image data */ // allocate a small buffer to convert image data */
buf = (DATA8*)malloc(imlib_image_get_width() * 3 * sizeof(DATA8)); buf = (DATA8*)malloc(imlib_image_get_width() * 3 * sizeof(DATA8));
while (cinfo.next_scanline < cinfo.image_height) while (cinfo.next_scanline < cinfo.image_height)
{ {
// convert scanline from ARGB to RGB packed // convert scanline from ARGB to RGB packed
for (int j = 0, i = 0; i < imlib_image_get_width(); i++) for (int j = 0, i = 0; i < imlib_image_get_width(); i++)
{ {
buf[j++] = ((*ptr) >> 16) & 0xff; buf[j++] = ((*ptr) >> 16) & 0xff;
buf[j++] = ((*ptr) >> 8) & 0xff; buf[j++] = ((*ptr) >> 8) & 0xff;
buf[j++] = ((*ptr)) & 0xff; buf[j++] = ((*ptr)) & 0xff;
ptr++; ptr++;
} }
// write scanline // write scanline
jpeg_write_scanlines(&cinfo, (JSAMPROW*)(&buf), 1); jpeg_write_scanlines(&cinfo, (JSAMPROW*)(&buf), 1);
} }
free(buf); free(buf);
jpeg_finish_compress(&cinfo); jpeg_finish_compress(&cinfo);
jpeg_destroy_compress(&cinfo); jpeg_destroy_compress(&cinfo);
return data->size; return data->size;
} }
int scaleImageToJpegBuffer(Imlib_Image image, MemoryStruct* data, int width, int height) int scaleImageToJpegBuffer(Imlib_Image image, MemoryStruct* data, int width, int height)
{ {
if (width && height) if (width && height)
{ {
Imlib_Image scaledImage; Imlib_Image scaledImage;
imlib_context_set_image(image); imlib_context_set_image(image);
int imgWidth = imlib_image_get_width(); int imgWidth = imlib_image_get_width();
int imgHeight = imlib_image_get_height(); int imgHeight = imlib_image_get_height();
double ratio = (double)imgWidth / (double)imgHeight; double ratio = (double)imgWidth / (double)imgHeight;
if ((double)width/(double)imgWidth < (double)height/(double)imgHeight) if ((double)width/(double)imgWidth < (double)height/(double)imgHeight)
height = (int)((double)width / ratio); height = (int)((double)width / ratio);
else else
width = (int)((double)height * ratio); width = (int)((double)height * ratio);
scaledImage = imlib_create_image(width, height); scaledImage = imlib_create_image(width, height);
imlib_context_set_image(scaledImage); imlib_context_set_image(scaledImage);
imlib_context_set_color(240, 240, 240, 255); imlib_context_set_color(240, 240, 240, 255);
imlib_image_fill_rectangle(0, 0, width, height); imlib_image_fill_rectangle(0, 0, width, height);
imlib_blend_image_onto_image(image, 0, 0, 0, imlib_blend_image_onto_image(image, 0, 0, 0,
imgWidth, imgHeight, 0, 0, imgWidth, imgHeight, 0, 0,
width, height); width, height);
toJpeg(scaledImage, data, 70); toJpeg(scaledImage, data, 70);
imlib_context_set_image(scaledImage); imlib_context_set_image(scaledImage);
imlib_free_image(); imlib_free_image();
tell(1, "Scaled image to %d/%d, now %d bytes", width, height, (int)data->size); tell(1, "Scaled image to %d/%d, now %d bytes", width, height, (int)data->size);
} }
else else
{ {
toJpeg(image, data, 70); toJpeg(image, data, 70);
} }
return success; return success;
} }
int scaleJpegBuffer(MemoryStruct* data, int width, int height) int scaleJpegBuffer(MemoryStruct* data, int width, int height)
{ {
Imlib_Image image; Imlib_Image image;
fromJpeg(image, (unsigned char*)data->memory, data->size); fromJpeg(image, (unsigned char*)data->memory, data->size);
scaleImageToJpegBuffer(image, data, width, height); scaleImageToJpegBuffer(image, data, width, height);
imlib_context_set_image(image); imlib_context_set_image(image);
imlib_free_image(); imlib_free_image();
return success; return success;
} }

View File

@ -13,25 +13,7 @@
#include "dbdict.h" #include "dbdict.h"
cDbConnection* connection = 0; cDbConnection* connection = 0;
const char* logPrefix = "test";
//***************************************************************************
//
//***************************************************************************
class cTimeMs
{
private:
uint64_t begin;
public:
cTimeMs(int Ms = 0);
static uint64_t Now(void);
void Set(int Ms = 0);
bool TimedOut(void);
uint64_t Elapsed(void);
};
//*************************************************************************** //***************************************************************************
// Init Connection // Init Connection
@ -273,69 +255,6 @@ void chkStatement3()
delete mapDb; delete mapDb;
} }
// --- cTimeMs ---------------------------------------------------------------
cTimeMs::cTimeMs(int Ms)
{
if (Ms >= 0)
Set(Ms);
else
begin = 0;
}
uint64_t cTimeMs::Now(void)
{
#define MIN_RESOLUTION 5 // ms
static bool initialized = false;
static bool monotonic = false;
struct timespec tp;
if (!initialized) {
// check if monotonic timer is available and provides enough accurate resolution:
if (clock_getres(CLOCK_MONOTONIC, &tp) == 0) {
// long Resolution = tp.tv_nsec;
// require a minimum resolution:
if (tp.tv_sec == 0 && tp.tv_nsec <= MIN_RESOLUTION * 1000000) {
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) {
monotonic = true;
}
else
tell(0, "cTimeMs: clock_gettime(CLOCK_MONOTONIC) failed");
}
else
tell(0, "cTimeMs: not using monotonic clock - resolution is too bad (%ld s %ld ns)", tp.tv_sec, tp.tv_nsec);
}
else
tell(0, "cTimeMs: clock_getres(CLOCK_MONOTONIC) failed");
initialized = true;
}
if (monotonic) {
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
return (uint64_t(tp.tv_sec)) * 1000 + tp.tv_nsec / 1000000;
tell(0, "cTimeMs: clock_gettime(CLOCK_MONOTONIC) failed");
monotonic = false;
// fall back to gettimeofday()
}
struct timeval t;
if (gettimeofday(&t, NULL) == 0)
return (uint64_t(t.tv_sec)) * 1000 + t.tv_usec / 1000;
return 0;
}
void cTimeMs::Set(int Ms)
{
begin = Now() + Ms;
}
bool cTimeMs::TimedOut(void)
{
return Now() >= begin;
}
uint64_t cTimeMs::Elapsed(void)
{
return Now() - begin;
}
//*************************************************************************** //***************************************************************************
// //
//*************************************************************************** //***************************************************************************

View File

@ -7,6 +7,7 @@
*/ */
#include "scraper2vdr.h" #include "scraper2vdr.h"
const char* logPrefix = LOG_PREFIX;
#if defined (APIVERSNUM) && (APIVERSNUM < 10600) #if defined (APIVERSNUM) && (APIVERSNUM < 10600)
# error VDR API versions < 1.6.0 are not supported ! # error VDR API versions < 1.6.0 are not supported !

View File

@ -354,7 +354,7 @@ void cScrapManager::DumpMovies(void) {
} }
void cScrapManager::DumpRecordings(void) { void cScrapManager::DumpRecordings(void) {
tell(0, "%d recordings in memory:", (int)recordings.size()); tell(0, "%ld recordings in memory:", recordings.size());
for (map<sRecordingsKey, sEventsValue>::iterator it = recordings.begin(); it != recordings.end(); it++) { for (map<sRecordingsKey, sEventsValue>::iterator it = recordings.begin(); it != recordings.end(); it++) {
sRecordingsKey key = it->first; sRecordingsKey key = it->first;
sEventsValue val = it->second; sEventsValue val = it->second;