Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Extract platform dependent code out of Skill #76

Open
wants to merge 5 commits into
base: 21.02
Choose a base branch
from

Conversation

krisgesling
Copy link
Contributor

Description

Currently the Volume Skill has lots of ALSA specific code embedded in it. I took a stab at starting to extract out the platform dependent code. The intention is that this code will be moved to the Hardware Abstraction Layer (HAL) - formerly known as "enclosure" but there are way too many things that are "enclosures".

For the moment, I've created a little HAL "emulator" in the Skill that should only be interacted with via the bus. Once the real HAL interface is ready we should be able to delete the module from the Skill and the rest will continue to function as normal.

Interested in any thoughts on this approach before I bother going too far, so opening a work-in-progress PR.

Most recently raised in MycroftAI/enclosure-picroft#153

Type of PR

  • Bugfix
  • Feature implementation
  • Refactor of code (without functional changes)
  • Documentation improvements
  • Test improvements

Testing

  • Set the volume
  • Decrease / increase the volume

Documentation

Docstrings included

CLA

  • Yes

# Instantiate the HAL emulator
self.platform = self.config_core['enclosure'].get('platform', 'unknown')
if self.platform in ALSA_PLATFORMS:
self.HAL = HALFactory.create('ALSA', self.settings)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pardon the intrusion, especially for a kind of style comment, it's not very important, I'm kind of wondering why this doesn't read

`self.HAL = HALFactory.create(self.platform, self.settings)`

And let "create" decide what to return rather than needing to switch on platform here (given that it's a HAL).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even self.HAL = HALFactory.create(self.config_core, self.settings)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No intrusion at all - glad to have more eyes on it.

You're totally right here too - I'm thinking passing in the self.platform should be sufficient for now.

I expect that this will change when it moves to the real HAL service, as each HAL plugin will either select their audio output service or provide their own methods that meet a minimum spec.

@krisgesling
Copy link
Contributor Author

Tip from sgee in chat:
https://pypi.org/project/pulsectl/

Just dropping it here to come back to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Work in progress by author
Development

Successfully merging this pull request may close these issues.

2 participants