Re: [vdr] Q: no sound with dvd-plugin and softdevice

2007-05-14 Thread Harald Milz
Hi,

does nobody have an idea concerning this one? The question appears to be
how do I use softdevice-audio with dvd-plugin. 



Harald Milz [EMAIL PROTECTED] wrote:
 Hi,

 I would like to use the dvd plugin (CVS as of today) together with
 softdevice-0.4.0. Plays DVDs fine but no sound. In the plugin's source code
 there's in player-dvd.c:

 BitStreamOutActive  = false;
 HasBitStreamOut = (cPluginManager::GetPlugin(bitstreamout) != NULL);

 SoftDeviceOutActive = false;
 HasSoftDeviceOut= (cPluginManager::GetPlugin(xine) != NULL);

 Shouldn't the plugin also check for softdevice? player-dvd.h says

 static bool SoftDeviceOutActive; // currently used to switch for xine
 static bool HasSoftDeviceOut;// currently used to switch for xine

 Hmmm - 

 However - this patch 


 --- player-dvd.c.ORIG   2006-04-09 20:35:53.0 +0200
 +++ player-dvd.c2007-05-11 18:50:22.871312099 +0200
 @@ -577,7 +577,8 @@
  HasBitStreamOut = (cPluginManager::GetPlugin(bitstreamout) != 
 NULL);

  SoftDeviceOutActive = false;
 -HasSoftDeviceOut   = (cPluginManager::GetPlugin(xine) != NULL);
 +HasSoftDeviceOut   = (cPluginManager::GetPlugin(xine) != NULL) ||
 + (cPluginManager::GetPlugin(softdevice) != NULL);

  cSetupLine *slBitStreamOutActive = NULL;
  if(HasBitStreamOut) {


 leads to 

 May 11 18:52:00 linvdr vdr: [3894] dvd-plugin: SoftDeviceOutActive=1, 
 HasSoftDeviceOut=1

 but still no sound, but a whole lot of 

 May 11 18:52:20 linvdr vdr: [3894] ERROR: dvd-plugin iframeassembler full 
 524772
 May 11 18:52:20 linvdr vdr: [3982] [softdevice-audio] samplerate: 22050Hz, 
 channels: #2
 May 11 18:52:20 linvdr vdr: [3982] [softdevice-audio] Device 'spdif-48', 
 Samplerate 22050 Channels 2
 May 11 18:52:20 linvdr vdr: [3982] [softdevice-audio] Period size 1152 Buffer 
 size 6915
 May 11 18:52:20 linvdr vdr: [3982] [softdevice-audio] Hardware initialized
 May 11 18:52:20 linvdr vdr: [3982] [softdevice-audio] samplerate: 48000Hz, 
 channels: #2
 May 11 18:52:20 linvdr vdr: [3982] [softdevice-audio] Device 'spdif-48', 
 Samplerate 48000 Channels 2
 May 11 18:52:20 linvdr vdr: [3982] [softdevice-audio] Period size 1152 Buffer 
 size 9216
 May 11 18:52:20 linvdr vdr: [3982] [softdevice-audio] Hardware initialized


 spdif-48 is a plug that resamples everything to 48 kHz:

 pcm.spdif-48 {
 type plug
 slave.pcm spdif
 slave.rate 48000
 }

 Seems softdevice-audio doesn't get any useful data from dvd:

 [mp2 @ 0xb79e7148]header missing skiping one byte

 and

 libdvdnav: Using dvdnav version 0.1.10 from http://dvd.sf.net
 libdvdnav: DVD Title: VDRCONVERT_11-05-2007
 libdvdnav: DVD Serial Number: 464496BE
 libdvdnav: DVD Title (Alternative):
 libdvdnav: Unable to find map file '//.dvdnav/VDRCONVERT_11-05-2007.map'
 libdvdnav: DVD disk reports itself with Region mask 0x. Regions: 1
 2 3 4 5 6 7 8
 libdvdnav: Language 'de' not found, using 'en' instead
 libdvdnav: Menu Languages available: en
 libdvdnav: Language 'de' not found, using 'en' instead
 libdvdnav: Menu Languages available: en
 libdvdnav: Language 'de' not found, using 'en' instead
 libdvdnav: Menu Languages available: en
 libdvdnav: Language 'de' not found, using 'en' instead
 libdvdnav: Menu Languages available: en
 libdvdnav: Language 'de' not found, using 'en' instead
 libdvdnav: Menu Languages available: en
 libdvdnav: Language 'de' not found, using 'en' instead
 libdvdnav: Menu Languages available: en
 [mpegdecoder] Error! Codec 86020 not supported by libavcodec
 [mpegdecoder] Error! Codec 86020 not supported by libavcodec


 The DVD was created using vdrconvert-CVS and plays fine on my standalone
 DVD player, so no region code and the generic name. Is that vdrconvert's
 error? 



 ??? 





 -- 
 Blood is thicker than water, and much tastier.

 ___
 vdr mailing list
 vdr@linuxtv.org
 http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


-- 
Software, n.:
Formal evening attire for female computer analysts.

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] Q: no sound with dvd-plugin and softdevice

