summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordeva <deva>2006-08-12 15:47:29 +0000
committerdeva <deva>2006-08-12 15:47:29 +0000
commit5a00b6f95ebe4d6e487ef96c88d385844541a15b (patch)
tree14dd9ae0306eef1c78c0221d5a0e520e84f31c02 /client
parent516535eba2188552a70ead6e953301a6cdaa9794 (diff)
New tasks!
Made dvfile read at most 25 fps.
Diffstat (limited to 'client')
-rw-r--r--client/dvfile.cc18
-rw-r--r--client/dvfile.h1
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;
};