diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/dvfile.cc | 18 | ||||
| -rw-r--r-- | client/dvfile.h | 1 | 
2 files changed, 17 insertions, 2 deletions
| diff --git a/client/dvfile.cc b/client/dvfile.cc index 601c21d..a34de3d 100644 --- a/client/dvfile.cc +++ b/client/dvfile.cc @@ -31,6 +31,8 @@  #include "info.h" +#include <sys/time.h> +  dvfile::dvfile()  {    fp = fopen(TEST_MOVIE, "r"); @@ -44,9 +46,18 @@ dvfile::~dvfile()  Frame *dvfile::readFrame()  { -  unsigned char *ptr = new unsigned char[DVPACKAGE_SIZE]; +  timeval tv; + +  // Wait untill atleast 1/25th of a second has passed in order to +  // preserve 25fps when enough cpu is available +  gettimeofday(&tv, NULL); +  long long unsigned int diff = +    tv.tv_sec * 1000000LL +  +    tv.tv_usec - last_frame; -  sleep_1_frame(); +  if(diff < (1000000 / 25)) usleep((1000000 / 25) - diff); +   +  unsigned char *ptr = new unsigned char[DVPACKAGE_SIZE];    if(fp) {      while(fread(ptr, DVPACKAGE_SIZE, 1, fp) == 0) { @@ -58,5 +69,8 @@ Frame *dvfile::readFrame()    Frame *frame = new Frame((char*)ptr, DVPACKAGE_SIZE, VF_DV, NULL, 0, AF_DV); +  gettimeofday(&tv, NULL); +  last_frame = tv.tv_sec * 1000000LL + tv.tv_usec; +    return frame;  } diff --git a/client/dvfile.h b/client/dvfile.h index 9e21a4d..8a45044 100644 --- a/client/dvfile.h +++ b/client/dvfile.h @@ -46,6 +46,7 @@ public:    Frame *readFrame();  private: +  long long last_frame;    FILE* fp;  }; | 
