-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
update documentation on AudioSink #9332
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What does "unchanged" mean? When it's already playing, or when it was playing but paused in the middle?
Why does this happen? Shouldn't the audio stop? Isn't this a bug? Is a new AudioSink re-added?
Does it also happen if there is no
PlaybackSettings
on this entity, what about ifPlaybackSettings::paused
istrue
?To be honest I'm not sure why the API is this way, I feel like to be consistent with most other Bevy APIs the
AudioSink
should be part ofAudioSourceBundle
not added after, and no audio would be played if an entity doesn't have all the components ofAudioSourceBundle
includingAudioSink
, but there's maybe something I don't know/am missing.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.
AudioSink
is created by the audio engine dynamically. This may be a bug, but it's difficult to change, and it's genuinely useful. There's a discussion on the Discord about this in the #audio-dev channel (Reproducer and following discussion: https://canary.discord.com/channels/691052431525675048/749430447326625812/1135716276132642878).If the
AudioSource
that was used to start the audio hasn't been removed, and theAudioSink
is removed, it's recreated from the sameAudioSource
, thus being an extremely easy way to restart music. Likewise, if the source is swapped out for another one, this provides a clean way to swap from one song to another instantly.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.
It makes sense that that's what's happening.
That's a personal opinion and a bit out of scope for this PR but this API (if it's intended to have to remove the
AudioSink
to restart an audio track or switch track) feels kinda hacky to me.I would expect:
AudioSink
to be added inAudioSourceBundle
andplay_queued_audio_system
would query newly-addedAudioSink
, orplay_queued_audio_system
would createAudioSink
only for newly addedHandle<Source>
andPlaybackSettings
,Handle<Source>
to recreate theAudioSink
if the track changedAudioSink
orPlaybackSettings
would allow the track to restart,PlaybackSettings
is deleted whenAudioSink
is created, or that modifying its fields after would effectively do somethingThere might be a very good reason for most of it though like not having a one-frame lag in the changes or something.
Anyway, for this PR, I think this comment should clearly mention what's happening, something like:
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.
The idea is not to explain the implementation details but to explain the effect of them; other parts of the documentation don't explain why the engine does what it does with certain things, so why should this?
Also, the more I think about it, the more natural this API feels. It's odd, but not as odd as it could be.
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 think when components are added/removed from entities automatically should be documented.
I'm not saying it should be mentioned in the doc of
AudioBundle
for example, but this is the doc of this component, how it behaves is important.