Use GetTickCount64 instead of GetTickCountPrecise.
authorArmin Novak <armin.novak@thincast.com>
Mon, 2 Sep 2019 13:44:52 +0000 (15:44 +0200)
committerArmin Novak <armin.novak@thincast.com>
Mon, 2 Sep 2019 13:46:36 +0000 (15:46 +0200)
channels/rdpgfx/client/rdpgfx_main.c
channels/rdpgfx/client/rdpgfx_main.h
channels/rdpsnd/client/rdpsnd_main.c
include/freerdp/autodetect.h
libfreerdp/core/autodetect.c
libfreerdp/core/transport.c
winpr/libwinpr/utils/collections/MessageQueue.c

index aeb4b36..c46a3a8 100644 (file)
@@ -760,7 +760,7 @@ static UINT rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
        Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
        DEBUG_RDPGFX(gfx->log, "RecvStartFramePdu: frameId: %"PRIu32" timestamp: 0x%08"PRIX32"",
                   pdu.frameId, pdu.timestamp);
-       gfx->StartDecodingTime = GetTickCountPrecise();
+       gfx->StartDecodingTime = GetTickCount64();
 
        if (context)
        {
@@ -845,7 +845,7 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
                        if (gfx->SendQoeAck)
                        {
                                RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU qoe;
-                               UINT32 diff = (GetTickCountPrecise() - gfx->StartDecodingTime);
+                               UINT64 diff = (GetTickCount64() - gfx->StartDecodingTime);
 
                                if (diff > 65000)
                                        diff = 0;
index aada843..f7dfdf2 100644 (file)
@@ -72,7 +72,7 @@ struct _RDPGFX_PLUGIN
        ZGFX_CONTEXT* zgfx;
        UINT32 UnacknowledgedFrames;
        UINT32 TotalDecodedFrames;
-       UINT32 StartDecodingTime;
+       UINT64 StartDecodingTime;
        BOOL suspendFrameAcks;
        BOOL sendFrameAcks;
 
index 4284ab2..331a9a9 100644 (file)
@@ -82,7 +82,7 @@ struct rdpsnd_plugin
        BYTE waveData[4];
        UINT16 waveDataSize;
        UINT32 wTimeStamp;
-       UINT32 wArrivalTime;
+       UINT64 wArrivalTime;
 
        UINT32 latency;
        BOOL isOpen;
@@ -388,7 +388,7 @@ static UINT rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s,
        if (Stream_GetRemainingLength(s) < 12)
                return ERROR_BAD_LENGTH;
 
-       rdpsnd->wArrivalTime = GetTickCount();
+       rdpsnd->wArrivalTime = GetTickCount64();
        Stream_Read_UINT16(s, rdpsnd->wTimeStamp);
        Stream_Read_UINT16(s, wFormatNo);
 
@@ -440,8 +440,8 @@ static UINT rdpsnd_treat_wave(rdpsndPlugin* rdpsnd, wStream* s, size_t size)
 {
        BYTE* data;
        AUDIO_FORMAT* format;
-       DWORD end;
-       DWORD diffMS;
+       UINT64 end;
+       UINT64 diffMS;
        UINT latency = 0;
 
        if (Stream_GetRemainingLength(s) < size)
@@ -474,7 +474,7 @@ static UINT rdpsnd_treat_wave(rdpsndPlugin* rdpsnd, wStream* s, size_t size)
                        return status;
        }
 
-       end = GetTickCount();
+       end = GetTickCount64();
        diffMS = end - rdpsnd->wArrivalTime + latency;
        return rdpsnd_send_wave_confirm_pdu(rdpsnd, rdpsnd->wTimeStamp + diffMS, rdpsnd->cBlockNo);
 }
@@ -518,7 +518,7 @@ static UINT rdpsnd_recv_wave2_pdu(rdpsndPlugin* rdpsnd, wStream* s, UINT16 BodyS
        Stream_Read_UINT32(s, dwAudioTimeStamp);
        rdpsnd->waveDataSize = BodySize - 12;
        format = &rdpsnd->ClientFormats[wFormatNo];
-       rdpsnd->wArrivalTime = GetTickCount();
+       rdpsnd->wArrivalTime = GetTickCount64();
        WLog_Print(rdpsnd->log, WLOG_DEBUG, "Wave2PDU: cBlockNo: %"PRIu8" wFormatNo: %"PRIu16", align=%hu",
                   rdpsnd->cBlockNo, wFormatNo, format->nBlockAlign);
 
index d5fa2e7..9d95c95 100644 (file)
@@ -1,61 +1,61 @@
-/**
- * FreeRDP: A Remote Desktop Protocol Implementation
- * Auto-Detect PDUs
- *
- * Copyright 2014 Dell Software <Mike.McDonald@software.dell.com>
- * Copyright 2014 Vic Lee
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef FREERDP_AUTODETECT_H
-#define FREERDP_AUTODETECT_H
-
-typedef struct rdp_autodetect rdpAutoDetect;
-
-typedef BOOL (*pRTTMeasureRequest)(rdpContext* context, UINT16 sequenceNumber);
-typedef BOOL (*pRTTMeasureResponse)(rdpContext* context, UINT16 sequenceNumber);
-typedef BOOL (*pBandwidthMeasureStart)(rdpContext* context, UINT16 sequenceNumber);
-typedef BOOL (*pBandwidthMeasureStop)(rdpContext* context, UINT16 sequenceNumber);
-typedef BOOL (*pBandwidthMeasureResults)(rdpContext* context, UINT16 sequenceNumber);
-typedef BOOL (*pNetworkCharacteristicsResult)(rdpContext* context, UINT16 sequenceNumber);
-typedef BOOL (*pClientBandwidthMeasureResult)(rdpContext* context, rdpAutoDetect* data);
-
-struct rdp_autodetect
-{
-       ALIGN64 rdpContext* context; /* 0 */
-       /* RTT measurement */
-       ALIGN64 UINT32 rttMeasureStartTime; /* 1 */
-       /* Bandwidth measurement */
-       ALIGN64 UINT32 bandwidthMeasureStartTime; /* 2 */
-       ALIGN64 UINT32 bandwidthMeasureTimeDelta; /* 3 */
-       ALIGN64 UINT32 bandwidthMeasureByteCount; /* 4 */
-       /* Network characteristics (as reported by server) */
-       ALIGN64 UINT32 netCharBandwidth; /* 5 */
-       ALIGN64 UINT32 netCharBaseRTT; /* 6 */
-       ALIGN64 UINT32 netCharAverageRTT; /* 7 */
-       ALIGN64 BOOL bandwidthMeasureStarted; /* 8 */
-       UINT64 paddingA[16 - 9]; /* 9 */
-
-       ALIGN64 pRTTMeasureRequest RTTMeasureRequest; /* 16 */
-       ALIGN64 pRTTMeasureResponse RTTMeasureResponse; /* 17 */
-       ALIGN64 pBandwidthMeasureStart BandwidthMeasureStart; /* 18 */
-       ALIGN64 pBandwidthMeasureStop BandwidthMeasureStop; /* 19 */
-       ALIGN64 pBandwidthMeasureResults BandwidthMeasureResults; /* 20 */
-       ALIGN64 pNetworkCharacteristicsResult NetworkCharacteristicsResult; /* 21 */
-       ALIGN64 pClientBandwidthMeasureResult ClientBandwidthMeasureResult; /* 22 */
-       UINT64 paddingB[32 - 23]; /* 23 */
-};
-
-
-#endif /* FREERDP_AUTODETECT_H */
+/**\r
+ * FreeRDP: A Remote Desktop Protocol Implementation\r
+ * Auto-Detect PDUs\r
+ *\r
+ * Copyright 2014 Dell Software <Mike.McDonald@software.dell.com>\r
+ * Copyright 2014 Vic Lee\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#ifndef FREERDP_AUTODETECT_H\r
+#define FREERDP_AUTODETECT_H\r
+\r
+typedef struct rdp_autodetect rdpAutoDetect;\r
+\r
+typedef BOOL (*pRTTMeasureRequest)(rdpContext* context, UINT16 sequenceNumber);\r
+typedef BOOL (*pRTTMeasureResponse)(rdpContext* context, UINT16 sequenceNumber);\r
+typedef BOOL (*pBandwidthMeasureStart)(rdpContext* context, UINT16 sequenceNumber);\r
+typedef BOOL (*pBandwidthMeasureStop)(rdpContext* context, UINT16 sequenceNumber);\r
+typedef BOOL (*pBandwidthMeasureResults)(rdpContext* context, UINT16 sequenceNumber);\r
+typedef BOOL (*pNetworkCharacteristicsResult)(rdpContext* context, UINT16 sequenceNumber);\r
+typedef BOOL (*pClientBandwidthMeasureResult)(rdpContext* context, rdpAutoDetect* data);\r
+\r
+struct rdp_autodetect\r
+{\r
+       ALIGN64 rdpContext* context; /* 0 */\r
+       /* RTT measurement */\r
+       ALIGN64 UINT64 rttMeasureStartTime; /* 1 */\r
+       /* Bandwidth measurement */\r
+       ALIGN64 UINT64 bandwidthMeasureStartTime; /* 2 */\r
+       ALIGN64 UINT64 bandwidthMeasureTimeDelta; /* 3 */\r
+       ALIGN64 UINT32 bandwidthMeasureByteCount; /* 4 */\r
+       /* Network characteristics (as reported by server) */\r
+       ALIGN64 UINT32 netCharBandwidth; /* 5 */\r
+       ALIGN64 UINT32 netCharBaseRTT; /* 6 */\r
+       ALIGN64 UINT32 netCharAverageRTT; /* 7 */\r
+       ALIGN64 BOOL bandwidthMeasureStarted; /* 8 */\r
+       UINT64 paddingA[16 - 9]; /* 9 */\r
+\r
+       ALIGN64 pRTTMeasureRequest RTTMeasureRequest; /* 16 */\r
+       ALIGN64 pRTTMeasureResponse RTTMeasureResponse; /* 17 */\r
+       ALIGN64 pBandwidthMeasureStart BandwidthMeasureStart; /* 18 */\r
+       ALIGN64 pBandwidthMeasureStop BandwidthMeasureStop; /* 19 */\r
+       ALIGN64 pBandwidthMeasureResults BandwidthMeasureResults; /* 20 */\r
+       ALIGN64 pNetworkCharacteristicsResult NetworkCharacteristicsResult; /* 21 */\r
+       ALIGN64 pClientBandwidthMeasureResult ClientBandwidthMeasureResult; /* 22 */\r
+       UINT64 paddingB[32 - 23]; /* 23 */\r
+};\r
+\r
+\r
+#endif /* FREERDP_AUTODETECT_H */\r
index 2c1f8b2..11cf085 100644 (file)
@@ -73,7 +73,7 @@ static BOOL autodetect_send_rtt_measure_request(rdpContext* context, UINT16 sequ
        Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_REQUEST); /* headerTypeId (1 byte) */
        Stream_Write_UINT16(s, sequenceNumber); /* sequenceNumber (2 bytes) */
        Stream_Write_UINT16(s, requestType); /* requestType (2 bytes) */
