def close(self): """ Clean up allocated memory Close libsoundio connections """ if self.input['stream']: soundio.instream_destroy() del self.input['stream'] if self.output['stream']: soundio.outstream_destroy() del self.output['stream'] if self.input['buffer']: soundio.ring_buffer_destroy(self.input['buffer']) del self.input['buffer'] if self.output['buffer']: soundio.ring_buffer_destroy(self.output['buffer']) del self.output['buffer'] if self.input['device']: soundio.device_unref(self.input['device']) del self.input['device'] if self.output['device']: soundio.device_unref(self.output['device']) del self.output['device'] if self._soundio: soundio.disconnect() soundio.destroy() del self._soundio
def tearDown(self): if self.outstream: soundio.outstream_pause(True) soundio.outstream_destroy() if self.device: soundio.device_unref(self.device) soundio.disconnect() soundio.destroy()
def list_devices(self): """ Return a list of available devices Returns ------- (list)(dict) containing information on available input / output devices. """ output_count = soundio.get_output_device_count() input_count = soundio.get_input_device_count() default_output = soundio.default_output_device_index() default_input = soundio.default_input_device_index() input_devices = [] output_devices = [] for i in range(0, input_count): device = soundio.get_input_device(i) pydevice = _ctypes.cast(device, _ctypes.POINTER(SoundIoDevice)) input_devices.append({ 'id': pydevice.contents.id.decode(), 'name': pydevice.contents.name.decode(), 'is_raw': pydevice.contents.is_raw, 'is_default': default_input == i, 'sample_rates': self.get_sample_rates(device), 'formats': self.get_formats(device), 'layouts': self.get_layouts(device), 'software_latency_min': pydevice.contents.software_latency_min, 'software_latency_max': pydevice.contents.software_latency_max, 'software_latency_current': pydevice.contents.software_latency_current, 'probe_error': PySoundIoError(soundio.strerror(pydevice.contents.probe_error)) if pydevice.contents.probe_error else None }) soundio.device_unref(device) for i in range(0, output_count): device = soundio.get_output_device(i) pydevice = _ctypes.cast(device, _ctypes.POINTER(SoundIoDevice)) output_devices.append({ 'id': pydevice.contents.id.decode(), 'name': pydevice.contents.name.decode(), 'is_raw': pydevice.contents.is_raw, 'is_default': default_output == i, 'sample_rates': self.get_sample_rates(device), 'formats': self.get_formats(device), 'layouts': self.get_layouts(device), 'software_latency_min': pydevice.contents.software_latency_min, 'software_latency_max': pydevice.contents.software_latency_max, 'software_latency_current': pydevice.contents.software_latency_current, 'probe_error': PySoundIoError(soundio.strerror(pydevice.contents.probe_error)) if pydevice.contents.probe_error else None }) soundio.device_unref(device) LOGGER.info('%d devices found' % (input_count + output_count)) return (input_devices, output_devices)
def tearDown(self): if self.device: soundio.device_unref(self.device) soundio.destroy()
def tearDown(self): if self.instream: soundio.instream_destroy() if self.device: soundio.device_unref(self.device) soundio.destroy()