mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-24 17:01:43 +00:00
server: Add time constants to go with spice_get_monotonic_time_ms()
They clarify the time unit being used and simplify calculations. Signed-off-by: Francois Gouget <fgouget@codeweavers.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
parent
5c9fb9a0f3
commit
8bddb1444e
@ -42,6 +42,7 @@
|
||||
#include "main-channel.h"
|
||||
#include "inputs-channel.h"
|
||||
#include "migration-protocol.h"
|
||||
#include "utils.h"
|
||||
|
||||
// TODO: RECEIVE_BUF_SIZE used to be the same for inputs_channel and main_channel
|
||||
// since it was defined once in reds.c which contained both.
|
||||
@ -111,7 +112,7 @@ static SpiceTimer *key_modifiers_timer;
|
||||
|
||||
static InputsChannel *g_inputs_channel = NULL;
|
||||
|
||||
#define KEY_MODIFIERS_TTL (1000 * 2) /*2sec*/
|
||||
#define KEY_MODIFIERS_TTL (MSEC_PER_SEC * 2)
|
||||
|
||||
#define SCROLL_LOCK_SCAN_CODE 0x46
|
||||
#define NUM_LOCK_SCAN_CODE 0x45
|
||||
|
||||
@ -53,9 +53,9 @@
|
||||
#define NET_TEST_WARMUP_BYTES 0
|
||||
#define NET_TEST_BYTES (1024 * 250)
|
||||
|
||||
#define PING_INTERVAL (1000 * 10)
|
||||
#define PING_INTERVAL (MSEC_PER_SEC * 10)
|
||||
|
||||
#define CLIENT_CONNECTIVITY_TIMEOUT (30*1000) // 30 seconds
|
||||
#define CLIENT_CONNECTIVITY_TIMEOUT (MSEC_PER_SEC * 30)
|
||||
|
||||
static uint8_t zero_page[ZERO_BUF_SIZE] = {0};
|
||||
|
||||
@ -1050,7 +1050,7 @@ static void do_ping_client(MainChannelClient *mcc,
|
||||
main_channel_client_push_ping(mcc, 0);
|
||||
} else if (!strcmp(opt, "on")) {
|
||||
if (has_interval && interval > 0) {
|
||||
mcc->ping_interval = interval * 1000;
|
||||
mcc->ping_interval = interval * MSEC_PER_SEC;
|
||||
}
|
||||
core->timer_start(mcc->ping_timer, mcc->ping_interval);
|
||||
} else if (!strcmp(opt, "off")) {
|
||||
|
||||
@ -59,7 +59,7 @@ static const int mjpeg_quality_samples[MJPEG_QUALITY_SAMPLE_NUM] = {20, 30, 40,
|
||||
* avoid interrupting the playback when there are temporary
|
||||
* incidents of instability (with respect to server and client drops)
|
||||
*/
|
||||
#define MJPEG_MAX_CLIENT_PLAYBACK_DELAY 5000 // 5 sec
|
||||
#define MJPEG_MAX_CLIENT_PLAYBACK_DELAY (MSEC_PER_SEC * 5)
|
||||
|
||||
/*
|
||||
* The stream starts after lossless frames were sent to the client,
|
||||
@ -663,11 +663,11 @@ static void mjpeg_encoder_adjust_fps(MJpegEncoder *encoder, uint64_t now)
|
||||
|
||||
if (!rate_control->during_quality_eval &&
|
||||
adjusted_fps_time_passed > MJPEG_ADJUST_FPS_TIMEOUT &&
|
||||
adjusted_fps_time_passed > 1000 / rate_control->adjusted_fps) {
|
||||
adjusted_fps_time_passed > MSEC_PER_SEC / rate_control->adjusted_fps) {
|
||||
double avg_fps;
|
||||
double fps_ratio;
|
||||
|
||||
avg_fps = ((double)rate_control->adjusted_fps_num_frames*1000) /
|
||||
avg_fps = ((double)rate_control->adjusted_fps_num_frames * MSEC_PER_SEC) /
|
||||
adjusted_fps_time_passed;
|
||||
spice_debug("#frames-adjust=%"PRIu64" #adjust-time=%"PRIu64" avg-fps=%.2f",
|
||||
rate_control->adjusted_fps_num_frames, adjusted_fps_time_passed, avg_fps);
|
||||
@ -1165,7 +1165,7 @@ static uint32_t get_min_required_playback_delay(uint64_t frame_enc_size,
|
||||
if (!frame_enc_size || !byte_rate) {
|
||||
return latency;
|
||||
}
|
||||
one_frame_time = (frame_enc_size*1000)/byte_rate;
|
||||
one_frame_time = (frame_enc_size * MSEC_PER_SEC) / byte_rate;
|
||||
|
||||
min_delay = MIN(one_frame_time*2 + latency, MJPEG_MAX_CLIENT_PLAYBACK_DELAY);
|
||||
return min_delay;
|
||||
|
||||
@ -50,8 +50,8 @@ typedef struct EmptyMsgPipeItem {
|
||||
int msg;
|
||||
} EmptyMsgPipeItem;
|
||||
|
||||
#define PING_TEST_TIMEOUT_MS 15000
|
||||
#define PING_TEST_IDLE_NET_TIMEOUT_MS 100
|
||||
#define PING_TEST_TIMEOUT_MS (MSEC_PER_SEC * 15)
|
||||
#define PING_TEST_IDLE_NET_TIMEOUT_MS (MSEC_PER_SEC / 10)
|
||||
|
||||
#define CHANNEL_BLOCKED_SLEEP_DURATION 10000 //micro
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
#include <spice/protocol.h>
|
||||
|
||||
#define MIGRATE_TIMEOUT (1000 * 10) /* 10sec */
|
||||
#define MIGRATE_TIMEOUT (MSEC_PER_SEC * 10)
|
||||
#define MM_TIME_DELTA 400 /*ms*/
|
||||
|
||||
typedef struct TicketAuthentication {
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
#define RED_STREAM_CHANNEL_CAPACITY 0.8
|
||||
/* the client's stream report frequency is the minimum of the 2 values below */
|
||||
#define RED_STREAM_CLIENT_REPORT_WINDOW 5 // #frames
|
||||
#define RED_STREAM_CLIENT_REPORT_TIMEOUT 1000 // milliseconds
|
||||
#define RED_STREAM_CLIENT_REPORT_TIMEOUT MSEC_PER_SEC
|
||||
#define RED_STREAM_DEFAULT_HIGH_START_BIT_RATE (10 * 1024 * 1024) // 10Mbps
|
||||
#define RED_STREAM_DEFAULT_LOW_START_BIT_RATE (2.5 * 1024 * 1024) // 2.5Mbps
|
||||
#define MAX_FPS 30
|
||||
|
||||
@ -62,6 +62,8 @@ static inline red_time_t spice_get_monotonic_time_ns(void)
|
||||
return NSEC_PER_SEC * time.tv_sec + time.tv_nsec;
|
||||
}
|
||||
|
||||
#define MSEC_PER_SEC 1000
|
||||
|
||||
static inline red_time_t spice_get_monotonic_time_ms(void)
|
||||
{
|
||||
return g_get_monotonic_time() / 1000;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user