GLFB: add a few sanity checks for sleep interval

Origin commit data
------------------
Branch: master
Commit: 3ce7bc213c
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2013-05-04 (Sat, 04 May 2013)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Stefan Seyfried
2013-05-04 17:27:01 +02:00
parent 8e329f1e26
commit c6f2fb2d91

View File

@@ -358,7 +358,8 @@ void GLFramebuffer::render()
GLuint err = glGetError();
if (err != 0)
lt_info("GLFB::%s: GLError:%d 0x%04x\n", __func__, err, err);
usleep(sleep_us);
if (sleep_us > 0)
usleep(sleep_us);
glutPostRedisplay();
}
@@ -515,12 +516,14 @@ void GLFramebuffer::bltDisplayBuffer()
sleep_us -= 1000;
last_apts = apts;
videoDecoder->getPictureInfo(dummy1, dummy2, rate);
if (rate)
if (rate > 0)
rate = 2000000 / rate; /* limit to half the frame rate */
else
rate = 50000; /* minimum 20 fps */
if (sleep_us > rate)
sleep_us = rate;
else if (sleep_us < 1)
sleep_us = 1;
}
lt_debug("vpts: 0x%" PRIx64 " apts: 0x%" PRIx64 " diff: %6.3f sleep_us %d buf %d\n",
buf->pts(), apts, (buf->pts() - apts)/90000.0, sleep_us, videoDecoder->buf_num);