Skip to content

Conversation

@PetrGlad
Copy link
Collaborator

@PetrGlad PetrGlad commented Nov 15, 2024

This is a breaking change.

Resolves PR#512 and #613
This pull request may be related #547

  • Use a builder pattern to configure output stream.
  • Make root mixer available to users.
  • Rename some of the creation methods.
  • Try alternative configurations when opening default stream.
  • ....

Still missing:

  • Examples that demonstrate custom stream configuration.
  • Update rustdocs in lib.rs

pub sample_rate: SampleRate,
pub buffer_size: BufferSize,
pub sample_format: SampleFormat,
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This can be a part of the builder, but I wanted to give users an option co copy/store/modify it if they prefer, so the builder becomes only an optional convenience.

Copy link
Member

Choose a reason for hiding this comment

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

I would not make it pub. If we make it pub we can never change the fields or add one without it being a breaking change. By using the builder we are free to add more in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The motivation of making this a separate struct, was to let users to pass it around or keep it in configs somewhere, for example. Yes, there is no problem to not publish it just yet.

Copy link
Member

@yara-blue yara-blue Nov 20, 2024

Choose a reason for hiding this comment

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

If I understand correctly OutputStreamConfig is public to allow users to skip using the builder a second time.

One of the big advantages to builders is that we can expand them over time without that being a breaking change.

My advice is to remove OutputStreamBuilder completely from the public API. Users wanting to abstract away the builder can still do that in their own project.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Usually I prefer plain data if possible. But in this case I have allowed this option (to use the config directly) just to cover all the cases. But since no one actually requested this, I do not object hiding the struct.

Updated.

Copy link
Member

Choose a reason for hiding this comment

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

OutputStreamBuilder fields no longer need to be public (it compiles with pub removed).

Sorry I would apply the change to the PR myself but its such a chore to set that up. Ill see if I can automate that better on my side so its no longer a problem in the future.

Copy link
Member

Choose a reason for hiding this comment

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

you know what ill fix it post merge, cause this is all ready to go! 🥳

@PetrGlad
Copy link
Collaborator Author

PetrGlad commented Nov 15, 2024

It looks like those "missing documentation" errors do not show up when building with stable toolchain :

rustup default stable
cargo test --all-targets

Using beta or nightly does show them.

@yara-blue yara-blue added the breaking Proposed change that would break the public API label Nov 18, 2024
@yara-blue
Copy link
Member

I have not done a full review (given its still a draft) but looked through it quickly and tried to address all the comments you made. What I see looks great though 🥳 ! It is clear you carefully considered your choices. Thank you very much for all the work.

Ill be careful not to create any merge conflicts. Given how big this PR is ill stay away from making larger changes till this has landed.

@PetrGlad
Copy link
Collaborator Author

PetrGlad commented Nov 18, 2024

@dvdsk I have added dome docs, so in this form I'd say it is complete. The biggest reason I titled it as a draft was that more API changes would be considered necessary.

@PetrGlad PetrGlad changed the title Draft: Use builder to init output stream Use builder to init output stream Nov 18, 2024
@yara-blue
Copy link
Member

yara-blue commented Nov 20, 2024

Only thing I still have a problem with is the OutputStreamConfig being public. I would still prefer another name for that one open function (see discussion) but we can merge that as is.

We do still need a changelog entry (see CHANGELOG.md) and ideally we should add a porting_guide.md given this is a breaking change. Could you make those or shall I get on that post merge?

@PetrGlad
Copy link
Collaborator Author

I have added a custom config example (doubles as a test for the builder).

@PetrGlad
Copy link
Collaborator Author

PetrGlad commented Nov 21, 2024

@dvdsk Updated, please have a look.

@yara-blue
Copy link
Member

This now also resolves: #643

@yara-blue yara-blue merged commit c1d2230 into RustAudio:master Nov 24, 2024
@yara-blue
Copy link
Member

Thanks a lot for all the hard work Petr. This has really improved the API 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Proposed change that would break the public API enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants