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

Allow passing PCM data as slices instead of Vec #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

revmischa
Copy link
Contributor

@revmischa revmischa commented Nov 3, 2024

ChatGPT recommended using slices because we can avoid extra allocations and ownership transfer when adding PCM data.

  1. Parameter Type:
    • Changed the samples parameter from Vec to &[f32] in both the public and internal methods. This allows you to pass a slice directly without allocating a new Vec.
  2. Ownership:
    • Since slices are borrowed references, there’s no ownership transfer, which is more efficient.
  3. Usage of as_ptr():
    • Slices can still provide a raw pointer using .as_ptr(), so the FFI call remains unchanged.

Might be a breaking change though, if we care

@murl-digital
Copy link

It shouldn't be a breaking change, vecs are borrowed as slices automatically in most cases.

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