Commit graph

23 commits

Author SHA1 Message Date
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
5b5f678e3f
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.

Add markers to precompiled.h header includes to avoid
include-what-you-use wanting them to be removed.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-08-14 20:15:30 +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
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
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
Ralph Sennhauser
ad3f6e3119
Dissolve external_libraries/openal.h
This header was used to overcome macos openal vs openal-soft header name
difference, for the migration to openal 1.1 and to pass arguments to the
linker on windows in the past. None of this is used anymore so dissolve
the header.

Also fix related headers so one can run include-what-you-use on the
changed files.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-07-08 19:33:36 +02:00
trompetin17
0ebcc45237
Refactor GetNextChunk for clarity and safety
Replaces the for(;;) loop in GetNextChunk with a clearer while
(bytesRead < size) loop for better readability and intent.

Other improvements:
- Uses constexpr for constant audio format parameters
- Replaces C-style cast with reinterpret_cast
- Ensures consistent use of static_cast for type conversions
- Improves comment formatting

This refactor maintains the original logic while aligning with modern
C++ best practices.
2025-06-20 10:49:23 -05:00
trompetin17
0396d67d26
Apply consistent naming to member variables in ogg.cpp
Renames local variables in the class to follow the member naming
convention using the m_ prefix (e.g., m_Adapter, m_VF, m_FileEOF).
2025-06-20 10:49:16 -05:00
trompetin17
6b9652050c
Use std::copy_n in VorbisBufferAdapter::Read
Replaces a raw memcpy call with std::copy_n in VorbisBufferAdapter::Read
for improved type safety and readability. This ensures cleaner buffer
copying using standard C++ algorithms, avoiding manual pointer
arithmetic on void*.

The change is functionally equivalent but aligns better with modern
C++17 practices.
2025-06-20 09:04:09 -05:00
trompetin17
1d20adc3b9
Ensure brace initialization for member variables in Ogg classes
This commit updates the Ogg-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-06-20 09:04:01 -05:00
trompetin17
2ae95d3c49
Refactor OggStreamImpl to use exceptions for error handling
Introduce a new `Open` method in `OggStreamImpl` that encapsulates the
logic for opening Ogg Vorbis files. This method replaces the previous
`Open` method and utilizes `std::runtime_error` for error reporting
instead of returning error codes. The constructor has been updated to
call this new method, ensuring files are opened upon instantiation. The
changes streamline the code and improve error handling.
2025-06-20 08:51:39 -05:00
trompetin17
336ff333ed
Remove unused OpenOggStream method
OpenOggStream was previously used to stream Ogg files directly from the
file system. It operated on raw file paths (OsPath) and assumed
uncompressed, unarchived files, which made it unsuitable for working
with files inside archives or VFS layers.

However, its usage has been fully replaced by OpenOggNonstream, which:
- Reads the entire file into memory (non-streaming),
- Works with virtual file systems (VFS),
- Supports both archived and compressed assets,

Is already used consistently across debug and release builds.

There are no remaining references to OpenOggStream in the codebase, so
this commit removes the unused function and its associated logic.
2025-06-20 08:41:39 -05:00
scuti
a81c38bab9 Skip playing audio of corrupted files.
Prints a warning instead of crashing.

Fixes #7150
2024-12-26 16:14:38 +01: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
vladislavbelov
babfd913fb Adds std namespace to shared_ptr usages in gui and sound.
This was SVN commit r25526.
2021-05-22 19:23:03 +00:00
vladislavbelov
7a71011149 Refactors smart pointers creation, reduces code duplication and improves exception safety.
This was SVN commit r24915.
2021-02-13 23:53:40 +00:00
vladislavbelov
7790fd7d29 Removes duplication of Clamp function.
Reviewed By: wraitii
Commented By: Stan
Differential Revision: https://code.wildfiregames.com/D1763
This was SVN commit r23002.
2019-09-26 21:14:21 +00:00
stwf
2a3f1cb412 eliminate most warnings produced by Cppcheck
This was SVN commit r13356.
2013-04-12 03:10:54 +00:00
stwf
ed8746e798 remove log message
This was SVN commit r13210.
2013-03-01 14:23:28 +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
historic_bruno
df96445284 missing files from 89c8bccbde
This was SVN commit r12570.
2012-08-31 19:26:29 +00:00