Remove manual memory management throughout the SoundManager subsystem
in favor of unorderedmap.
Key changes:
- Eliminate manual new/delete calls and potential memory leaks
- Update all sound item classes to use SoundManager factory
- Modernize resource management in OggData and related components
- Ensure exception-safe memory handling across the audio pipeline
This refactoring improves code maintainability, reduces crash risk from
memory errors, and aligns with modern C++ best practices.
With C++20 the custom container PS:span, which was a backport of
std::span is no longer needed.
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Make include-what-you-use happy with some files in source and fix what
needs to be fixed.
Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Modernized COggData::FetchDataIntoBuffer and OggStream
interface:
- Replaced raw buffer pointer with std::vector<u8> in COggData
- Updated GetNextChunk to use PS::span<u8>
- Removed manual new/delete and memset usage
- Replaced long with ALsizei for m_Frequency to match OpenAL API
- Simplified type usage with size_t where appropriate
- Eliminated unnecessary casting and improved code clarity
These changes improve safety, readability, and bring the
code closer to modern C++ standards.
Replaced the raw C array for m_Buffer with std::array
to improve bounds safety and code clarity.
- Used .data() and .at() for buffer access
- Added check for bufferCount exceeding OGG_MAX_BUFFER_COUNT
- Left FetchDataIntoBuffer unchanged to avoid breaking external usage
(e.g. CStreamItem)
This refactor improves safety while keeping external API stable.
OggData now manages its own buffer size and count directly,
instead of relying on SoundManager to provide those values.
- Removed unused GetBufferCount() and GetBufferSize()
- Use default values for buffer size and count in OggData
- Documented buffer settings for clarity
This change centralizes control in OggData and improves encapsulation.
This commit renames ogg to m_OggStreamPtr for clarity and consistency
with naming conventions. Additionally, it moves the m_Format and
m_Frequency fields to the private section to ensure proper
encapsulation.
Local variables like pcmout have been renamed to PCMOut to match style
conventions, and all member fields now follow a consistent m_ prefix
style, placed at the end of the class definition for clarity.
These changes help improve code readability, enforce privacy, and align
with the rest of the codebase's naming standards.
This commit updates the OggData-related classes to use uniform brace
initialization ({}) for member variables where applicable. Brace
initialization improves clarity and prevents potential narrowing
conversions or unintended behavior caused by default constructor
ambiguity.
This change improves consistency and aligns with modern C++ best
practices, especially in C++11 and later where brace initialization is
recommended for safer initialization semantics.
The OggStream interface no longer needs the Close() method.
OpenOggNonstream returns a smart pointer (OggStreamPtr),
so resource cleanup is automatically handled by the destructor.
OggStreamImpl now calls ov_clear in its destructor, making
manual cleanup unnecessary. This commit removes the Close()
method from the interface and its implementation.
Avoid cases of filenames
Update years in terms and other legal(ish) documents
Don't update years in license headers, since change is not meaningful
Will add linter rule in seperate commit
Happy recompiling everyone!
Original Patch By: Nescio
Comment By: Gallaecio
Differential Revision: D2620
This was SVN commit r27786.
Fixes sound system to work with archives (use VFS files instead of
POSIX), fixes#1604.
Improves error handling and logging, refs #1594.
Allows sound to be disabled with -nosound/-quickstart runtime options or
--without-audio build option, fixes#1609, #1614.
Experimentally increases default buffer size to help prevent sound
stoppages.
This was SVN commit r12566.