예제 #1
0
static void WaitForPoll(void) {		// Implement a blocking read
    static double time0 = 0;		// start time in seconds
    double timer;			// time remaining from last poll usec

    timer = quisk_sound_state.data_poll_usec - (QuiskTimeSec() - time0) * 1e6;

    if (timer > 1000.0)     // see if enough time has elapsed
        QuiskSleepMicrosec((int)timer);		// wait for the remainder of the poll interval

    time0 = QuiskTimeSec();	// reset starting time value
}
예제 #2
0
void ptimer(int counts)	// used for debugging
{	// print the number of counts per second
	static unsigned int calls=0, total=0;
	static time_t time0=0;
	time_t dt;

	if (time0 == 0) {
		time0 = (int)(QuiskTimeSec() * 1.e6);
		return;
	}
	total += counts;
	calls++;
	if (calls % 1000 == 0) {
		dt = (int)(QuiskTimeSec() * 1.e6) - time0;
		printf("ptimer: %d counts in %d microseconds %.3f counts/sec\n",
			total, (unsigned)dt, (double)total * 1E6 / dt); 
	}
}