[mythtv] [patch] VERBOSE flushing

Paul Andreassen paulx at andreassen.com.au
Fri Mar 25 10:56:58 UTC 2005


On Wed, 2005-03-23 at 16:56, Isaac Richards wrote: 
> On Monday 28 February 2005 10:02 am, Paul Andreassen wrote:
> > Occasionally I have problems with reception on some channels and my log
> > file gets full of:
> > "DVB#0 WARNING - Uncorrectable error in packet, dropped." and
> > "DVB#0 WARNING - Transport Stream Continuity Error. PID = 561" shorten
> > The problem is my hard drive goes nuts writing all this to disk.
> >
> > Is it a feature (or bug) that every VERBOSE has a "std::endl" which does
> > a flush?
> > http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.7
> >
> > Attached is a patch to change it to a "\n".
> 
> Applied..
> 
> Isaac

Hi,

I tried this for a while on my system but I seemed to lose a lot of log
messages.  Please tell me if this is also true for you.

What I did next was to only use "cout" with "\n" only for the two
messages mentioned above and put back flushing for all other messages. 
This works extremely well.  

Matt Lovett mentioned in a post on the 23 March that instead of logging
these two errors; we just keep a count of them.  Not sure of a nice way 
to do this but it maybe the best way.  If I pull out my antenna the
backend log file grows very quickly to many megabytes.

Attached is a patch which reverts to the old behaviour and adds no 
flushing for the two messages above.

I would have fixed this earlier but I thought it had been skipped.
Paul

http://gcc.gnu.org/onlinedocs/gcc-3.4.3/cpp/Variadic-Macros.html#Variadic-Macros

-------------- next part --------------
--- mythtv/libs/libmyth/mythcontext.h.old	2005-03-25 15:43:18.000000000 +1000
+++ mythtv/libs/libmyth/mythcontext.h	2005-03-25 15:46:15.000000000 +1000
@@ -94,6 +94,18 @@
         QDateTime dtmp = QDateTime::currentDateTime(); \
         QString dtime = dtmp.toString("yyyy-MM-dd hh:mm:ss.zzz"); \
         MythContext::verbose_mutex.lock(); \
+        cout << dtime << " " << args << endl; \
+        MythContext::verbose_mutex.unlock(); \
+    } \
+} while (0)
+
+#define VERBOSE_NOFLUSH(mask,args...) \
+do { \
+    if ((print_verbose_messages & mask) != 0) \
+    { \
+        QDateTime dtmp = QDateTime::currentDateTime(); \
+        QString dtime = dtmp.toString("yyyy-MM-dd hh:mm:ss.zzz"); \
+        MythContext::verbose_mutex.lock(); \
         cout << dtime << " " << args << "\n"; \
         MythContext::verbose_mutex.unlock(); \
     } \
-------------- next part --------------
--- mythtv/libs/libmythtv/dvbtypes.h.old	2005-03-25 15:53:50.000000000 +1000
+++ mythtv/libs/libmythtv/dvbtypes.h	2005-03-25 16:24:57.000000000 +1000
@@ -96,6 +96,9 @@
 #define WARNING(args...) \
     VERBOSE(VB_GENERAL, QString("DVB#%1 WARNING - ").arg(cardnum) << args);
 
+#define WARNING_NOFLUSH(args...) \
+    VERBOSE_NOFLUSH(VB_GENERAL, QString("DVB#%1 WARNING - ").arg(cardnum) << args);
+
 #define GENERAL(args...) \
     VERBOSE(VB_GENERAL, QString("DVB#%1 ").arg(cardnum) << args);
 
-------------- next part --------------
--- mythtv/libs/libmythtv/dvbrecorder.cpp.old	2005-03-25 16:26:04.533697984 +1000
+++ mythtv/libs/libmythtv/dvbrecorder.cpp	2005-03-25 16:28:04.669434576 +1000
@@ -664,7 +664,7 @@
 
             if (pktbuf[1] & 0x80)
             {
-                WARNING("Uncorrectable error in packet, dropped.");
+                WARNING_NOFLUSH("Uncorrectable error in packet, dropped.");
                 ++_bad_packet_count;
                 continue;
             }
@@ -697,7 +697,7 @@
 
                 if (_continuity_count[pid] != cc)
                 {
-                    WARNING("Transport Stream Continuity Error. PID = " << pid );
+                    WARNING_NOFLUSH("Transport Stream Continuity Error. PID = " << pid );
                     RECORD(QString("PID %1 _continuity_count %2 cc %3")
                            .arg(pid).arg(_continuity_count[pid]).arg(cc));
                     _continuity_count[pid] = cc;


More information about the mythtv-dev mailing list