Commit graph

32 commits

Author SHA1 Message Date
phosit
e2ed4afe00
SoundManager: reintroduce manual memory management
This reverts commit 94c907342a.

It introduced multiple errors and is to big to find the actual errors.

Fixes: #8342
Fixes: #8426
2025-10-13 20:42:32 +02:00
trompetin17
94c907342a
SoundManager: Replace manual memory with unorderedmap
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.
2025-08-25 09:45:14 -05:00
Ralph Sennhauser
2cedb48de2
Remove custom span and use std::span
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>
2025-08-24 11:09:57 +02:00
Ralph Sennhauser
3647921bed
Fix some includes all over the place
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>
2025-08-13 19:38:21 +02:00
trompetin17
8ed40553c8
Update SetFormatAndFreq method to use ALenum type in format parameter 2025-07-22 08:41:03 -05:00
trompetin17
000304a402
Rename m_BuffersUsed to m_BuffersCount for consistency in COggData class 2025-07-22 08:41:02 -05:00
trompetin17
c40aada404
Rename atFileEOF to AtFileEOF for consistency in Ogg classes 2025-07-22 08:41:01 -05:00
trompetin17
586d02838a
Refactor Ogg buffer logic to use span and vector
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.
2025-07-22 08:41:00 -05:00
trompetin17
325bedcf3f
Use std::array for OggData buffer handling
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.
2025-07-22 08:41:00 -05:00
trompetin17
21f26455f5
Decouple buffer config from SoundManager
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.
2025-07-22 08:40:59 -05:00
trompetin17
95fc9bd2ed
Standardize OggData fields and variable naming
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.
2025-07-22 08:40:58 -05:00
trompetin17
e95829494c
Ensure brace initialization variables in OggData
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.
2025-07-22 08:40:57 -05:00
trompetin17
e97292430d
Remove manual Close method from OggStream
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.
2025-07-22 08:40:48 -05:00
vladislavbelov
ffc4a56b9f Revert non-ASCII characters from source and configuration files introduced in 157c6af18e.
Fixes #6846

Differential Revision: https://code.wildfiregames.com/D5185
This was SVN commit r27965.
2023-12-03 00:30:12 +00:00
bb
157c6af18e Make the space in 0 A.D. non-breaking throughout the codebase.
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.
2023-07-27 20:54:46 +00:00
elexis
417c84870c Actually remove trailing tabs from source/.
This was SVN commit r18991.
2016-11-23 14:09:58 +00:00
elexis
6149dd3841 Actually remove trailing whitespace for non-header files as well.
This was SVN commit r18989.
2016-11-23 13:02:58 +00:00
leper
ec7c8f2d65 Move gain config setting retrieval to the sound manager. Fixes #3030.
Also clean up the sound manager a bit.

This was SVN commit r16257.
2015-02-02 13:44:06 +00:00
Ykkrosh
e9a33b71ae Manually fix the less trivial CLogger format strings.
This was SVN commit r16184.
2015-01-22 20:32:06 +00:00
sanderd17
006bf42809 Fix segmentation fault in the sound destructor. Happened when the sound file doesn't exist. Errors are shown by other code.
This was SVN commit r15437.
2014-06-24 11:07:39 +00:00
stwf
ada7702bec add UI sound channel, clean up external interface and javascript calls
This was SVN commit r13467.
2013-06-10 13:58:43 +00:00
stwf
004eaf9e75 log warning when stereo sounds are played at position
This was SVN commit r13442.
2013-06-01 01:52:05 +00:00
stwf
503b481468 handle initialization errors cleanly, clean stuff up
This was SVN commit r13359.
2013-04-18 03:24:20 +00:00
stwf
2a3f1cb412 eliminate most warnings produced by Cppcheck
This was SVN commit r13356.
2013-04-12 03:10:54 +00:00
stwf
e4a9312c46 newest soundmanager patch, should give better battle sequences, and handle low resource situations correctly.
This was SVN commit r13209.
2013-03-01 14:22:28 +00:00
stwf
1fce30839f zero out buffers before loading sounds
This was SVN commit r12639.
2012-09-08 02:54:49 +00:00
stwf
df0c4559ad silence repeated errors when buffers don't allocate, fix up reference counting
This was SVN commit r12638.
2012-09-07 12:05:29 +00:00
stwf
a6e1e6cec7 report errors opening sound files and hopefully revcover from them gracefully
This was SVN commit r12591.
2012-09-01 23:24:32 +00:00
historic_bruno
d45a044445 Cleans up rogue printf
This was SVN commit r12587.
2012-09-01 22:16:53 +00:00
leper
ccdb67c8f2 Fix non-pch build.
This was SVN commit r12586.
2012-09-01 22:12:28 +00:00
historic_bruno
89c8bccbde Sound system patch by stwf:
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.
2012-08-31 19:08:41 +00:00
historic_bruno
011ba8255e New sound system implementation by stwf, refs #1223, #961.
Enables audio on OS X, refs #685, #931.
Fixes music not playing after a game, refs #946.

This was SVN commit r12428.
2012-08-15 00:10:44 +00:00