Fix TS buffer thread high CPU usage

Message ID
State New

Commit Message

glenvt18 March 10, 2016, 1:54 a.m. UTC
  Hi folks,

I've found that with some DVB tuner drivers poll() returns when there
are only small (1-3) number of TS packets available to read(). This
results in high CPU usage of the TS buffer thread which is busy
reading small chunks of data in cTSBuffer::Action(). 2 out of 3 tuners
I tested were affected with this issue. Even with a "good" tuner TS
buffer thread CPU usage is up to 10% per HD stream on ARM Cortex-A7.
With the proposed patch it is below 1-2% on all ARM and x86_64
platforms I've tested. The delay value of 10 ms can be considered

#define DVR_BUFFER_SIZE (10*188*1024)

It will take a tuner to receive (10*188*1024)*8*(1000/10) / 1000000 =
1540 Mbit/s to overflow the device buffer within 10 ms interval. A
smaller delay is not enough for ARM. cDvbDevice has a ring buffer of
5MB which is larger.

This patch was made against VDR 2.3.1, but it can be applied to VDR
2.2.0 as well.

Please review.


Index: b/device.c
--- a/device.c    2015-09-18 01:04:12.000000000 +0300
+++ b/device.c    2016-03-10 03:38:50.078400715 +0300
@@ -1768,6 +1768,8 @@ 
+              else
+                 cCondWait::SleepMs(10);