-       context->rdp->autodetect->rttMeasureStartTime = GetTickCountPrecise();
+       context->rdp->autodetect->rttMeasureStartTime = GetTickCount64();
        return rdp_send_message_channel_pdu(context->rdp, s, SEC_AUTODETECT_REQ);
 }
 
@@ -251,9 +251,9 @@ static BOOL autodetect_send_bandwidth_measure_results(rdpRdp* rdp, UINT16 respon
 {
        BOOL success = TRUE;
        wStream* s;
-       UINT32 timeDelta;
+       UINT64 timeDelta;
        /* Compute the total time */
-       timeDelta = GetTickCountPrecise() - rdp->autodetect->bandwidthMeasureStartTime;
+       timeDelta = GetTickCount64() - rdp->autodetect->bandwidthMeasureStartTime;
        /* Send the result PDU to the server */
        s = rdp_message_channel_pdu_init(rdp);
 
@@ -352,7 +352,7 @@ static BOOL autodetect_recv_rtt_measure_response(rdpRdp* rdp, wStream* s,
                return FALSE;
 
        WLog_VRB(AUTODETECT_TAG, "received RTT Measure Response PDU");
-       rdp->autodetect->netCharAverageRTT = GetTickCountPrecise() - rdp->autodetect->rttMeasureStartTime;
+       rdp->autodetect->netCharAverageRTT = GetTickCount64() - rdp->autodetect->rttMeasureStartTime;
 
        if (rdp->autodetect->netCharBaseRTT == 0 ||
            rdp->autodetect->netCharBaseRTT > rdp->autodetect->netCharAverageRTT)
@@ -369,10 +369,10 @@ static BOOL autodetect_recv_bandwidth_measure_start(rdpRdp* rdp, wStream* s,
        if (autodetectReqPdu->headerLength != 0x06)
                return FALSE;
 
-       WLog_VRB(AUTODETECT_TAG, "received Bandwidth Measure Start PDU - time=%"PRIu32"",
-                GetTickCountPrecise());
+       WLog_VRB(AUTODETECT_TAG, "received Bandwidth Measure Start PDU - time=%"PRIu64"",
+                        GetTickCount64());
        /* Initialize bandwidth measurement parameters */
-       rdp->autodetect->bandwidthMeasureStartTime = GetTickCountPrecise();
+       rdp->autodetect->bandwidthMeasureStartTime = GetTickCount64();
        rdp->autodetect->bandwidthMeasureByteCount = 0;
 
        /* Continuous Auto-Detection: mark the start of the measurement */
index ee038a0..77915cd 100644 (file)
@@ -991,8 +991,8 @@ int transport_check_fds(rdpTransport* transport)
        int status;
        int recv_status;
        wStream* received;
-       DWORD now = GetTickCount();
-       DWORD dueDate = 0;
+       UINT64 now = GetTickCount64();
+       UINT64 dueDate = 0;
 
        if (!transport)
                return -1;
@@ -1056,7 +1056,7 @@ int transport_check_fds(rdpTransport* transport)
                        return -1;
                }
 
-               now = GetTickCount();
+               now = GetTickCount64();
        }
 
        if (now >= dueDate)
index c41c473..4cda990 100644 (file)
@@ -101,7 +101,7 @@ BOOL MessageQueue_Dispatch(wMessageQueue* queue, wMessage* message)
        queue->size++;
 
        message = &(queue->array[queue->tail]);
-       message->time = (UINT64) GetTickCount();
+       message->time = GetTickCount64();
 
        if (queue->size > 0)
                SetEvent(queue->event);