mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 15:02:58 +02:00
- rename lt_debug => hal_debug; it's not only libtriple debugging
Signed-off-by: Thilo Graf <dbt@novatux.de> - debuglevel fixed
This commit is contained in:
@@ -12,9 +12,9 @@
|
||||
#include <aio.h>
|
||||
|
||||
#include "record_lib.h"
|
||||
#include "lt_debug.h"
|
||||
#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_RECORD, this, args)
|
||||
#define lt_info(args...) _lt_info(TRIPLE_DEBUG_RECORD, this, args)
|
||||
#include "hal_debug.h"
|
||||
#define hal_debug(args...) _hal_debug(HAL_DEBUG_RECORD, this, args)
|
||||
#define hal_info(args...) _hal_info(HAL_DEBUG_RECORD, this, args)
|
||||
|
||||
/* helper function to call the cpp thread loop */
|
||||
void *execute_record_thread(void *c)
|
||||
@@ -33,7 +33,7 @@ void *execute_writer_thread(void *c)
|
||||
|
||||
cRecord::cRecord(int num, int bs_dmx, int bs)
|
||||
{
|
||||
lt_info("%s %d\n", __func__, num);
|
||||
hal_info("%s %d\n", __func__, num);
|
||||
dmx = NULL;
|
||||
record_thread_running = false;
|
||||
file_fd = -1;
|
||||
@@ -47,14 +47,14 @@ cRecord::cRecord(int num, int bs_dmx, int bs)
|
||||
|
||||
cRecord::~cRecord()
|
||||
{
|
||||
lt_info("%s: calling ::Stop()\n", __func__);
|
||||
hal_info("%s: calling ::Stop()\n", __func__);
|
||||
Stop();
|
||||
lt_info("%s: end\n", __func__);
|
||||
hal_info("%s: end\n", __func__);
|
||||
}
|
||||
|
||||
bool cRecord::Open(void)
|
||||
{
|
||||
lt_info("%s\n", __func__);
|
||||
hal_info("%s\n", __func__);
|
||||
exit_flag = RECORD_STOPPED;
|
||||
return true;
|
||||
}
|
||||
@@ -63,13 +63,13 @@ bool cRecord::Open(void)
|
||||
// unused
|
||||
void cRecord::Close(void)
|
||||
{
|
||||
lt_info("%s: \n", __func__);
|
||||
hal_info("%s: \n", __func__);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool cRecord::Start(int fd, unsigned short vpid, unsigned short *apids, int numpids, uint64_t)
|
||||
{
|
||||
lt_info("%s: fd %d, vpid 0x%03x\n", __func__, fd, vpid);
|
||||
hal_info("%s: fd %d, vpid 0x%03x\n", __func__, fd, vpid);
|
||||
int i;
|
||||
|
||||
if (!dmx)
|
||||
@@ -91,7 +91,7 @@ bool cRecord::Start(int fd, unsigned short vpid, unsigned short *apids, int nump
|
||||
{
|
||||
exit_flag = RECORD_FAILED_READ;
|
||||
errno = i;
|
||||
lt_info("%s: error creating thread! (%m)\n", __func__);
|
||||
hal_info("%s: error creating thread! (%m)\n", __func__);
|
||||
delete dmx;
|
||||
dmx = NULL;
|
||||
return false;
|
||||
@@ -102,10 +102,10 @@ bool cRecord::Start(int fd, unsigned short vpid, unsigned short *apids, int nump
|
||||
|
||||
bool cRecord::Stop(void)
|
||||
{
|
||||
lt_info("%s\n", __func__);
|
||||
hal_info("%s\n", __func__);
|
||||
|
||||
if (exit_flag != RECORD_RUNNING)
|
||||
lt_info("%s: status not RUNNING? (%d)\n", __func__, exit_flag);
|
||||
hal_info("%s: status not RUNNING? (%d)\n", __func__, exit_flag);
|
||||
|
||||
exit_flag = RECORD_STOPPED;
|
||||
if (record_thread_running)
|
||||
@@ -114,7 +114,7 @@ bool cRecord::Stop(void)
|
||||
|
||||
/* We should probably do that from the destructor... */
|
||||
if (!dmx)
|
||||
lt_info("%s: dmx == NULL?\n", __func__);
|
||||
hal_info("%s: dmx == NULL?\n", __func__);
|
||||
else
|
||||
delete dmx;
|
||||
dmx = NULL;
|
||||
@@ -122,7 +122,7 @@ bool cRecord::Stop(void)
|
||||
if (file_fd != -1)
|
||||
close(file_fd);
|
||||
else
|
||||
lt_info("%s: file_fd not open??\n", __func__);
|
||||
hal_info("%s: file_fd not open??\n", __func__);
|
||||
file_fd = -1;
|
||||
return true;
|
||||
}
|
||||
@@ -133,9 +133,9 @@ bool cRecord::ChangePids(unsigned short /*vpid*/, unsigned short *apids, int num
|
||||
int j;
|
||||
bool found;
|
||||
unsigned short pid;
|
||||
lt_info("%s\n", __func__);
|
||||
hal_info("%s\n", __func__);
|
||||
if (!dmx) {
|
||||
lt_info("%s: DMX = NULL\n", __func__);
|
||||
hal_info("%s: DMX = NULL\n", __func__);
|
||||
return false;
|
||||
}
|
||||
pids = dmx->pesfds;
|
||||
@@ -169,9 +169,9 @@ bool cRecord::ChangePids(unsigned short /*vpid*/, unsigned short *apids, int num
|
||||
bool cRecord::AddPid(unsigned short pid)
|
||||
{
|
||||
std::vector<pes_pids> pids;
|
||||
lt_info("%s: \n", __func__);
|
||||
hal_info("%s: \n", __func__);
|
||||
if (!dmx) {
|
||||
lt_info("%s: DMX = NULL\n", __func__);
|
||||
hal_info("%s: DMX = NULL\n", __func__);
|
||||
return false;
|
||||
}
|
||||
pids = dmx->pesfds;
|
||||
@@ -210,7 +210,7 @@ void cRecord::WriterThread()
|
||||
|
||||
void cRecord::RecordThread()
|
||||
{
|
||||
lt_info("%s: begin\n", __func__);
|
||||
hal_info("%s: begin\n", __func__);
|
||||
char threadname[17];
|
||||
strncpy(threadname, "RecordThread", sizeof(threadname));
|
||||
threadname[16] = 0;
|
||||
@@ -223,20 +223,20 @@ void cRecord::RecordThread()
|
||||
struct aiocb a;
|
||||
|
||||
buf = (uint8_t *)malloc(bufsize);
|
||||
lt_info("BUFSIZE=0x%x READSIZE=0x%x\n", bufsize, readsize);
|
||||
hal_info("BUFSIZE=0x%x READSIZE=0x%x\n", bufsize, readsize);
|
||||
if (!buf)
|
||||
{
|
||||
exit_flag = RECORD_FAILED_MEMORY;
|
||||
lt_info("%s: unable to allocate buffer! (out of memory)\n", __func__);
|
||||
hal_info("%s: unable to allocate buffer! (out of memory)\n", __func__);
|
||||
if (failureCallback)
|
||||
failureCallback(failureData);
|
||||
lt_info("%s: end\n", __func__);
|
||||
hal_info("%s: end\n", __func__);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
int val = fcntl(file_fd, F_GETFL);
|
||||
if (fcntl(file_fd, F_SETFL, val|O_APPEND))
|
||||
lt_info("%s: O_APPEND? (%m)\n", __func__);
|
||||
hal_info("%s: O_APPEND? (%m)\n", __func__);
|
||||
|
||||
memset(&a, 0, sizeof(a));
|
||||
a.aio_fildes = file_fd;
|
||||
@@ -251,20 +251,20 @@ void cRecord::RecordThread()
|
||||
if (buf_pos < bufsize)
|
||||
{
|
||||
if (overflow_count) {
|
||||
lt_info("%s: Overflow cleared after %d iterations\n", __func__, overflow_count);
|
||||
hal_info("%s: Overflow cleared after %d iterations\n", __func__, overflow_count);
|
||||
overflow_count = 0;
|
||||
}
|
||||
int toread = bufsize - buf_pos;
|
||||
if (toread > readsize)
|
||||
toread = readsize;
|
||||
ssize_t s = dmx->Read(buf + buf_pos, toread, 50);
|
||||
lt_debug("%s: buf_pos %6d s %6d / %6d\n", __func__,
|
||||
hal_debug("%s: buf_pos %6d s %6d / %6d\n", __func__,
|
||||
buf_pos, (int)s, bufsize - buf_pos);
|
||||
if (s < 0)
|
||||
{
|
||||
if (errno != EAGAIN && (errno != EOVERFLOW || !overflow))
|
||||
{
|
||||
lt_info("%s: read failed: %m\n", __func__);
|
||||
hal_info("%s: read failed: %m\n", __func__);
|
||||
exit_flag = RECORD_FAILED_READ;
|
||||
state = REC_STATUS_OVERFLOW;
|
||||
break;
|
||||
@@ -291,13 +291,13 @@ void cRecord::RecordThread()
|
||||
overflow_count = 0;
|
||||
overflow = true;
|
||||
if (!(overflow_count % 10))
|
||||
lt_info("%s: buffer full! Overflow? (%d)\n", __func__, ++overflow_count);
|
||||
hal_info("%s: buffer full! Overflow? (%d)\n", __func__, ++overflow_count);
|
||||
state = REC_STATUS_SLOW;
|
||||
}
|
||||
r = aio_error(&a);
|
||||
if (r == EINPROGRESS)
|
||||
{
|
||||
lt_debug("%s: aio in progress, free: %d\n", __func__, bufsize - buf_pos);
|
||||
hal_debug("%s: aio in progress, free: %d\n", __func__, bufsize - buf_pos);
|
||||
continue;
|
||||
}
|
||||
// not calling aio_return causes a memory leak --martii
|
||||
@@ -305,11 +305,11 @@ void cRecord::RecordThread()
|
||||
if (r < 0)
|
||||
{
|
||||
exit_flag = RECORD_FAILED_FILE;
|
||||
lt_debug("%s: aio_return = %d (%m)\n", __func__, r);
|
||||
hal_debug("%s: aio_return = %d (%m)\n", __func__, r);
|
||||
break;
|
||||
}
|
||||
else
|
||||
lt_debug("%s: aio_return = %d, free: %d\n", __func__, r, bufsize - buf_pos);
|
||||
hal_debug("%s: aio_return = %d, free: %d\n", __func__, r, bufsize - buf_pos);
|
||||
if (posix_fadvise(file_fd, 0, 0, POSIX_FADV_DONTNEED))
|
||||
perror("posix_fadvise");
|
||||
if (queued)
|
||||
@@ -323,7 +323,7 @@ void cRecord::RecordThread()
|
||||
r = aio_write(&a);
|
||||
if (r)
|
||||
{
|
||||
lt_info("%s: aio_write %d (%m)\n", __func__, r);
|
||||
hal_info("%s: aio_write %d (%m)\n", __func__, r);
|
||||
exit_flag = RECORD_FAILED_FILE;
|
||||
break;
|
||||
}
|
||||
@@ -331,7 +331,7 @@ void cRecord::RecordThread()
|
||||
dmx->Stop();
|
||||
while (true) /* write out the unwritten buffer content */
|
||||
{
|
||||
lt_debug("%s: run-out write, buf_pos %d\n", __func__, buf_pos);
|
||||
hal_debug("%s: run-out write, buf_pos %d\n", __func__, buf_pos);
|
||||
r = aio_error(&a);
|
||||
if (r == EINPROGRESS)
|
||||
{
|
||||
@@ -342,7 +342,7 @@ void cRecord::RecordThread()
|
||||
if (r < 0)
|
||||
{
|
||||
exit_flag = RECORD_FAILED_FILE;
|
||||
lt_info("%s: aio_result: %d (%m)\n", __func__, r);
|
||||
hal_info("%s: aio_result: %d (%m)\n", __func__, r);
|
||||
break;
|
||||
}
|
||||
if (!queued)
|
||||
@@ -372,7 +372,7 @@ void cRecord::RecordThread()
|
||||
|
||||
if ((exit_flag != RECORD_STOPPED) && failureCallback)
|
||||
failureCallback(failureData);
|
||||
lt_info("%s: end\n", __func__);
|
||||
hal_info("%s: end\n", __func__);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user