changeset 111:18ffaaaa27e7

Add explicit check for sound file existence (my pygame 1.9 returns a valid sound object even when the path does not exist).
author Simon Cross <simon@simonx>
date Tue, 24 Aug 2010 14:43:33 +0200
parents 545dee3bd8e9
children a2c09200a433
files gamelib/sound.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/sound.py	Tue Aug 24 14:33:48 2010 +0200
+++ b/gamelib/sound.py	Tue Aug 24 14:43:33 2010 +0200
@@ -4,6 +4,8 @@
 # a) work around an annoying bugs
 # b) add some missing functionality (disable_sound)
 
+import os
+
 from albow.resource import _resource_path, dummy_sound
 
 sound_cache = {}
@@ -14,6 +16,9 @@
     path = _resource_path("sounds", names)
     sound = sound_cache.get(path)
     if not sound:
+        if not os.path.isfile(path):
+            missing_sound("File does not exist", path)
+            return dummy_sound
         try:
             from pygame.mixer import Sound
         except ImportError, e: