Skip to content

Commit

Permalink
prevent crash on sound_player with placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed Aug 14, 2020
1 parent 7dc29fb commit d7b214f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mpfmc/core/mc_placeholder_manager.py
Expand Up @@ -10,7 +10,7 @@ def get_global_parameters(self, name):
if name == "settings":
return self.machine.settings
elif name == "machine":
return MachinePlaceholder(self.machine)
return False
elif self.machine.player:
if name == "current_player":
return self.machine.player
Expand Down
41 changes: 41 additions & 0 deletions mpfmc/integration/machine_files/sound/config/config.yaml
@@ -0,0 +1,41 @@
#config_version=5
sound_system:
buffer: 2048
frequency: 44100
channels: 2
master_volume: 0.9
tracks:
music:
volume: 0.5
simultaneous_sounds: 1
sfx:
volume: 0.4
simultaneous_sounds: 8
preload: yes
voice:
volume: 0.6
simultaneous_sounds: 1
preload: yes

assets:
sounds:
default:
load: preload
voice:
load: preload
track: voice
sfx:
load: preload
track: sfx
music:
load: on_demand
track: music
loops:
load: preload
track: sfx
playlist:
load: on_demand
track: sfx

sound_player:
machine_var_factory_reset_current_selection{machine.factory_reset_current_selection==2}: 210871_synthping
2 changes: 2 additions & 0 deletions mpfmc/integration/machine_files/sound/sounds/license.txt
@@ -0,0 +1,2 @@
All sounds used in these tests were downloaded from www.freesound.org and are licensed under the
Create Commons 0 License (http://creativecommons.org/publicdomain/zero/1.0/).
Binary file not shown.
19 changes: 19 additions & 0 deletions mpfmc/integration/test_Sound.py
@@ -0,0 +1,19 @@
from mpfmc.tests.MpfIntegrationTestCase import MpfIntegrationTestCase


class TestSound(MpfIntegrationTestCase):

def get_machine_path(self):
return 'integration/machine_files/sound'

def get_config_file(self):
return 'config.yaml'

def test_sound_player_with_conditionals(self):
self.machine.variables.set_machine_var("factory_reset_current_selection", 1)
self.mock_mc_event("sounds_play")
self.advance_time_and_run(1)
self.assertMcEventNotCalled("sounds_play")
self.machine.variables.set_machine_var("factory_reset_current_selection", 2)
self.advance_time_and_run(1)
self.assertMcEventCalled("sounds_play")

0 comments on commit d7b214f

Please sign in to comment.