Skip to content

Comments

Preallocate buffers#8

Merged
OpenSauce merged 8 commits intomainfrom
preallocate-buffers
May 24, 2025
Merged

Preallocate buffers#8
OpenSauce merged 8 commits intomainfrom
preallocate-buffers

Conversation

@OpenSauce
Copy link
Owner

  • Pre-allocate downsampler and upsampler buffers, use process_into_buffer
  • Handle errors correctly
  • Simplify the JACK ProcessHandler typing

Copilot AI review requested due to automatic review settings May 24, 2025 23:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR preallocates buffers for the upsampler and downsampler, updates error messages for improved consistency, and simplifies the JACK ProcessHandler implementation.

  • Preallocation of input, upsampled, and downsampled buffers using process_into_buffer
  • Standardization of error message capitalization
  • Simplification of processor creation and async client activation

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/main.rs Updated error messages and context strings for consistency
src/io/processor.rs Refactored port registration, buffer preallocation, and error handling; fixed typos in error messages and comments
src/io/manager.rs Updated processor initialization and async client activation

OpenSauce and others added 3 commits May 25, 2025 00:05
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@OpenSauce OpenSauce requested a review from Copilot May 24, 2025 23:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Refactors the audio processing setup by preallocating buffers, improving error handling, and simplifying the JACK process handler implementation.

  • Switches to process_into_buffer and preallocates input, upsampled, and downsampled buffers in Processor
  • Implements ProcessHandler trait directly and adds a buffer_size callback to manage dynamic buffer sizes
  • Normalizes error contexts and messages to use consistent lowercase prefixes

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main.rs Lowercased error and context messages for consistency
src/io/processor.rs Refactored Processor::new, added preallocated buffers, and replaced process calls with process_into_buffer
src/io/manager.rs Activated JACK client with Processor directly and normalized error contexts
Comments suppressed due to low confidence (2)

src/main.rs:56

  • [nitpick] Error messages are conventionally capitalized; consider starting this message with an uppercase letter for consistency, e.g., "Environment variable '{}' must be set.".
Err(_) => anyhow::bail!("environment variable '{}' must be set.", key),

src/io/processor.rs:128

  • Using debug_assert! means this capacity check is disabled in release builds. Consider using a regular assert! or proactively resizing buffers to avoid potential runtime issues in production.
debug_assert!(self.input_buffer[0].capacity() >= n_frames,

@OpenSauce OpenSauce requested a review from Copilot May 24, 2025 23:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors audio processing to use pre-allocated buffers and simplifies error handling and JACK integration.

  • Pre-allocate and reuse input, upsampled, and downsampled buffers via process_into_buffer.
  • Standardize error contexts and messages to use anyhow::Context.
  • Simplify JACK ProcessHandler implementation by implementing the trait directly on Processor.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main.rs Lowercase error messages and update context strings for consistency
src/io/processor.rs Pre-allocate DSP buffers, switch to process_into_buffer, implement ProcessHandler
src/io/manager.rs Simplify ProcessorManager by using Processor directly in activate_async
Comments suppressed due to low confidence (5)

src/main.rs:56

  • [nitpick] Error messages should follow a consistent style. Consider capitalizing the first letter to match other messages, e.g., Environment variable '{}' must be set.
Err(_) => anyhow::bail!("environment variable '{}' must be set.", key),

src/main.rs:61

  • [nitpick] Context messages should start with a capital letter for consistency, e.g., Failed to create ProcessorManager.
ProcessorManager::new().context("failed to create ProcessorManager");

src/main.rs:68

  • [nitpick] Consider capitalizing the context message: Failed to enable recording in '{}'.
.with_context(|| format!("failed to enable recording in '{}'", args.recording_dir))?;

src/main.rs:80

  • [nitpick] For consistency, capitalize the expect message: Error setting Ctrl+C handler.
.expect("error setting Ctrl+C handler");

src/io/manager.rs:27

  • [nitpick] Align with other messages by capitalizing the start: Failed to create JACK client.
.context("failed to create JACK client")?;

@OpenSauce OpenSauce requested a review from Copilot May 24, 2025 23:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR preallocates buffers for the upsampler and downsampler, improves error message handling, and simplifies the JACK ProcessHandler typing.

  • Preallocate reusable buffers for up/down sampling in the processor.
  • Update error messages for more uniform styling.
  • Simplify ProcessHandler by directly implementing the trait.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/main.rs Lowercase error messages for consistency and minor style changes.
src/io/processor.rs Refactored Processor creation and ProcessHandler implementation with preallocated buffers.
src/io/manager.rs Updated error message text and ProcessHandler integration.
Comments suppressed due to low confidence (1)

src/main.rs:56

  • [nitpick] Consider confirming that the use of lowercase in error messages is intentional and consistent with your project’s style, as other parts of the codebase might use different capitalization.
Err(_) => anyhow::bail("environment variable '{}' must be set.", key),

@OpenSauce OpenSauce merged commit e2a2cb8 into main May 24, 2025
1 check passed
@OpenSauce OpenSauce deleted the preallocate-buffers branch December 6, 2025 20:26
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.

1 participant