<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi Guys,<br>
    <br>
    I have some questions on
    <meta http-equiv="Content-Type" content="text/html;
      charset=ISO-8859-1">
    <span class="Apple-style-span" style="border-collapse: separate;
      color: rgb(0, 0, 0); font-family: Arial; font-size: 14px;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: normal; orphans: 2;
      text-align: auto; text-indent: 0px; text-transform: none;
      white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-border-horizontal-spacing: 0px;
      -webkit-border-vertical-spacing: 0px;
      -webkit-text-decorations-in-effect: none;
      -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span
        class="Apple-style-span" style="text-align: left; ">ringbuffer.cpp.
        Please realize that I am fully aware that there is a complex
        logic behind all this that I do not understand yet. This is
        where I hope somebody can help out.<br>
        <br>
        I run a single back-end (Ubuntu) with multiple frond-ends
        (ZBOXes, also Ubuntu)<br>
        <br>
        It started out by me being tortured with the never ending <br>
        <br>
=========================================================================<br>
        Decoder ringbuffer.cpp:1086 (WaitForAvail)
        RingBuf(/second_drive/recordings/3130_20120103210000.mpg):
        Waited 2.0 seconds for data #012#011#011#011t<br>
=========================================================================<br>
        <br>
        in the backend log file. I was on 0.25 then. I tried running the
        backend in a virtual machine, in a stand-alone machine, with a
        new hard drive, difference file systems (ext3, ext4). Nothing
        helped. I then saw the bug 10428, which was for 0.26. I
        backported that one but the error message did not go away. I
        only had real freezes on the front-end between shows and they
        would last around 4-5 seconds. Finally I took the leap and
        upgraded to 0.27, but the error persisted. Now it is</span></span><br>
    <br>
    <span class="Apple-style-span" style="border-collapse: separate;
      color: rgb(0, 0, 0); font-family: Arial; font-size: 14px;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: normal; orphans: 2;
      text-align: auto; text-indent: 0px; text-transform: none;
      white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-border-horizontal-spacing: 0px;
      -webkit-border-vertical-spacing: 0px;
      -webkit-text-decorations-in-effect: none;
      -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span
        class="Apple-style-span" style="text-align: left; ">=========================================================================<br>
      </span></span>
    <meta http-equiv="Content-Type" content="text/html;
      charset=ISO-8859-1">
    Feb 13 11:27:53 myth1204 mythbackend: mythbackend[5567]: I
    ProcessRequest ringbuffer.cpp:1098 (WaitForAvail) RingBuf(/Reco<br>
    rdings/7730_20140213171157.mpg): Waited 0.2 seconds for data
    #012#011#011#011to become available... 214228 &lt; 425984<br>
    <span class="Apple-style-span" style="border-collapse: separate;
      color: rgb(0, 0, 0); font-family: Arial; font-size: 14px;
      font-style: normal; font-variant: normal; font-weight: normal;
      letter-spacing: normal; line-height: normal; orphans: 2;
      text-align: auto; text-indent: 0px; text-transform: none;
      white-space: normal; widows: 2; word-spacing: 0px;
      -webkit-border-horizontal-spacing: 0px;
      -webkit-border-vertical-spacing: 0px;
      -webkit-text-decorations-in-effect: none;
      -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span
        class="Apple-style-span" style="text-align: left; ">=========================================================================</span></span><br>
    <br>
    This is when I started to look at ringbuffer.cpp, and specifically
    the function RingBuffer::WaitForAvail(int count), where the error
    comes from. I have many questions here and I hope this is the place
    to ask it.<br>
    <br>
    Prior to starting the big while loop, that seem to wait for the
    buffer to fill up, there is a timer t (MythTimer) instantiated and
    started<br>
    <br>
    MythTimer t;<br>
    &nbsp;&nbsp;&nbsp; t.start();<br>
    <br>
    This seems straight forward. Then the big while loop is started,
    which seems to be waiting for avail to be at least as big as count
    (which seems to be the amount of data we want). It test other things
    as well but they all seem external to the WaitForAvial function.<br>
    <br>
    In the while loop we call the QWaitCondition wait
    (generalWait.wait(&amp;rwlock, 250), with a timeout of max 250
    milliseconds. Once we are out of that (worst case 250 ms later) we
    go onto checking if avail now is at least count big. If not we do
    something I don't understand this and this is where I have
    questions. First out, here is the if statement<br>
    <br>
    ==================================================<br>
    <meta http-equiv="Content-Type" content="text/html;
      charset=ISO-8859-1">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (avail &lt; count)<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int elapsed = t.elapsed();<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (elapsed &gt; 500 &amp;&amp; low_buffers &amp;&amp;
    avail &gt;= fill_min)<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count = avail;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else if&nbsp; (((elapsed &gt; 250) &amp;&amp; (elapsed &lt;
    500))&nbsp; ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt;&nbsp; 500) &amp;&amp; (elapsed &lt;
    750))&nbsp; ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 1000) &amp;&amp; (elapsed &lt;
    1250)) ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 2000) &amp;&amp; (elapsed &lt;
    2250)) ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 4000) &amp;&amp; (elapsed &lt;
    4250)) ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 8000) &amp;&amp; (elapsed &lt;
    8250)) ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 9000)))<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(VB_GENERAL, LOG_INFO, LOC + "Waited " +<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QString("%1").arg((elapsed / 250) * 0.25f, 3,
    'f', 1) +<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " seconds for data \n\t\t\tto become
    available..." +<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QString(" %2 &lt; %3") .arg(avail).arg(count));<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (elapsed &gt; 16000)<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LOG(VB_GENERAL, LOG_ERR, LOC + "Waited " +<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QString("%1").arg(elapsed/1000) +<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; " seconds for data, aborting.");<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
    ==================================================<br>
    <br>
    So why do we expect elapsed to be over 500 ms here? In worst case it
    should be only 250 ms, right? At least the first time we are in the
    while loop. We would therefore automatically enter the "else if"
    statement the first time we are in the while loop, and therefore
    risk outputting the Error.<br>
    <br>
    Then looking at the "if else" statement, what is going on there?<br>
    <br>
    else if&nbsp; (((elapsed &gt; 250) &amp;&amp; (elapsed &lt; 500))&nbsp; ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt;&nbsp; 500) &amp;&amp; (elapsed &lt;
    750))&nbsp; ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 1000) &amp;&amp; (elapsed &lt;
    1250)) ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 2000) &amp;&amp; (elapsed &lt;
    2250)) ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 4000) &amp;&amp; (elapsed &lt;
    4250)) ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 8000) &amp;&amp; (elapsed &lt;
    8250)) ||<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((elapsed &gt; 9000)))<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Log ugly message<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
    <br>
    So what is the logic?<br>
    if elapsed&nbsp; below&nbsp; 500 ms =&gt; OK (can't happen the first lapse in
    the while loop)<br>
    if elapsed between 750 and 1000 =&gt; OK<br>
    if elapsed between 1250 and 2000 =&gt; OK<br>
    and so on....<br>
    <br>
    It is obvious that I am missing part of the logic here and for that
    I apologize. Perhaps if somebody can point me to where I can read
    up?<br>
    <br>
    To me it seems that one test for a max value would be enough. That
    max value would be something that would actually cause a problem for
    the client. Now it seems we are just polluting the log file with
    messages for something that seems to be perfectly okay with the
    client. I also notice that the log level is LOG_INFO so I am
    wondering why it is visible in the LOG. I run Ubuntu's package and
    it seems that thing comes with this log level enabled.<br>
    <br>
    Just for the heck of it I made some changes (and clearly I don't
    know what I am doing here). <br>
    I changed the <br>
    <br>
    generalWait.wait(&amp;rwlock, 250) to generalWait.wait(&amp;rwlock,
    500)<br>
    This change was made mostly as I felt there might be another thread
    that needed some more time (perhaps something that is writing to the
    buffer?)<br>
    <br>
    I then removed everything in the else-if statement and just tested
    if it was over 1000. <br>
    With these changes I very rarely get anything in the log. I still
    get the 4-5 seconds freeze between shows though (even though that
    doesn't always happen).<br>
    <br>
    Any clarifications here would be awesome. I have also seen multiple
    other folks having these error messages (searching the Internet).<br>
    <br>
    Thanks,<br>
    <br>
    // Jonas<br>
  </body>
</html>