Skip to content

Conversation

@roderickvd
Copy link
Contributor

@roderickvd roderickvd commented Sep 7, 2025

This PR adds completes getter and setter methods for buffer and period parameters to the HwParams implementation, including all _near setters.

Added

Period Time Methods:

  • get_period_time(&self) -> Result<u32>
  • get_period_time_min(&self) -> Result<u32>
  • get_period_time_max(&self) -> Result<u32>
  • set_period_time(&self, v: u32, dir: ValueOr) -> Result<()>
  • set_period_time_min(&self, v: u32, dir: ValueOr) -> Result<u32>
  • set_period_time_max(&self, v: u32, dir: ValueOr) -> Result<u32>

Period Size Methods:

  • set_period_size_min(&self, v: Frames, dir: ValueOr) -> Result<Frames>
  • set_period_size_max(&self, v: Frames, dir: ValueOr) -> Result<Frames>

Periods Methods:

  • get_periods_min(&self) -> Result<u32>
  • get_periods_max(&self) -> Result<u32>
  • set_periods_near(&self, v: u32, dir: ValueOr) -> Result<u32>
  • set_periods_min(&self, v: u32, dir: ValueOr) -> Result<u32>
  • set_periods_max(&self, v: u32, dir: ValueOr) -> Result<u32>

Buffer Time Methods:

  • get_buffer_time(&self) -> Result<u32>
  • set_buffer_time(&self, v: u32, dir: ValueOr) -> Result<()>
  • set_buffer_time_min(&self, v: u32, dir: ValueOr) -> Result<u32>
  • set_buffer_time_max(&self, v: u32, dir: ValueOr) -> Result<u32>

Use Case

These methods provide complete hardware parameter introspection and configuration capabilities, essential for:

  • Finding nearest supported values when exact values aren't supported (_near methods)
  • Querying full range of supported hardware parameter constraints (_min/_max getters)
  • Setting precise buffer and period configurations with constraint boundaries
  • Building adaptive audio applications that can work optimally with diverse hardware capabilities
  • Advanced audio buffer management and latency optimization
  • Debugging and logging complete hardware parameter constraints

I'm currently working on improving the buffer and period size configuration in cpal, and this comprehensive parameter API is desired to properly query hardware constraints and select optimal configurations for different audio devices.

@roderickvd
Copy link
Contributor Author

roderickvd commented Sep 7, 2025

Real changes are in b4a4a31 and fbae5d4. Style changes in 93e265e are just the result of cargo fmt.

@roderickvd roderickvd changed the title feat: add get_periods_min and get_periods_max methods to HwParams feat: comprehensive buffer and period parameter methods Sep 7, 2025
@diwic
Copy link
Owner

diwic commented Sep 18, 2025

Hi,

"Format code with rustfmt" part is NAK, the other two looks good.
Can you resubmit the two remaining patches without the rustfmt part?

Thanks.

@roderickvd
Copy link
Contributor Author

"Format code with rustfmt" part is NAK, the other two looks good. Can you resubmit the two remaining patches without the rustfmt part?

Reverted that. Let me know if you want me to squash.

@diwic diwic merged commit 50805d9 into diwic:master Sep 22, 2025
1 check passed
@diwic
Copy link
Owner

diwic commented Sep 22, 2025

Thanks! I let github squash it. :-)

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