diff options
-rw-r--r-- | server/inputs-channel.c | 3 | ||||
-rw-r--r-- | server/main-channel.c | 6 | ||||
-rw-r--r-- | server/mjpeg-encoder.c | 8 | ||||
-rw-r--r-- | server/red-channel.c | 4 | ||||
-rw-r--r-- | server/reds-private.h | 2 | ||||
-rw-r--r-- | server/stream.h | 2 | ||||
-rw-r--r-- | server/utils.h | 2 |
7 files changed, 15 insertions, 12 deletions
diff --git a/server/inputs-channel.c b/server/inputs-channel.c index 74aa30da..ba97f0ff 100644 --- a/server/inputs-channel.c +++ b/server/inputs-channel.c @@ -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 diff --git a/server/main-channel.c b/server/main-channel.c index 6cd2e596..eb894b03 100644 --- a/server/main-channel.c +++ b/server/main-channel.c @@ -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")) { diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c index 2a040f55..3bd1a043 100644 --- a/server/mjpeg-encoder.c +++ b/server/mjpeg-encoder.c @@ -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; diff --git a/server/red-channel.c b/server/red-channel.c index f10810ec..ba906c63 100644 --- a/server/red-channel.c +++ b/server/red-channel.c @@ -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 diff --git a/server/reds-private.h b/server/reds-private.h index 5afde306..2df4ca4d 100644 --- a/server/reds-private.h +++ b/server/reds-private.h @@ -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 { diff --git a/server/stream.h b/server/stream.h index 7b63402a..a3e84edd 100644 --- a/server/stream.h +++ b/server/stream.h @@ -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 diff --git a/server/utils.h b/server/utils.h index b85b1048..00631f81 100644 --- a/server/utils.h +++ b/server/utils.h @@ -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; |