aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/crepe/system/AudioSystem.cpp6
-rw-r--r--src/test/AudioTest.cpp9
2 files changed, 12 insertions, 3 deletions
diff --git a/src/crepe/system/AudioSystem.cpp b/src/crepe/system/AudioSystem.cpp
index b2c1dc6..ddba268 100644
--- a/src/crepe/system/AudioSystem.cpp
+++ b/src/crepe/system/AudioSystem.cpp
@@ -26,12 +26,12 @@ void AudioSystem::diff_update(AudioSource & component, Sound & resource) {
SoundContext & context = this->get_context();
if (component.active != component.last_active) {
- if (component.active) {
- component.oneshot_play = component.play_on_awake;
- } else {
+ if (!component.active) {
context.stop(component.voice);
return;
}
+ if (component.play_on_awake)
+ component.oneshot_play = true;
}
if (!component.active) return;
diff --git a/src/test/AudioTest.cpp b/src/test/AudioTest.cpp
index 774fdb8..48bba1b 100644
--- a/src/test/AudioTest.cpp
+++ b/src/test/AudioTest.cpp
@@ -150,3 +150,12 @@ TEST_F(AudioTest, PlayOnActive) {
system.update();
}
}
+
+TEST_F(AudioTest, PlayImmediately) {
+ component.play_on_awake = false;
+ component.play();
+
+ EXPECT_CALL(context, play(_)).Times(1);
+
+ system.update();
+}