changeset 535:a50c0a1b628f

Don’t stop music loading if the pos file isn’t found.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 05 Apr 2014 13:51:31 +0200
parents 346cbf266856
children 6b76c9ba3975
files pytouhou/ui/music.pyx
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/ui/music.pyx
+++ b/pytouhou/ui/music.pyx
@@ -36,9 +36,8 @@ cdef class BGMPlayer(MusicPlayer):
             try:
                 track = resource_loader.get_track(posname)
             except KeyError:
-                self.bgms.append(None)
-                logger.warn(u'Music description “%s” not found.', posname)
-                continue
+                track = None
+                logger.warn(u'Music description “%s” not found, continuing without looping data.', posname)
             globname = join(resource_loader.game_dir, bgm[1].encode('ascii')).replace('.mid', '.*')
             filenames = glob(globname)
             for filename in reversed(filenames):
@@ -48,7 +47,8 @@ cdef class BGMPlayer(MusicPlayer):
                     logger.debug(u'Music file “%s” unreadable: %s', filename, error)
                     continue
                 else:
-                    source.set_loop_points(track.start / 44100., track.end / 44100.) #TODO: retrieve the sample rate from the actual track.
+                    if track is not None:
+                        source.set_loop_points(track.start / 44100., track.end / 44100.) #TODO: retrieve the sample rate from the actual track.
                     self.bgms.append(source)
                     logger.debug(u'Music file “%s” opened.', filename)
                     break