2007-05-14 Thread Torgeir Veimo


On 14 May 2007, at 11:34, Harald Milz wrote:

does nobody have an idea concerning this one? The question appears  
to be

how do I use softdevice-audio with dvd-plugin.



Harald Milz [EMAIL PROTECTED] wrote:

Hi,



Seems softdevice-audio doesn't get any useful data from dvd:



[mpegdecoder] Error! Codec 86020 not supported by libavcodec
[mpegdecoder] Error! Codec 86020 not supported by libavcodec


Coded 86020 is Dolby AC3. Do you have A52 support compiled into your  
ffmpeg?


--
Torgeir Veimo
[EMAIL PROTECTED]




___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


[vdr] Re: Problem with multiple audio channels and DVB subtitles in recordings (YLE Teema)

2007-05-14 Thread Arthur Konovalov

Ville Aakko wrote:

Wathing the program in real-time has no problems, there I can see the
subtitles without problems. Only the recordings have problems.


I have similar issue with YLE1 and YLE2. Sometimes subtitles saved, sometimes 
not. ProjectX shows same: no subtitles- no DVB stream. And vice versa.


At moment using vdr-1.4.6-1, subtitles-0.5, and ttxtsubs-0.0.5-LHE plugins 
patched with vdr-1.4.4-subtitles-0.4.0-and-ttxtsubs-0.0.5.diff.


Br,
AK


___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] Re: Problem with multiple audio channels and DVB subtitles in recordings (YLE Teema)

2007-05-14 Thread Pekka Virtanen

On 5/14/07, Arthur Konovalov [EMAIL PROTECTED] wrote:

Ville Aakko wrote:
 Wathing the program in real-time has no problems, there I can see the
 subtitles without problems. Only the recordings have problems.

I have similar issue with YLE1 and YLE2. Sometimes subtitles saved, sometimes
not. ProjectX shows same: no subtitles- no DVB stream. And vice versa.


The problem is most likely caused by the fact that the PIDs for
subtitles are different than at the time the recording started.
Current implementation doesn't detect if PIDs change during recording.
As a workaround you can set your time e.g. 1 minute after the program
has begun.

--
pekka

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [ANNOUNCE] VDR sync early patch

2007-05-14 Thread Jaroslaw Swierczynski

Strangely enough it doesn't crash now.

--
Jaroslaw Swierczynski [EMAIL PROTECTED]
www.archlinux.org | www.juvepoland.com

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] Re: Problem with multiple audio channels and DVB subtitles in recordings (YLE Teema)

2007-05-14 Thread Rolf Ahrenberg

On Mon, 14 May 2007, Petri Helin wrote:

Since the subtitle pids are always the same (at least I think they are on 
Finnish channels: Finnish subtitles can be found from 1027 for TV1, 2027 for 
TV2, 3027 for FST, 4027 for Teema and 5027 for Extra), would it be hard to 
add a possibility to fix the pids per channel? Maybe through setup.


I've done and using (and sent to Klaus) two patches (spids  remux) that 
detects automatically changes in subtitle pids as it's done nowadays 
with audio pids and records all available subtitle tracks. I don't see 
any benefits using fixed pids...


Also all OSD opening problems should be fixed hopefully in the latest 
versions of my subtitles patches. Sorry, cannot remember the exact 
version, but atleast vdr-1.5.2-subtitles-0.5.0.diff should contain the 
fix.


--
rofa

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] Re: Problem with multiple audio channels and DVB subtitles in recordings (YLE Teema)

2007-05-14 Thread Petri Helin

