mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
Merge remote-tracking branch 'martiis-libstb-hal/master'
Origin commit data
------------------
Branch: master
Commit: 40461c4cce
Author: max_10 <max_10@gmx.de>
Date: 2014-08-25 (Mon, 25 Aug 2014)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -23,6 +23,13 @@ void *execute_record_thread(void *c)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *execute_writer_thread(void *c)
|
||||||
|
{
|
||||||
|
cRecord *obj = (cRecord *)c;
|
||||||
|
obj->WriterThread();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
cRecord::cRecord(int num, int bs_dmx, int bs)
|
cRecord::cRecord(int num, int bs_dmx, int bs)
|
||||||
{
|
{
|
||||||
lt_info("%s %d\n", __func__, num);
|
lt_info("%s %d\n", __func__, num);
|
||||||
@@ -174,6 +181,32 @@ bool cRecord::AddPid(unsigned short pid)
|
|||||||
return dmx->addPid(pid);
|
return dmx->addPid(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cRecord::WriterThread()
|
||||||
|
{
|
||||||
|
char threadname[17];
|
||||||
|
strncpy(threadname, "WriterThread", sizeof(threadname));
|
||||||
|
threadname[16] = 0;
|
||||||
|
prctl (PR_SET_NAME, (unsigned long)&threadname);
|
||||||
|
unsigned int chunk = 0;
|
||||||
|
while (!sem_wait(&sem)) {
|
||||||
|
if (!io_len[chunk]) // empty, assume end of recording
|
||||||
|
return;
|
||||||
|
unsigned char *p_buf = io_buf[chunk];
|
||||||
|
size_t p_len = io_len[chunk];
|
||||||
|
while (p_len) {
|
||||||
|
ssize_t written = write(file_fd, p_buf, p_len);
|
||||||
|
if (written < 0)
|
||||||
|
break;
|
||||||
|
p_len -= written;
|
||||||
|
p_buf += written;
|
||||||
|
}
|
||||||
|
if (posix_fadvise(file_fd, 0, 0, POSIX_FADV_DONTNEED))
|
||||||
|
perror("posix_fadvise");
|
||||||
|
chunk++;
|
||||||
|
chunk %= RECORD_WRITER_CHUNKS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cRecord::RecordThread()
|
void cRecord::RecordThread()
|
||||||
{
|
{
|
||||||
lt_info("%s: begin\n", __func__);
|
lt_info("%s: begin\n", __func__);
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define __RECORD_TD_H
|
#define __RECORD_TD_H
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <semaphore.h>
|
||||||
#include "dmx_lib.h"
|
#include "dmx_lib.h"
|
||||||
|
|
||||||
#define REC_STATUS_OK 0
|
#define REC_STATUS_OK 0
|
||||||
@@ -32,6 +33,11 @@ class cRecord
|
|||||||
int bufsize_dmx;
|
int bufsize_dmx;
|
||||||
void (*failureCallback)(void *);
|
void (*failureCallback)(void *);
|
||||||
void *failureData;
|
void *failureData;
|
||||||
|
|
||||||
|
sem_t sem;
|
||||||
|
#define RECORD_WRITER_CHUNKS 16
|
||||||
|
unsigned char *io_buf[RECORD_WRITER_CHUNKS];
|
||||||
|
size_t io_len[RECORD_WRITER_CHUNKS];
|
||||||
public:
|
public:
|
||||||
cRecord(int num = 0, int bs_dmx = 100 * 188 * 1024, int bs = 100 * 188 * 1024);
|
cRecord(int num = 0, int bs_dmx = 100 * 188 * 1024, int bs = 100 * 188 * 1024);
|
||||||
void setFailureCallback(void (*f)(void *), void *d) { failureCallback = f; failureData = d; }
|
void setFailureCallback(void (*f)(void *), void *d) { failureCallback = f; failureData = d; }
|
||||||
@@ -46,5 +52,6 @@ class cRecord
|
|||||||
bool ChangePids(unsigned short vpid, unsigned short *apids, int numapids);
|
bool ChangePids(unsigned short vpid, unsigned short *apids, int numapids);
|
||||||
|
|
||||||
void RecordThread();
|
void RecordThread();
|
||||||
|
void WriterThread();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user