Mercurial > boomslang
comparison pyntnclick/sound.py @ 576:1b1ab71535bd pyntnclick
Classify constants, which involves a whole bunch of XXX comments
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sat, 11 Feb 2012 16:02:06 +0200 |
parents | e393954e3749 |
children | ccc26c23d2c1 |
comparison
equal
deleted
inserted
replaced
575:970cdc219e15 | 576:1b1ab71535bd |
---|---|
16 # Save error, so we don't crash and can do the right thing later | 16 # Save error, so we don't crash and can do the right thing later |
17 pygame_import_error = e | 17 pygame_import_error = e |
18 pygame_Sound = None | 18 pygame_Sound = None |
19 music = None | 19 music = None |
20 | 20 |
21 from pyntnclick.constants import FREQ, BITSIZE, CHANNELS, BUFFER | |
22 from pyntnclick.resources import ResourceNotFound | 21 from pyntnclick.resources import ResourceNotFound |
23 | 22 |
24 import albow.music | 23 import albow.music |
25 | 24 |
26 | 25 |
59 def __init__(self, resource_finder): | 58 def __init__(self, resource_finder): |
60 self.sound_enabled = False | 59 self.sound_enabled = False |
61 self.sound_cache = {} | 60 self.sound_cache = {} |
62 self._resource_finder = resource_finder | 61 self._resource_finder = resource_finder |
63 | 62 |
64 def enable_sound(self): | 63 def enable_sound(self, constants): |
65 """Attempt to initialise the sound system""" | 64 """Attempt to initialise the sound system""" |
66 if pygame_Sound is None: | 65 if pygame_Sound is None: |
67 self.disable_sound(pygame_import_error) | 66 self.disable_sound(pygame_import_error) |
68 return | 67 return |
69 try: | 68 try: |
70 pygame.mixer.init(FREQ, BITSIZE, CHANNELS, BUFFER) | 69 pygame.mixer.init(constants.snd_freq, |
70 constants.snd_bitsize, | |
71 constants.snd_channels, | |
72 constants.snd_buffer) | |
71 self.sound_enabled = True | 73 self.sound_enabled = True |
72 except pygame.error, exc: | 74 except pygame.error, exc: |
73 self.disable_sound(exc) | 75 self.disable_sound(exc) |
74 | 76 |
75 def disable_sound(self, exc=None): | 77 def disable_sound(self, exc=None): |