Skip to content

Commit

Permalink
Add error message for encoding error (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
chidiwilliams committed Dec 11, 2022
1 parent 47ddb4a commit bdbab0f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions buzz/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ def __init__(self, parent: Optional[QWidget] = None, *args) -> None:
self.setCurrentIndex(default_device_index)

def get_audio_devices(self) -> List[Tuple[int, str]]:
devices: sounddevice.DeviceList = sounddevice.query_devices()
input_devices = filter(
lambda device: device.get('max_input_channels') > 0, devices)
return list(map(lambda device: (device.get('index'), device.get('name')), input_devices))
try:
devices: sounddevice.DeviceList = sounddevice.query_devices()
input_devices = filter(
lambda device: device.get('max_input_channels') > 0, devices)
return list(map(lambda device: (device.get('index'), device.get('name')), input_devices))
except UnicodeDecodeError:
QMessageBox.critical(
self, '', 'An error occured while loading your audio devices. Please check the application logs for more information.')
return []

def on_index_changed(self, index: int):
self.device_changed.emit(self.audio_devices[index][0])
Expand Down

0 comments on commit bdbab0f

Please sign in to comment.