Rolf Ahrenberg wrote:

On Mon, 14 May 2007, Petri Helin wrote:

Since the subtitle pids are always the same (at least I think they are 
on Finnish channels: Finnish subtitles can be found from 1027 for TV1, 
2027 for TV2, 3027 for FST, 4027 for Teema and 5027 for Extra), would 
it be hard to add a possibility to fix the pids per channel? Maybe 
through setup.


I've done and using (and sent to Klaus) two patches (spids  remux) that 
detects automatically changes in subtitle pids as it's done nowadays 
with audio pids and records all available subtitle tracks. I don't see 
any benefits using fixed pids...




Of course that is the preferred way to go. I was just thinking a quick 
fix type of solution...


Also all OSD opening problems should be fixed hopefully in the latest 
versions of my subtitles patches. Sorry, cannot remember the exact 
version, but atleast vdr-1.5.2-subtitles-0.5.0.diff should contain the fix.




I'll have to check which patches I have applied and come back to this if 
 the latest ones still have the OSD opening problem.


-Petri

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] Best settings..

2007-05-14 Thread Petri Helin

Anssi Hannula wrote:

Lauri Tischler wrote:

Anssi Hannula wrote:

JJussi wrote:

Hi!

I have very simple and still hard question..

At vdr pluging setup - xineliboutput - Video.
Post processing (ffmpeg) and Deinterlaceing.
What ARE best values (to select) when you have HD LCD (via DVI) as 
TV and enough CPU power (Intel Core 2 Duo) to use.


I think that I'm not only one who thinks that there is too many 
choices.. ;-)


I use vdr-sxfe with --video=xv --aspect=16:9 --post 
tvtime:method=Greedy2Frame,cheap_mode=0,pulldown=0,use_progressive_frame_flag=1. 





Is there a document somewhere which explains all switches in above 
command ?


I think they are shown somewhere in xine gui, but quoting from xine-lib
source:


PARAM_ITEM( POST_PARAM_TYPE_INT, method, enum_methods, 0, 0, 0,
deinterlace method )
PARAM_ITEM( POST_PARAM_TYPE_BOOL, enabled, NULL, 0, 1, 0,
enable/disable )
PARAM_ITEM( POST_PARAM_TYPE_INT, pulldown, enum_pulldown, 0, 0, 0,
pulldown algorithm )
PARAM_ITEM( POST_PARAM_TYPE_INT, framerate_mode, enum_framerate, 0, 0, 0,
framerate output mode )
PARAM_ITEM( POST_PARAM_TYPE_BOOL, judder_correction, NULL, 0, 1, 0,
make frames evenly spaced for film mode (24 fps) )
PARAM_ITEM( POST_PARAM_TYPE_BOOL, use_progressive_frame_flag, NULL, 0, 
1, 0,

disable deinterlacing when progressive_frame flag is set )
PARAM_ITEM( POST_PARAM_TYPE_BOOL, chroma_filter, NULL, 0, 1, 0,
apply chroma filter after deinterlacing )
PARAM_ITEM( POST_PARAM_TYPE_BOOL, cheap_mode, NULL, 0, 1, 0,
skip image format conversion - cheaper but not 100% 
correct )




And in a bit more detail, also from the source:

Advanced tvtime/deinterlacer plugin with pulldown detection
This plugin aims to provide deinterlacing mechanisms comparable
to high quality progressive DVD players and so called
line-doublers, for use with computer monitors, projectors and
other progressive display devices.

Parameters:

  Method: Select deinterlacing method/algorithm to use, see below for
explanation of each method.

  Enabled: Enable/disable the plugin.

  Pulldown: Choose the 2-3 pulldown detection algorithm. 24 FPS films
that have being converted to NTSC can be detected and intelligently
reconstructed to their original (non-interlaced) frames.

  Framerate_mode: Selecting 'full' will deinterlace every field
to an unique frame for television quality and beyond. This feature will
effetively double the frame rate, improving smoothness. Note, however,
that full 59.94 FPS is not possible with plain 2.4 Linux kernel (that
use a timer interrupt frequency of 100Hz). Newer RedHat and 2.6 kernels
use higher HZ settings (512 and 1000, respectively) and should work fine.

  Judder_correction: Once 2-3 pulldown is enabled and a film material
