On 05/09/07 20:56, Artur Skawina wrote:
>> void cRecorder::Receive(uchar *Data, int Length)
>> {
>>   if (Running()) {
>>      int p = ringBuffer->Put(Data, Length);
>>      if (p != Length && Running())
>>         ringBuffer->ReportOverflow(Length - p);
>>      }
>> }
>>
>> it simply drops any data that does not fit into the buffer, which would be 
>> fine
>> for live viewing, but isn't ideal when recording.
>>
>> Can we try harder not to loose data here? IOW can this function sleep (and 
>> retry)?
> 
> It took a while to trigger the condition again, but now it happened and 
> trying a bit
> harder payed off. Running vdr /w following patch resulted in this log (and no 
> overflow):
> 
> 20:31:35 vdr: [16328] buffer usage: 70% (tid=16327)
> 20:31:35 vdr: [16328] buffer usage: 80% (tid=16327)
> 20:31:35 vdr: [16328] buffer usage: 90% (tid=16327)
> 20:31:35 vdr: [16328] buffer usage: 100% (tid=16327)
> 20:31:35 vdr: [16327] Enlarging ring buffer "Result": 262144 bytes (trigger 3)
> 20:31:35 vdr: [16329] Enlarging ring buffer "TS": 262144 bytes (trigger 2)
> 20:31:35 vdr: [16328] Enlarging ring buffer "Recorder": 262144 bytes (trigger 
> 3)
> 20:31:35 vdr: [16328] buffer usage: 0% (tid=16327)
> 20:31:35 vdr: [16328] saved extra 153 bytes in recorder ring buffer after 80 
> ms delay
> 
> artur
> 
> diff --git a/recorder.c b/recorder.c
> index 8bb1621..3c0e002 100644
> --- a/recorder.c
> +++ b/recorder.c
> @@ -157,8 +157,20 @@ void cRecorder::Receive(uchar *Data, int Length)
>  {
>    if (Running()) {
>       int p = ringBuffer->Put(Data, Length);
> -     if (p != Length && Running())
> +     if (p != Length && Running()) {
> +        for (int ms=20; ms<1000; ms+=ms) {
> +           cCondWait::SleepMs(ms);
> +           if (!Running())
> +              return;
> +           int r = ringBuffer->Put(Data+p, Length-p);
> +           p += r;
> +           if (r)
> +              dsyslog("saved extra %d bytes in recorder ring buffer after %d 
> ms delay", r, ms);
> +           if (p == Length || !Running())
> +              return;
> +           }
>          ringBuffer->ReportOverflow(Length - p);
> +        }
>       }
>  }

>From receiver.h:

  virtual void Receive(uchar *Data, int Length) = 0;
               ///< This function is called from the cDevice we are attached 
to, and
               ///< delivers one TS packet from the set of PIDs the cReceiver 
has requested.
               ///< The data packet must be accepted immediately, and the call 
must return
                                    ****************************                
    ******
               ///< as soon as possible, without any unnecessary delay. Each TS 
packet
                    **************************************************
               ///< will be delivered only ONCE, so the cReceiver must make 
sure that
               ///< it will be able to buffer the data if necessary.


Klaus

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

Reply via email to