[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beta Version - Please help





On Tue, 17 Aug 1999, Philipp GXhring wrote:
> 
> The first thing I need is delay(long n).
> delay should wait for n milliseconds. (thousands of a second)
as i see it, there are two ways to do this.
the first is to use the gettimeofday function, and set a variable, say 
oldtime, to it.  then just loop, or sleep until the gettimeofday function 
returns the first oldtime+delaytime...but personally (and i'm not sure 
how true this is) i've found that the gettimeofday function is really slow.
theres also the select function which i read somewhere (though don't ask 
me where) is a good way to do a delay type situation...
but wait, theres more...
way back in my dos programming days, there was a technique suggested to 
me where at the beginning of your program, you make a function that is as 
follows:
gettime();
while (i<UPPER_BOUND) && (keepgoing==true) {
  t=gettime()
  for (j=0; j<i; j++);
  if (gettime()-t==timeyouwanttodelay) keepgoing=false;
}
and then your own home brewed delay function, use that j value to do the 
following:
function delay() {
  for (k=0; k<j; k++);  
}
which should theoretically delay for timeyouwanttodelay...
well, all these ways may be back-asswards ways of doing a delay, but 
thats what comes to mind of the top of my head...

> 
> The next thing I need is a constant framerate for my video player (it
> plays .flc and .fli videos) I need for example 15 frames per second.
> So the loop algorithm I wrote was the following:
a modified home-brew delay as described above might work.
> 
> While playing the above way, it should be possible to skip the video
> or a sequence of videos by pressing a key on the keyboard. I realized
> this under DOS with kbhit(), which i couldnīt find in Linux.
> (kbhit is a non-blocking getch)
um, excuse my ignorence, but i don't rightly know if you're doing this 
under x or console.  if you're doing it under x, then the main idle loop 
can look for keyboard hits at any time.  if you're doing it under 
console, i believe there is a way to make io non-blocking via fcntl, 
using the F_SETFL operation and setting the O_NONBLOCK bit, or using 
ioctl with the FIONBIO operation (?????)

> And the last thing is the Background music. I just forked and updated
> mikmod in the background, but it is still playing, when I stop the
> program with CTRL+C.
you just have to let your different forked processes talk to each other 
either via a pipe, shared memory, or the like, and then if one gets an 
exit signal then it will the tell the other accordingly.

well, rather a long winded response, but i hope you can glean some 
usefull information...tell me if any of this actually works...

abram connelly