diff options
author | Michael Pavone <pavone@retrodev.com> | 2020-05-08 11:40:30 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2020-05-08 11:40:30 -0700 |
commit | b31a9b47266bf4ea531cd43f96dc2e666948f175 (patch) | |
tree | fdf3ac4e2cafaed2158d1295d30e589e9e416d5f /event_log.c | |
parent | fd634d54cddc7419df08949f39fc50e4275ee8f7 (diff) |
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
Diffstat (limited to 'event_log.c')
-rw-r--r-- | event_log.c | 15 |
1 files changed, 15 insertions, 0 deletions
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; |