Go to the documentation of this file.
7 #include <sys/select.h>
25 #include <dveo/master.h>
27 #define LOC QString("ASISH[%1](%2): ").arg(m_inputId).arg(m_device)
38 const QString& devkey = devname;
40 QMap<QString,ASIStreamHandler*>::iterator it =
s_handlers.find(devkey);
49 LOG(VB_RECORD, LOG_INFO,
50 QString(
"ASISH[%1]: Creating new stream handler %2 for %3")
51 .arg(QString::number(inputid), devkey, devname));
57 LOG(VB_RECORD, LOG_INFO,
58 QString(
"ASISH[%1]: Using existing stream handler %2 for %3")
59 .arg(QString::number(inputid), devkey, devname) +
60 QString(
" (%1 in use)").arg(rcount));
76 QMap<QString,ASIStreamHandler*>::iterator it =
s_handlers.find(devname);
87 LOG(VB_RECORD, LOG_INFO, QString(
"ASISH[%1]: Closing handler for %2")
88 .arg(inputid).arg(devname));
95 LOG(VB_GENERAL, LOG_ERR,
96 QString(
"ASISH[%1] Error: Couldn't find handler for %2")
97 .arg(inputid).arg(devname));
135 LOG(VB_RECORD, LOG_INFO,
LOC +
"run(): begin");
139 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Failed to open device %1 : %2")
150 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to allocate DRB buffer");
160 auto *buffer =
new unsigned char[buffer_size];
163 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to allocate buffer");
171 memset(buffer, 0, buffer_size);
190 &(buffer[remainder]), buffer_size - remainder);
196 if (drb->IsErrored())
198 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Device error detected");
204 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Device EOF detected");
230 remainder = sit.key()->ProcessData(buffer, len);
236 if (remainder > 0 && (len > remainder))
237 memmove(buffer, &(buffer[len - remainder]), remainder);
239 LOG(VB_RECORD, LOG_INFO,
LOC +
"run(): " +
"shutdown");
248 if (drb->IsRunning())
255 LOG(VB_RECORD, LOG_INFO,
LOC +
"run(): " +
"end");
290 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to set RX Mode: " +
error);
295 m_fd = open(
m_device.toLocal8Bit().constData(), O_RDONLY, 0);
298 LOG(VB_GENERAL, LOG_ERR,
LOC +
299 QString(
"Failed to open '%1'").arg(
m_device) +
ENO);
304 unsigned int cap = 0;
305 if (ioctl(
m_fd, ASI_IOC_RXGETCAP, &cap) < 0)
307 LOG(VB_GENERAL, LOG_ERR,
LOC +
308 QString(
"Failed to query capabilities '%1'").arg(
m_device) +
ENO);
348 if(ioctl(fd, ASI_IOC_RXGETEVENTS, &val) < 0)
350 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Failed to open device %1: ")
355 if(val & ASI_EVENT_RX_BUFFER)
357 LOG(VB_RECORD, LOG_ERR,
LOC +
358 QString(
"Driver receive buffer queue overrun detected %1")
361 if(val & ASI_EVENT_RX_FIFO)
363 LOG(VB_RECORD, LOG_ERR,
LOC +
364 QString(
"Driver receive FIFO overrun detected %1")
367 if(val & ASI_EVENT_RX_CARRIER)
369 LOG(VB_RECORD, LOG_NOTICE,
LOC +
370 QString(
"Carrier Status change detected %1")
373 if(val & ASI_EVENT_RX_LOS)
375 LOG(VB_RECORD, LOG_ERR,
LOC +
376 QString(
"Loss of Packet Sync detected %1")
379 if(val & ASI_EVENT_RX_AOS)
381 LOG(VB_RECORD, LOG_NOTICE,
LOC +
382 QString(
"Acquisition of Sync detected %1")
385 if(val & ASI_EVENT_RX_DATA)
387 LOG(VB_RECORD, LOG_NOTICE,
LOC +
388 QString(
"Receive data status change detected %1")
#define ENO
This can be appended to the LOG args with "+".
static void error(const char *str,...)
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