is detected, it is possible to reduce the frame rate to original rate
used (24 FPS). This will make the frames evenly spaced in time,
matching the speed they were shot and eliminating the judder effect.

  Use_progressive_frame_flag: Well mastered MPEG2 streams uses a flag
to indicate progressive material. This setting control whether we trust
this flag or not (some rare and buggy mpeg2 streams set it wrong).

  Chroma_filter: DVD/MPEG2 use an interlaced image format that has
a very poor vertical chroma resolution. Upsampling the chroma for 
purposes of deinterlacing may cause some artifacts to occur (eg. color 
stripes). Use this option to blur the chroma vertically after 
deinterlacing to remove the artifacts. Warning: cpu intensive.


  Cheap_mode: This will skip the expensive YV12-YUY2 image conversion,
tricking tvtime/dscaler routines like if they were still handling YUY2
images. Of course, this is not correct, not all pixels will be evaluated
by the algorithms to decide the regions to deinterlace and chroma will 
be processed separately. Nevertheless, it allows people with not so fast

systems to try deinterlace algorithms, in a tradeoff between quality
and cpu usage.


One conclusion is that Judder_correction and Pulldown are useless for 
PAL material. Use_progressive_frame_flag is also quite futile with DVB 
material, but some DVDs might benefit from it.


-Petri

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] Re: Problem with multiple audio channels and DVB subtitles in recordings (YLE Teema)

2007-05-14 Thread Petri Helin

Rolf Ahrenberg wrote:
I've done and using (and sent to Klaus) two patches (spids  remux) that 
detects automatically changes in subtitle pids as it's done nowadays 
with audio pids and records all available subtitle tracks. I don't see 
any benefits using fixed pids...




So, I should just remove the part regarding remux.c from 
vdr-1.5.2-subtitles-0.5.0-and-ttxtsubs-0.0.5.diff patch to test these 
patches with 1.5.2, or do you have a matching subtitlesttxtsubs patch 
to be used with the remux patch already?


-Petri

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [PATCH] Auto sized ringbuffers v3

2007-05-14 Thread Jaroslaw Swierczynski

It seems your patch is against VDR 1.5.x. Could you please backport it
to VDR 1.4.x?

--
Jaroslaw Swierczynski [EMAIL PROTECTED]
www.archlinux.org | www.juvepoland.com

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


[vdr] BUG: race condition triggered in cReceiver due to incorrect use by femon

2007-05-14 Thread Reinhard Nissl
Hi,

I've just got a pure virtual function call in cDevice::Action() for
receiver[i]-Receive(b, TS_SIZE);

It has happened while closing femon's OSD:

(gdb) bt
#0  0xe410 in __kernel_vsyscall ()
#1  0xb7f2fc4e in __lll_mutex_lock_wait () from /lib/libpthread.so.0
#2  0xb7f2ba3c in _L_mutex_lock_88 () from /lib/libpthread.so.0
#3  0xb7f2b42d in pthread_mutex_lock () from /lib/libpthread.so.0
#4  0x08124281 in cMutex::Lock (this=0xb762c48) at thread.c:190
#5  0x080a7cdc in cThread::Lock (this=0xb762c38) at thread.h:91
#6  0x080a5548 in cDevice::Detach (this=0xb762c38, Receiver=0xb099ab0)
at device.c:1298
#7  0x080effb9 in cReceiver::Detach (this=0xb099ab0) at receiver.c:60
#8  0x080f0090 in ~cReceiver (this=0xb099ab0) at receiver.c:43
#9  0xb799ac29 in cFemonReceiver::~cFemonReceiver () from
/soft/vdr-1.4.6/lib/vdr/libvdr-femon.so.1.4.5
#10 0xb7998b05 in cFemonOsd::~cFemonOsd () from
/soft/vdr-1.4.6/lib/vdr/libvdr-femon.so.1.4.5
#11 0x08131da7 in main (argc=20, argv=0xbf90e914) at vdr.c:885
#12 0xb7ce6f9c in __libc_start_main () from /lib/libc.so.6
#13 0x0809 in _start ()
(gdb)

cReceiver::~cReceiver() calls Detach(), but at that time, it is simply
too late as the virtual method table entry for Receive() has already
been restored to 0.

I suggest to call Detach() from cFemonReceiver::~cFemonReceiver() to fix
this issue.

