class DirectSoundDriver(AbstractAudioDriver): def __init__(self): self._ds_driver = interface.DirectSoundDriver() self._ds_listener = self._ds_driver.create_listener() assert self._ds_driver is not None assert self._ds_listener is not None self.worker = PlayerWorkerThread() self.worker.start() def __del__(self): self.delete() def create_audio_player(self, source, player): assert self._ds_driver is not None # We increase IDirectSound refcount for each AudioPlayer instantiated # This makes sure the AudioPlayer still has a valid _native_dsound to # clean-up itself during tear-down. self._ds_driver._native_dsound.AddRef() return DirectSoundAudioPlayer(self, self._ds_driver, source, player) def get_listener(self): assert self._ds_driver is not None assert self._ds_listener is not None return DirectSoundListener(self._ds_listener, self._ds_driver.primary_buffer) def delete(self): # Make sure the _ds_listener is deleted before the _ds_driver self.worker.stop() self._ds_listener = None
def __init__(self): self._ds_driver = interface.DirectSoundDriver() self._ds_listener = self._ds_driver.create_listener() assert self._ds_driver is not None assert self._ds_listener is not None self.worker = PlayerWorkerThread() self.worker.start()
def __init__(self, device_name=None): super().__init__() self.device = interface.OpenALDevice(device_name) self.context = self.device.create_context() self.context.make_current() self._listener = OpenALListener(self) self.worker = PlayerWorkerThread() self.worker.start()
class OpenALDriver(AbstractAudioDriver): def __init__(self, device_name=None): super().__init__() self.device = interface.OpenALDevice(device_name) self.context = self.device.create_context() self.context.make_current() self._listener = OpenALListener(self) self.worker = PlayerWorkerThread() self.worker.start() def __del__(self): assert _debug("Delete OpenALDriver") self.delete() def create_audio_player(self, source, player): assert self.device is not None, "Device was closed" return OpenALAudioPlayer(self, source, player) def delete(self): self.worker.stop() self.context = None def have_version(self, major, minor): return (major, minor) <= self.get_version() def get_version(self): assert self.device is not None, "Device was closed" return self.device.get_version() def get_extensions(self): assert self.device is not None, "Device was closed" return self.device.get_extensions() def have_extension(self, extension): return extension in self.get_extensions() def get_listener(self): return self._listener