Go to the documentation of this file.
7 #include <sys/select.h>
27 #include <dveo/master.h>
29 #define LOC QString("ASISH[%1](%2): ").arg(m_inputId).arg(m_device)
40 const QString& devkey = devname;
42 QMap<QString,ASIStreamHandler*>::iterator it =
s_handlers.find(devkey);
51 LOG(VB_RECORD, LOG_INFO,
52 QString(
"ASISH[%1]: Creating new stream handler %2 for %3")
53 .arg(QString::number(inputid), devkey, devname));
59 LOG(VB_RECORD, LOG_INFO,
60 QString(
"ASISH[%1]: Using existing stream handler %2 for %3")
61 .arg(QString::number(inputid), devkey, devname) +
62 QString(
" (%1 in use)").arg(rcount));
78 QMap<QString,ASIStreamHandler*>::iterator it =
s_handlers.find(devname);
89 LOG(VB_RECORD, LOG_INFO, QString(
"ASISH[%1]: Closing handler for %2")
90 .arg(inputid).arg(devname));
97 LOG(VB_GENERAL, LOG_ERR,
98 QString(
"ASISH[%1] Error: Couldn't find handler for %2")
99 .arg(inputid).arg(devname));
137 LOG(VB_RECORD, LOG_INFO,
LOC +
"run(): begin");
141 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Failed to open device %1 : %2")
152 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to allocate DRB buffer");
162 auto *buffer =
new unsigned char[buffer_size];
165 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to allocate buffer");
173 memset(buffer, 0, buffer_size);
192 &(buffer[remainder]), buffer_size - remainder);
198 if (drb->IsErrored())
200 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Device error detected");
206 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Device EOF detected");
232 remainder = sit.key()->ProcessData(buffer, len);
238 if (remainder > 0 && (len > remainder))
239 memmove(buffer, &(buffer[len - remainder]), remainder);
241 LOG(VB_RECORD, LOG_INFO,
LOC +
"run(): " +
"shutdown");
250 if (drb->IsRunning())
257 LOG(VB_RECORD, LOG_INFO,
LOC +
"run(): " +
"end");
292 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to set RX Mode: " +
error);
297 m_fd = open(
m_device.toLocal8Bit().constData(), O_RDONLY, 0);
300 LOG(VB_GENERAL, LOG_ERR,
LOC +
301 QString(
"Failed to open '%1'").arg(
m_device) +
ENO);
306 unsigned int cap = 0;
307 if (ioctl(
m_fd, ASI_IOC_RXGETCAP, &cap) < 0)
309 LOG(VB_GENERAL, LOG_ERR,
LOC +
310 QString(
"Failed to query capabilities '%1'").arg(
m_device) +
ENO);
350 if(ioctl(fd, ASI_IOC_RXGETEVENTS, &val) < 0)
352 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Failed to open device %1: ")
357 if(val & ASI_EVENT_RX_BUFFER)
359 LOG(VB_RECORD, LOG_ERR,
LOC +
360 QString(
"Driver receive buffer queue overrun detected %1")
363 if(val & ASI_EVENT_RX_FIFO)
365 LOG(VB_RECORD, LOG_ERR,
LOC +
366 QString(
"Driver receive FIFO overrun detected %1")
369 if(val & ASI_EVENT_RX_CARRIER)
371 LOG(VB_RECORD, LOG_NOTICE,
LOC +
372 QString(
"Carrier Status change detected %1")
375 if(val & ASI_EVENT_RX_LOS)
377 LOG(VB_RECORD, LOG_ERR,
LOC +
378 QString(
"Loss of Packet Sync detected %1")
381 if(val & ASI_EVENT_RX_AOS)
383 LOG(VB_RECORD, LOG_NOTICE,
LOC +
384 QString(
"Acquisition of Sync detected %1")
387 if(val & ASI_EVENT_RX_DATA)
389 LOG(VB_RECORD, LOG_NOTICE,
LOC +
390 QString(
"Receive data status change detected %1")
#define ENO
This can be appended to the LOG args with "+".
bool RemoveAllPIDFilters(void)
void SetRunning(bool running, bool using_buffering, bool using_section_reader)
static QMap< QString, ASIStreamHandler * > s_handlers
void WriteMPTS(const unsigned char *buffer, uint len)
Write out a copy of the raw MPTS.
static int GetASIDeviceNumber(const QString &device, QString *error=nullptr)
void setObjectName(const QString &name)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
Buffers reads from device files.
static QMap< QString, uint > s_handlersRefCnt
static uint GetASINumBuffers(uint device_num, QString *error=nullptr)
static uint GetASIBufferSize(uint device_num, QString *error=nullptr)
QRecursiveMutex m_listenerLock
@ kASIRXSyncOn204ConvertTo188
static ASIStreamHandler * Get(const QString &devname, int inputid)
static constexpr unsigned int kDVBEmissionSize
virtual void SetRunningDesired(bool desired)
At minimum this sets _running_desired, this may also send signals to anything that might be blocking ...
ASIClockSource m_clockSource
bool UpdateFiltersFromStreamData(void)
static void Return(ASIStreamHandler *&ref, int inputid)
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
void SetClockSource(ASIClockSource cs)
static QMutex s_handlersLock
void SetRunningDesired(bool desired) override
At minimum this sets _running_desired, this may also send signals to anything that might be blocking ...
volatile bool m_runningDesired
void PriorityEvent(int fd) override
ASIStreamHandler(const QString &device, int inputid)
StreamDataList m_streamDataList
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
@ kASIRXSyncOnActualConvertTo188
void SetRXMode(ASIRXMode m)
static bool SetASIMode(uint device_num, uint mode, QString *error=nullptr)
static constexpr unsigned int kSize