From b31a9b47266bf4ea531cd43f96dc2e666948f175 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Fri, 8 May 2020 11:40:30 -0700 Subject: Add an event log soft flush and call it twice per frame in between hard flushes to netplay latency when there are insufficient hardware updates to flush packets in the middle of a frame --- event_log.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'event_log.c') diff --git a/event_log.c b/event_log.c index dd6eaa7..79f2bc2 100644 --- a/event_log.c +++ b/event_log.c @@ -276,6 +276,7 @@ static void flush_socket(void) } } +uint8_t wrote_since_last_flush; void event_log(uint8_t type, uint32_t cycle, uint8_t size, uint8_t *payload) { if (!fully_active) { @@ -294,6 +295,7 @@ void event_log(uint8_t type, uint32_t cycle, uint8_t size, uint8_t *payload) if (listen_sock) { if ((output_stream.next_out - compressed) > 1280 || !output_stream.avail_out) { flush_socket(); + wrote_since_last_flush = 1; } } else if (!output_stream.avail_out) { fwrite(compressed, 1, compressed_storage, event_file); @@ -467,9 +469,22 @@ void event_flush(uint32_t cycle) output_stream.avail_out = compressed_storage; } else if (listen_sock) { flush_socket(); + wrote_since_last_flush = 0; } } +void event_soft_flush(uint32_t cycle) +{ + if (!fully_active || wrote_since_last_flush || event_file) { + return; + } + event_header(EVENT_FLUSH, cycle); + last = cycle; + + deflate_flush(0); + flush_socket(); +} + static void init_event_reader_common(event_reader *reader) { reader->last_cycle = 0; -- cgit v1.2.3