Furthermore I suggest to add some debug output to ~cReceiver() in the
case where the receiver is still attached. I've been using femon for
quite some time now and it was the first time, that VDR dumped a core
regarding a pure virtual function call. Such a debug output would have
triggered way more early.

Bye.
-- 
Dipl.-Inform. (FH) Reinhard Nissl
mailto:[EMAIL PROTECTED]
--- ../vdr-1.4.6-orig/receiver.c	2006-03-26 16:07:21.0 +0200
+++ receiver.c	2007-05-14 23:17:26.0 +0200
@@ -38,7 +39,11 @@ cReceiver::cReceiver(int Ca, int Priorit
 
 cReceiver::~cReceiver()
 {
-  Detach();
+  if (device) {
+ esyslog(ERROR: cReceiver has not been detached yet! This is a design fault and VDR will segfault now!);
+ fprintf(stderr, ERROR: cReceiver has not been detached yet! This is a design fault and VDR will segfault now!\n);
+ *(char *)0 = 0;
+ }
 }
 
 bool cReceiver::WantsPid(int Pid)
___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] Re: Problem with multiple audio channels and DVB subtitles in recordings (YLE Teema)

2007-05-14 Thread Petri Helin

Rolf Ahrenberg wrote:

On Mon, 14 May 2007, Petri Helin wrote:

So, I should just remove the part regarding remux.c from 
vdr-1.5.2-subtitles-0.5.0-and-ttxtsubs-0.0.5.diff patch to test these 
patches with 1.5.2, or do you have a matching subtitlesttxtsubs patch 
to be used with the remux patch already?


Yes, you shouldn't need the remux.c and menu.c hunks anymore. The spids 


Hmm. It looks like menu.c needs to be patched?

menu.c: In constructor ‘cRecordControl::cRecordControl(cDevice*, 
cTimer*, bool)’:
menu.c:3846: error: no matching function for call to 
‘cRecorder::cRecorder(char*, tChannelID, int, int, const int*, const 
int*, const int*)’
recorder.h:32: note: candidates are: cRecorder::cRecorder(const char*, 
tChannelID, int, int, const int*, const int*, const int*, 
cTtxtSubsRecorderBase*)

recorder.h:22: note: cRecorder::cRecorder(const cRecorder)
make: *** [menu.o] Error 1


-Petri

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] [PATCH] Auto sized ringbuffers v3

2007-05-14 Thread VDR User

In case anyone is having trouble, here's an attached patch of v3 for vdr-1.5.2.
diff -ruN vdr-1.5.2-orig/dvbdevice.c vdr-1.5.2/dvbdevice.c
--- vdr-1.5.2-orig/dvbdevice.c	2007-05-14 14:58:29.0 -0700
+++ vdr-1.5.2/dvbdevice.c	2007-05-14 15:22:50.0 -0700
@@ -1172,7 +1172,7 @@
   CloseDvr();
   fd_dvr = DvbOpen(DEV_DVB_DVR, CardIndex(), O_RDONLY | O_NONBLOCK, true);
   if (fd_dvr = 0)
- tsBuffer = new cTSBuffer(fd_dvr, MEGABYTE(2), CardIndex() + 1);
+ tsBuffer = new cTSBuffer(fd_dvr, MEGABYTE(8), CardIndex() + 1);
   return fd_dvr = 0;
 }
 
diff -ruN vdr-1.5.2-orig/recorder.c vdr-1.5.2/recorder.c
--- vdr-1.5.2-orig/recorder.c	2007-05-14 14:58:29.0 -0700
+++ vdr-1.5.2/recorder.c	2007-05-14 15:27:12.0 -0700
@@ -176,8 +176,22 @@
int Count = remux-Put(b, r);
if (Count)
   ringBuffer-Del(Count);
-   else
-  cCondWait::SleepMs(100); // avoid busy loop when resultBuffer is full in cRemux::Put()
-   }
+	   else { // avoid busy loop when resultBuffer is full in cRemux::Put()
+	  int ms;
+	  for (ms=5; Running()  ms100; ms+=ms) {
+		 cCondWait::SleepMs(ms);
+		 if (!Running())
+		return;
+		 Count = remux-Put(b, r);
+		 if (Count) {
+		ringBuffer-Del(Count);
+		dsyslog(cRecorder::Action() ring buffer consumer slept %d ms, ms);
+		break;
+		}
+		 }
+	  if (ms=100)
+		 dsyslog(cRecorder::Action() ring buffer consumer slept 100 ms);
+	  }
+	   }
 }
 }
