-
Notifications
You must be signed in to change notification settings - Fork 223
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
Configurable buffer size #512
base: master
Are you sure you want to change the base?
Conversation
Incompatible API change.
THe idea was to add a new function.
sample_format: &SampleFormat, | ||
) -> Result<(Self, OutputStreamHandle), StreamError> { | ||
let (mixer, _stream) = device.try_new_output_stream(&config, &sample_format)?; | ||
_stream.play()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a maintainer, but one of the users of rodio, though, what a wonderful pull request!!!
I had the opposite of your case, a problem with regeneration due to lack of buffer, but thanks to you I was able to solve it.
One thing I noticed is that this _stream.play()?
is necessary?
_stream.play()?; |
I removed it and tried it (in this fork), but it works without any problems and the time it takes has become shorter.
Correction, it worked fine on macos and Linux, but on Windows it would not play without this code. Sorry for the accusation.
If you don't mind, I would be glad to know why this line is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried to follow existing patterns, and make minimal changes to pass the new parameter to the point where the stream is initialized. For example, I do not like underscored names there, since normally that indicates unused variable, but kept it to mimic existing style :) Other similar functions also use open()
after initialization. See for example stream::try_from_device_config(...)
.
It looks like what play()
does depends on the platform/back-end implementation. The trait containing it is part of cpal
library. The declaration doc says
Note: Not all platforms automatically run the stream upon creation, so it is important to call
play
after creation if it is expected that the stream should run immediately.
Just to give you all an update, configurable buffer size will be merged one day. Its just that I have my plate full atm and want to do as many breaking changes at once, such that I can write a porting/update guide and do an announcement on the various platforms. Before I do that I want to overhaul
And that will take a while once I have the time or someone else pitches in. Therefore thanks @PetrGlad for this PR, I suggest anyone who urgently needs this change to rely on their fork or this PR for now. |
@PetrGlad I've been listing all the breaking changes planned. What is your opinion on replacing all the |
@dvdsk Yes, this looks to me like a good idea, especially if the builder instance can be copied/passed around. In my case I was happy with the defaults and only wanted to change the buffer size. In that case a builder can help setting the defaults. Maybe the builder should have methods that can provide replacements for let conf_builder = rodio::OutputConfigBuilder::from(cpal_suported_config)
.buffer_size(13);
let output = rodio::OutputStream::open(conf_builder); or let conf = rodio::OutputConfigBuilder::from(cpal_suported_config)
.buffer_size(13)
.build();
let output = rodio::OutputStream::open(conf); Another option could be to add all possible options to some config struct in |
I needed to configure smaller buffer size to reduce playback delays (for a MIDI/VST application), and could not find a better way than to patch
rodio
. Notes:The version from this patch works for me. I am willing to rework the request if there is a better idea how to do this.