From 293031de6fb301d818ce51e46dd047c57a189f0b Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Fri, 28 Jun 2013 13:03:30 -0700 Subject: [PATCH] ping reporter added to interface take 3 --- interface/src/Application.cpp | 49 ++++++++++++++++------------------- interface/src/Application.h | 1 - 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 55db7fa50b..1125ed3fb6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -759,21 +759,22 @@ void Application::wheelEvent(QWheelEvent* event) { } } -void sendPingPacket() { +void sendPingPackets() { - char agentTypesOfInterest[] = {'V', 'M', 'W'}; - char pingPacket[1 + sizeof(long long)]; + char agentTypesOfInterest[] = {AGENT_TYPE_VOXEL_SERVER, AGENT_TYPE_AUDIO_MIXER, AGENT_TYPE_AVATAR_MIXER}; + long long currentTime = usecTimestampNow(); + char pingPacket[1 + sizeof(currentTime)]; pingPacket[0] = PACKET_HEADER_PING; - long long currTime = usecTimestampNow(); - memcpy(&pingPacket[1], &currTime, sizeof(long long)); - AgentList::getInstance()->broadcastToAgents((unsigned char*)&pingPacket, 1 + sizeof(long long), agentTypesOfInterest, 3); + + memcpy(&pingPacket[1], ¤tTime, sizeof(currentTime)); + AgentList::getInstance()->broadcastToAgents((unsigned char*)pingPacket, 1 + sizeof(currentTime), agentTypesOfInterest, 3); } // Every second, check the frame rates and other stuff void Application::timer() { gettimeofday(&_timerEnd, NULL); - sendPingPacket(); + sendPingPackets(); _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); _packetsPerSecond = (float)_packetCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f); @@ -2163,23 +2164,6 @@ void Application::displayOverlay() { glPopMatrix(); } -void Application::getPing(long long &pingAudio, long long &pingAvatar, long long &pingVoxel) { - AgentList *agentList = AgentList::getInstance(); - for(AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) { - const char *agentType = agent->getTypeName(); - long long pingTime = agent->getPingTime(); - if (strcmp(agentType, "Audio Mixer") == 0) { - pingAudio = pingTime / 1000; - } - if (strcmp(agentType, "Avatar Mixer") == 0) { - pingAvatar = pingTime / 1000; - } - if (strcmp(agentType, "Voxel Server") == 0) { - pingVoxel = pingTime / 1000; - } - } -} - void Application::displayStats() { int statsVerticalOffset = 8; @@ -2188,11 +2172,22 @@ void Application::displayStats() { _fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f); drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats); - long long pingAudio = 0, pingAvatar = 0, pingVoxel = 0; - getPing(pingAudio, pingAvatar, pingVoxel); + int pingAudio = 0, pingAvatar = 0, pingVoxel = 0; + + AgentList *agentList = AgentList::getInstance(); + Agent *audioMixerAgent = agentList->soloAgentOfType(AGENT_TYPE_AUDIO_MIXER); + Agent *avatarMixerAgent = agentList->soloAgentOfType(AGENT_TYPE_AVATAR); + Agent *voxelServerAgent = agentList->soloAgentOfType(AGENT_TYPE_VOXEL_SERVER); + + if (audioMixerAgent != NULL) + pingAudio = audioMixerAgent->getPingTime(); + if (avatarMixerAgent != NULL) + pingAvatar = avatarMixerAgent->getPingTime(); + if (voxelServerAgent != NULL) + pingVoxel = voxelServerAgent->getPingTime(); char pingStats[200]; - sprintf(pingStats, "Ping audio/avatar/voxel: %lld / %lld / %lld ", pingAudio, pingAvatar, pingVoxel); + sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d ", pingAudio, pingAvatar, pingVoxel); drawtext(10, statsVerticalOffset + 35, 0.10f, 0, 1.0, 0, pingStats); std::stringstream voxelStats; diff --git a/interface/src/Application.h b/interface/src/Application.h index ee7bab209e..b860923299 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -81,7 +81,6 @@ public: private slots: - void getPing(long long &pingAudio, long long &pingAvatar, long long &pingVoxel); void timer(); void idle(); void terminate();