-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(audio): add a recovery mechanism for audio service to rebind the …
…sound card if it is not available - closes #83
- Loading branch information
Showing
7 changed files
with
106 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "ubo-app" | ||
version = "0.15.5" | ||
version = "0.15.6" | ||
description = "Ubo main app, running on device initialization. A platform for running other apps." | ||
authors = ["Sassan Haradji <[email protected]>"] | ||
license = "Apache-2.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""handle audio commands.""" | ||
|
||
from __future__ import annotations | ||
|
||
import time | ||
from pathlib import Path | ||
|
||
from ubo_app.logging import get_logger | ||
|
||
DEVICE = '1-001a' | ||
DRIVER_PATH = Path('/sys/bus/i2c/drivers/wm8960') | ||
|
||
|
||
logger = get_logger('system-manager') | ||
|
||
|
||
def audio_handler(command: str) -> str | None: | ||
"""Install and start Docker on the host machine.""" | ||
if command == 'failure_report': | ||
logger.info('Audio failure report received, rebinding device...') | ||
try: | ||
(DRIVER_PATH / 'unbind').write_text(DEVICE) | ||
time.sleep(1) | ||
(DRIVER_PATH / 'bind').write_text(DEVICE) | ||
except Exception as e: | ||
logger.exception('Error rebinding device', exc_info=e) | ||
return 'error' | ||
else: | ||
logger.info('Device has been rebound.') | ||
return 'done' | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters