audio: Ensure stream sounds stop upon goto/loop (fix #370)
This commit is contained in:
parent
9ad069e11a
commit
7c406732c7
|
@ -450,10 +450,7 @@ impl<'gc> MovieClipData<'gc> {
|
||||||
|
|
||||||
fn stop(&mut self, context: &mut UpdateContext<'_, 'gc, '_>) {
|
fn stop(&mut self, context: &mut UpdateContext<'_, 'gc, '_>) {
|
||||||
self.set_playing(false);
|
self.set_playing(false);
|
||||||
// Stop audio stream if one is playing.
|
self.stop_audio_stream(context);
|
||||||
if let Some(audio_stream) = self.audio_stream.take() {
|
|
||||||
context.audio.stop_stream(audio_stream);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tag_stream_start(&self) -> u64 {
|
fn tag_stream_start(&self) -> u64 {
|
||||||
|
@ -556,11 +553,8 @@ impl<'gc> MovieClipData<'gc> {
|
||||||
self.tag_stream_pos = reader.get_ref().position();
|
self.tag_stream_pos = reader.get_ref().position();
|
||||||
|
|
||||||
// If we are playing a streaming sound, there should(?) be a `SoundStreamBlock` on each frame.
|
// If we are playing a streaming sound, there should(?) be a `SoundStreamBlock` on each frame.
|
||||||
if let Some(audio_stream) = self.audio_stream {
|
|
||||||
if !has_stream_block {
|
if !has_stream_block {
|
||||||
context.audio.stop_stream(audio_stream);
|
self.stop_audio_stream(context);
|
||||||
self.audio_stream = None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,6 +660,8 @@ impl<'gc> MovieClipData<'gc> {
|
||||||
// TODO: Move this to UpdateContext to avoid allocations.
|
// TODO: Move this to UpdateContext to avoid allocations.
|
||||||
let mut goto_commands = vec![];
|
let mut goto_commands = vec![];
|
||||||
|
|
||||||
|
self.stop_audio_stream(context);
|
||||||
|
|
||||||
let is_rewind = if frame < self.current_frame() {
|
let is_rewind = if frame < self.current_frame() {
|
||||||
// Because we can only step forward, we have to start at frame 1
|
// Because we can only step forward, we have to start at frame 1
|
||||||
// when rewinding.
|
// when rewinding.
|
||||||
|
@ -948,6 +944,13 @@ impl<'gc> MovieClipData<'gc> {
|
||||||
self.flags.remove(MovieClipFlags::Initialized)
|
self.flags.remove(MovieClipFlags::Initialized)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stops the audio stream if one is playing.
|
||||||
|
fn stop_audio_stream(&mut self, context: &mut UpdateContext<'_, 'gc, '_>) {
|
||||||
|
if let Some(audio_stream) = self.audio_stream.take() {
|
||||||
|
context.audio.stop_stream(audio_stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preloading of definition tags
|
// Preloading of definition tags
|
||||||
|
|
Loading…
Reference in New Issue