Skip to content

ALAudioRenderer: code improvements #2423

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

Merged
merged 15 commits into from
May 18, 2025

Conversation

capdevon
Copy link
Contributor

@capdevon capdevon commented May 4, 2025

WIP: Not ready for review.

After studying the OpenAL API, this PR introduces small tweaks to make the code clearer and easier to understand.

Changes:

  • Error Checking: Added more consistent checkAlError calls after relevant OpenAL operations.
  • Initialization/Cleanup: Improved error handling and resource cleanup in initOpenAL, initEfx, and destroyOpenAL.
  • Device Handling: Added logic to handle device disconnection and renderer restart. (Note: restartAudioRenderer is currently missing Environment and Listener settings handling).
  • Comments and Logging: Added/updated comments and improved logging messages.

capdevon added 7 commits May 4, 2025 13:16
- remove recursive calls to updateSourceParam() method
- more checkAlError
- added helper methods
- added comments
- javadoc
- fix Destroys the OpenAL context, deleting sources, buffers, filters, and effects.
@yaRnMcDonuts yaRnMcDonuts added this to the v3.9.0 milestone May 6, 2025
@capdevon
Copy link
Contributor Author

capdevon commented May 8, 2025

Hi guys,
good news! The PR is finished and ready to be merged. For anyone reviewing, I recommend taking a quick look at the OpenAL documentation. Some of the function logic and design decisions might seem unusual at first glance, but they're often dictated by the OpenAL library itself.

@yaRnMcDonuts

capdevon added 4 commits May 10, 2025 01:22
You should consider using ArrayDeque when:

You need a collection that efficiently supports adding and removing elements from both ends. This makes it ideal for implementing data structures like queues and stacks.
You frequently perform removals from the beginning of the collection.
see ALAudioRenderer.newChannel() and ALAudioRenderer.freeChannel()
removes the repeated call to the `checkAlError` method. The repeated string creation and the associated overhead of the error checking can negatively impact performance, especially in a frequently executed game loop. By removing this redundant check, we aim to improve overall performance and reduce garbage collection pressure.
@yaRnMcDonuts
Copy link
Member

I'll merge this in ~24 hours

@yaRnMcDonuts yaRnMcDonuts merged commit 0925f98 into jMonkeyEngine:master May 18, 2025
16 checks passed
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