From 3d5156b90d6cb1048c8415a326b901d5c3736621 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Sat, 15 Apr 2023 23:44:20 -0400 Subject: [PATCH] core: Update the stream offset after each tag is processed. The `preload_offset` is only ever moved forward, of course. --- core/src/streams.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/streams.rs b/core/src/streams.rs index 0514846ea..1f20bb230 100644 --- a/core/src/streams.rs +++ b/core/src/streams.rs @@ -12,6 +12,7 @@ use flv_rs::{ use gc_arena::{Collect, GcCell, MutationContext}; use ruffle_video::VideoStreamHandle; use ruffle_wstr::WStr; +use std::cmp::max; use std::io::Seek; use swf::{VideoCodec, VideoDeblocking}; @@ -393,6 +394,13 @@ impl<'gc> NetStream<'gc> { tracing::error!("FLV data parsing failed: {}", e) } } + + // We cannot mutate stream state while also holding an active + // reader or any tags. + let (_, position) = reader.into_parts(); + write.offset = position; + write.preload_offset = max(write.offset, write.preload_offset); + reader = FlvReader::from_parts(&write.buffer, position); } } }