diff -ruN vdr-1.5.2-orig/remux.c vdr-1.5.2/remux.c
--- vdr-1.5.2-orig/remux.c	2007-05-14 14:58:29.0 -0700
+++ vdr-1.5.2/remux.c	2007-05-14 15:27:45.0 -0700
@@ -1851,7 +1851,7 @@
 
 // --- cRemux 
 
-#define RESULTBUFFERSIZE KILOBYTE(256)
+#define RESULTBUFFERSIZE MEGABYTE(2)
 
 cRemux::cRemux(int VPid, const int *APids, const int *DPids, const int *SPids, bool ExitOnFailure)
 {
diff -ruN vdr-1.5.2-orig/ringbuffer.c vdr-1.5.2/ringbuffer.c
--- vdr-1.5.2-orig/ringbuffer.c	2007-05-14 14:58:29.0 -0700
+++ vdr-1.5.2/ringbuffer.c	2007-05-14 15:33:18.0 -0700
@@ -151,13 +151,31 @@
   }
 #endif
 
+// cRingBufferLinear are dynamically sized, or at least we can pretend they are ;)
+// We treat 'Size' as the maximum size, but start with a small buffer, which can
+// grow later as it fills up. Memory is always allocated for the full buffer, but
+// the unused RAM portion remains untouched until (if at all) it is actually needed.
+// Note that we can not start with a larger than requested buffer because there are
+// ring buffer users that cause crashes then (eg softdevice mpegdecoder absolutely
+// needs 32/64k).
+
+// Startup size. 64k still causes overflows before buffer starts to grow, 128k doesn't.
+// The buffers grow to 200..500k anyway, so maybe increasing this a bit more would
+// make sense, but let's first see if it's really needed.
+// In fact 128k is on the low side, but let's try not going for 256k yet.
+#define DEFRBSIZE KILOBYTE(192)
+
 cRingBufferLinear::cRingBufferLinear(int Size, int Margin, bool Statistics, const char *Description)
-:cRingBuffer(Size, Statistics)
+:cRingBuffer(min(Size,DEFRBSIZE), Statistics)
 {
   description = Description ? strdup(Description) : NULL;
   tail = head = margin = Margin;
   gotten = 0;
   buffer = NULL;
+  maxsize = Size;
+  growthresh = sizemaxsize ? size/3 : maxsize+1;
+  growbuf = 0;
+  dsyslog(New ring buffer \%s\ size: %d margin: %d, description, Size, Margin );
   if (Size  1) { // 'Size - 1' must not be 0!
  if (Margin = Size / 2) {
 buffer = MALLOC(uchar, Size);
@@ -183,6 +201,7 @@
 #ifdef DEBUGRINGBUFFERS
   DelDebugRBL(this);
 #endif
+  dsyslog(Deleting ring buffer \%s\ size: %d / %d (used %g%% of requested size), description, size, maxsize, size/(double)maxsize*100.0 );
   free(buffer);
   free(description);
 }
@@ -205,8 +224,20 @@
   EnablePut();
 }
 
+// Must only be called by the producer (ie Read()/Put()), not the consumer (Get()).
+void cRingBufferLinear::GrowBuffer(void)
+{
+  size = min(size+size/2, maxsize);
+  growthresh = sizemaxsize ? size/3 : maxsize+1;
+  dsyslog(Enlarging ring buffer \%s\: %d bytes (trigger %d, thresh %d),
+  description, size, growbuf, growthresh);
+  growbuf = 0;
+}
+
 int cRingBufferLinear::Read(int FileHandle, int Max)
 {
+  if (growbuf  head=tail  sizemaxsize)
+ GrowBuffer();
   int Tail = tail;
   int diff = Tail - head;
   int free = (diff  0) ? diff - 1 : Size() - head;
@@ -219,6 +250,10 @@
  Count = safe_read(FileHandle, buffer + head, free);
  if (Count  0) {
 int Head = head + Count;
+if (Available()+Count = growthresh)
+   growbuf = 2;
+if (growbuf  head=tail  sizemaxsize)
+   GrowBuffer();
 if (Head = Size())
Head = margin;
 head = Head;
@@ -245,6 +280,10 @@
 int cRingBufferLinear::Put(const uchar *Data, int Count)
 {