mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
pass timeval to diffclock function, change base SDK
This commit is contained in:
parent
bd62514fb5
commit
afebb6160e
6 changed files with 16 additions and 14 deletions
|
@ -232,7 +232,7 @@ void *receiveAudioViaUDP(void *args) {
|
|||
if (LOG_SAMPLE_DELAY) {
|
||||
if (!firstSample) {
|
||||
// write time difference (in microseconds) between packet receipts to file
|
||||
double timeDiff = diffclock(previousReceiveTime, currentReceiveTime);
|
||||
double timeDiff = diffclock(&previousReceiveTime, ¤tReceiveTime);
|
||||
logFile << timeDiff << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ void *receiveAudioViaUDP(void *args) {
|
|||
if (firstSample) {
|
||||
stdev.reset();
|
||||
} else {
|
||||
stdev.addValue(diffclock(previousReceiveTime, currentReceiveTime));
|
||||
stdev.addValue(diffclock(&previousReceiveTime, ¤tReceiveTime));
|
||||
if (stdev.getSamples() > 500) {
|
||||
printf("Avg: %4.2f, Stdev: %4.2f\n", stdev.getAverage(), stdev.getStDev());
|
||||
stdev.reset();
|
||||
|
@ -422,7 +422,7 @@ void Audio::render(int screenWidth, int screenHeight)
|
|||
float remainingBuffer = 0;
|
||||
timeval currentTime;
|
||||
gettimeofday(¤tTime, NULL);
|
||||
float timeLeftInCurrentBuffer = diffclock(data->lastCallback, currentTime)/(1000.0*(float)BUFFER_LENGTH_SAMPLES/(float)SAMPLE_RATE) * frameWidth;
|
||||
float timeLeftInCurrentBuffer = diffclock(&data->lastCallback, ¤tTime)/(1000.0*(float)BUFFER_LENGTH_SAMPLES/(float)SAMPLE_RATE) * frameWidth;
|
||||
//float timeLeftInCurrentBuffer = diffclock(currentTime, data->lastCallback)/23.22 * frameWidth;
|
||||
|
||||
remainingBuffer = data->ringBuffer->diffLastWriteNextOutput() / BUFFER_LENGTH_SAMPLES * frameWidth;
|
||||
|
|
|
@ -138,7 +138,7 @@ int network_receive(int handle, in_addr * from_addr, char * packet_data, int del
|
|||
}
|
||||
// Then check if next to be sent is past due, send if so
|
||||
if ((next_to_receive != next_to_send) &&
|
||||
(diffclock(delay_time_received[next_to_send], check) > delay)) {
|
||||
(diffclock(&delay_time_received[next_to_send], &check) > delay)) {
|
||||
int returned_bytes = delay_size_received[next_to_send];
|
||||
memcpy(packet_data,
|
||||
&delay_buffer[next_to_send*MAX_PACKET_SIZE],
|
||||
|
|
|
@ -137,10 +137,10 @@ void outstring(char * string, int length) {
|
|||
std::cout << out << "\n";
|
||||
}
|
||||
|
||||
double diffclock(timeval clock1,timeval clock2)
|
||||
double diffclock(timeval *clock1,timeval *clock2)
|
||||
{
|
||||
double diffms = (clock2.tv_sec - clock1.tv_sec) * 1000.0;
|
||||
diffms += (clock2.tv_usec - clock1.tv_usec) / 1000.0; // us to ms
|
||||
double diffms = (clock2->tv_sec - clock1->tv_sec) * 1000.0;
|
||||
diffms += (clock2->tv_usec - clock1->tv_usec) / 1000.0; // us to ms
|
||||
|
||||
return diffms;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ void drawtext(int x, int y, float scale, float rotate, float thick, int mono, ch
|
|||
float r=1.0, float g=1.0, float b=1.0);
|
||||
void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, glm::vec3 vec,
|
||||
float r=1.0, float g=1.0, float b=1.0);
|
||||
double diffclock(timeval clock1,timeval clock2);
|
||||
double diffclock(timeval *clock1,timeval *clock2);
|
||||
|
||||
class StDev {
|
||||
public:
|
||||
|
|
|
@ -217,9 +217,9 @@ float pointer_attenuation_quadratic[] = { 1.0f, 0.0f, 0.0f }; // for 2D view
|
|||
void Timer(int extra)
|
||||
{
|
||||
gettimeofday(&timer_end, NULL);
|
||||
FPS = (float)framecount / ((float)diffclock(timer_start,timer_end) / 1000.f);
|
||||
packets_per_second = (float)packetcount / ((float)diffclock(timer_start,timer_end) / 1000.f);
|
||||
bytes_per_second = (float)bytescount / ((float)diffclock(timer_start,timer_end) / 1000.f);
|
||||
FPS = (float)framecount / ((float)diffclock(&timer_start, &timer_end) / 1000.f);
|
||||
packets_per_second = (float)packetcount / ((float)diffclock(&timer_start, &timer_end) / 1000.f);
|
||||
bytes_per_second = (float)bytescount / ((float)diffclock(&timer_start, &timer_end) / 1000.f);
|
||||
framecount = 0;
|
||||
packetcount = 0;
|
||||
bytescount = 0;
|
||||
|
@ -312,7 +312,7 @@ void init(void)
|
|||
{
|
||||
serialPort.readData();
|
||||
gettimeofday(&timer_end, NULL);
|
||||
if (diffclock(timer_start,timer_end) > 1000) done = 1;
|
||||
if (diffclock(&timer_start, &timer_end) > 1000) done = 1;
|
||||
}
|
||||
gravity.x = serialPort.getValue(ACCEL_X);
|
||||
gravity.y = serialPort.getValue(ACCEL_Y);
|
||||
|
@ -759,7 +759,7 @@ void read_network()
|
|||
//
|
||||
timeval check;
|
||||
gettimeofday(&check, NULL);
|
||||
ping_msecs = (float)diffclock(ping_start, check);
|
||||
ping_msecs = (float)diffclock(&ping_start, &check);
|
||||
} else if (incoming_packet[0] == 'S') {
|
||||
//
|
||||
// Message from Spaceserver
|
||||
|
@ -780,7 +780,7 @@ void idle(void)
|
|||
gettimeofday(&check, NULL);
|
||||
|
||||
// Check and render display frame
|
||||
if (diffclock(last_frame,check) > RENDER_FRAME_MSECS)
|
||||
if (diffclock(&last_frame, &check) > RENDER_FRAME_MSECS)
|
||||
{
|
||||
steps_per_frame++;
|
||||
// Simulation
|
||||
|
|
|
@ -957,6 +957,7 @@
|
|||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx10.7;
|
||||
};
|
||||
|
@ -969,6 +970,7 @@
|
|||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7;
|
||||
SDKROOT = macosx10.7;
|
||||
};
|
||||
name = Release;
|
||||
|
|
Loading…
Reference in a new issue