Skip to content

fix(volume): handle mute status on absent audio device#415

Merged
amnweb merged 1 commit intoamnweb:mainfrom
feroesdahl:fix-crash-on-audio-device-absence
Aug 16, 2025
Merged

fix(volume): handle mute status on absent audio device#415
amnweb merged 1 commit intoamnweb:mainfrom
feroesdahl:fix-crash-on-audio-device-absence

Conversation

@feroesdahl
Copy link
Copy Markdown
Contributor

@feroesdahl feroesdahl commented Aug 13, 2025

Currently, the app can crash where no audio device is present. This also displays the "No Device" text again on missing audio device.

Commit with earlier fix:
da7d991

Commit introducing the bug:
e8aa058

Logs from crashes I have been having:

...
2025-08-10 21:42:22,933 [INFO] [MainThread] [root/log.py:59]: YASB v1.7.9
2025-08-10 21:42:22,934 [INFO] [Thread-1 (_run_server)] [cli_server/cli_server.py:212]: CLI server started v1.1.2
2025-08-10 21:42:22,934 [INFO] [MainThread] [cli_server/cli_server.py:104]: Log pipe server started
2025-08-10 21:42:23,084 [DEBUG] [MainThread] [comtypes/__init__.py:149]: CoInitializeEx(None, 2)
2025-08-10 21:42:23,472 [DEBUG] [MainThread] [tzlocal/win32.py:55]: Looking up time zone info from registry
2025-08-10 21:42:24,634 [INFO] [MainThread] [root/bar_manager.py:74]: Starting WindowsNotificationEventListener...
2025-08-10 21:42:24,635 [INFO] [MainThread] [root/watcher.py:54]: Created file watcher for path C:\Users\fero1\.config\yasb
2025-08-10 21:42:24,653 [DEBUG] [MainThread] [qasync._windows._EventPoller/_windows.py:213]: Starting (proactor: <_IocpProactor overlapped#=0 result#=0>)...
2025-08-10 21:42:24,653 [DEBUG] [Dummy-6] [qasync._windows._EventWorker/_windows.py:192]: Thread started
2025-08-10 21:48:14,661 [DEBUG] [MainThread] [qasync._windows._EventPoller/_windows.py:218]: Stopping worker thread...
2025-08-10 22:00:34,142 [INFO] [MainThread] [root/log.py:59]: YASB v1.7.9
2025-08-10 22:00:34,142 [INFO] [Thread-1 (_run_server)] [cli_server/cli_server.py:212]: CLI server started v1.1.2
2025-08-10 22:00:34,142 [INFO] [MainThread] [cli_server/cli_server.py:104]: Log pipe server started
2025-08-10 22:00:34,264 [DEBUG] [MainThread] [comtypes/__init__.py:149]: CoInitializeEx(None, 2)
2025-08-10 22:00:34,604 [DEBUG] [MainThread] [tzlocal/win32.py:55]: Looking up time zone info from registry
2025-08-10 22:00:35,373 [INFO] [MainThread] [root/bar_manager.py:74]: Starting WindowsNotificationEventListener...
2025-08-10 22:00:35,373 [INFO] [MainThread] [root/watcher.py:54]: Created file watcher for path C:\Users\fero1\.config\yasb
2025-08-10 22:00:35,388 [DEBUG] [MainThread] [qasync._windows._EventPoller/_windows.py:213]: Starting (proactor: <_IocpProactor overlapped#=0 result#=0>)...
2025-08-10 22:00:35,392 [DEBUG] [Dummy-6] [qasync._windows._EventWorker/_windows.py:192]: Thread started
2025-08-10 22:13:44,610 [DEBUG] [MainThread] [qasync._windows._EventPoller/_windows.py:218]: Stopping worker thread...
2025-08-10 22:13:44,622 [DEBUG] [Dummy-6] [qasync._windows._EventWorker/_windows.py:201]: Exiting thread
2025-08-10 22:13:44,622 [DEBUG] [MainThread] [qasync._windows._IocpProactor/_windows.py:75]: Closing
2025-08-11 18:32:40,210 [INFO] [MainThread] [root/log.py:59]: YASB v1.7.9
2025-08-11 18:32:40,210 [INFO] [Thread-1 (_run_server)] [cli_server/cli_server.py:212]: CLI server started v1.1.2
2025-08-11 18:32:40,210 [INFO] [MainThread] [cli_server/cli_server.py:104]: Log pipe server started
2025-08-11 18:32:40,265 [DEBUG] [MainThread] [comtypes/__init__.py:149]: CoInitializeEx(None, 2)
2025-08-11 18:32:40,368 [DEBUG] [MainThread] [tzlocal/win32.py:55]: Looking up time zone info from registry
2025-08-11 18:32:40,622 [INFO] [MainThread] [root/bar_manager.py:74]: Starting WindowsNotificationEventListener...
2025-08-11 18:32:40,625 [INFO] [MainThread] [root/watcher.py:54]: Created file watcher for path C:\Users\fero1\.config\yasb
2025-08-11 18:32:40,642 [DEBUG] [MainThread] [qasync._windows._EventPoller/_windows.py:213]: Starting (proactor: <_IocpProactor overlapped#=0 result#=0>)...
2025-08-11 18:32:40,642 [DEBUG] [Dummy-6] [qasync._windows._EventWorker/_windows.py:192]: Thread started
2025-08-11 19:34:28,666 [ERROR] [MainThread] [root/volume.py:559]: Failed to initialize volume interface: (-2147023728, 'Element not found.', (None, None, None, 0, None))
2025-08-11 19:34:28,668 [ERROR] [MainThread] [root/main.py:101]: Unhandled exception
Traceback (most recent call last):
  File "D:\a\yasb\yasb\src\core\widgets\yasb\volume.py", line 462, in _update_label
UnboundLocalError: cannot access local variable 'mute_status' where it is not associated with a value
2025-08-11 20:58:07,275 [INFO] [MainThread] [root/log.py:59]: YASB v1.7.9
2025-08-11 20:58:07,276 [INFO] [Thread-1 (_run_server)] [cli_server/cli_server.py:212]: CLI server started v1.1.2
2025-08-11 20:58:07,276 [INFO] [MainThread] [cli_server/cli_server.py:104]: Log pipe server started
2025-08-11 20:58:07,419 [DEBUG] [MainThread] [comtypes/__init__.py:149]: CoInitializeEx(None, 2)
2025-08-11 20:58:07,808 [DEBUG] [MainThread] [tzlocal/win32.py:55]: Looking up time zone info from registry
2025-08-11 20:58:09,012 [INFO] [MainThread] [root/bar_manager.py:74]: Starting WindowsNotificationEventListener...
2025-08-11 20:58:09,013 [INFO] [MainThread] [root/watcher.py:54]: Created file watcher for path C:\Users\fero1\.config\yasb
2025-08-11 20:58:09,031 [DEBUG] [MainThread] [qasync._windows._EventPoller/_windows.py:213]: Starting (proactor: <_IocpProactor overlapped#=0 result#=0>)...
2025-08-11 20:58:09,031 [DEBUG] [Dummy-6] [qasync._windows._EventWorker/_windows.py:192]: Thread started
2025-08-11 21:16:54,237 [ERROR] [MainThread] [root/volume.py:559]: Failed to initialize volume interface: (-2147023728, 'Element not found.', (None, None, None, 0, None))
2025-08-11 21:16:54,238 [ERROR] [MainThread] [root/main.py:101]: Unhandled exception
Traceback (most recent call last):
  File "D:\a\yasb\yasb\src\core\widgets\yasb\volume.py", line 462, in _update_label
UnboundLocalError: cannot access local variable 'mute_status' where it is not associated with a value
2025-08-12 19:00:33,350 [INFO] [MainThread] [root/log.py:59]: YASB v1.7.9
2025-08-12 19:00:33,350 [INFO] [Thread-1 (_run_server)] [cli_server/cli_server.py:212]: CLI server started v1.1.2
2025-08-12 19:00:33,350 [INFO] [MainThread] [cli_server/cli_server.py:104]: Log pipe server started
2025-08-12 19:00:33,404 [DEBUG] [MainThread] [comtypes/__init__.py:149]: CoInitializeEx(None, 2)
...

Currently, the app can crash where no audio device is present. This also
displays the "No Device" text again on missing audio device.

Commit with earlier fix:
da7d991
Commit introducing the bug:
e8aa058
@amnweb
Copy link
Copy Markdown
Owner

amnweb commented Aug 16, 2025

Thanks, I forgot to test for the case when there's no audio device available.

@amnweb amnweb merged commit 2d5ddbe into amnweb:main Aug 16, 2025
Kepners pushed a commit to Kepners/yasb that referenced this pull request Feb 4, 2026
…ce-absence

fix(volume): handle mute status on absent audio device
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants