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

Sounds: Various little improvements #12486

Merged
merged 2 commits into from
Jul 9, 2022
Merged

Conversation

SmallJoker
Copy link
Member

Nothing fancy; this turned out to be a minor code move/tidy.

  • Use SimpleSoundSpec where reasonable (OpenAL)
    • This ensures consistent sound information/parameters throughout the code
  • Ensure the sound IDs do not underflow or get overwritten -> loop in u16
  • Proper use of an enum.

To do

This PR is Ready for Review.

How to test

  1. Cart on power rails
  2. Drive. Jump in and out. the positional/attached sound must still work.

Use SimpleSoundSpec where reasonable (OpenAL)
Ensure the sound IDs do not underflow or get overwritten -> loop in u16
Proper use of an enum.
@SmallJoker SmallJoker added the Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements label Jun 28, 2022
@@ -379,6 +377,23 @@ class OpenALSoundManager: public ISoundManager
infostream << "Audio: Deinitialized." << std::endl;
}

u16 getFreeId() const
{
static thread_local u16 last_used_id = 0;
Copy link
Member

Choose a reason for hiding this comment

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

why a static thread_local? This feels more like a class member thing

Copy link
Member Author

@SmallJoker SmallJoker Jul 2, 2022

Choose a reason for hiding this comment

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

Recycled 1:1 from activeobjectmgr.h
EDIT: Like ActiveObjectMgr, this is a singleton, hence isolating the variable in this function will work as expected and not clutter the class members.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I think using class members is less of a code small, but I'm not too bothered about it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@rubenwardy
Copy link
Member

Oops, clicked the wrong button. Looks good apart from that though

@rubenwardy rubenwardy added Action / change needed Code still needs changes (PR) / more information requested (Issues) Sounds labels Jul 2, 2022
@rubenwardy rubenwardy added One approval ✅ ◻️ and removed Action / change needed Code still needs changes (PR) / more information requested (Issues) labels Jul 2, 2022
@SmallJoker SmallJoker merged commit e51f474 into minetest:master Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements One approval ✅ ◻️ Sounds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants