128 Commits
Author SHA1 Message Date
Goober5000andClaude Opus 4.6 3f85d6172a use std::move() for local variables that are copied but not reused (#7308)
* use std::move() for local variables that are copied but not reused

Addresses ~140 Coverity "Variable copied when it could be moved"
defects across 74 files.  Every std::move() targets a local variable
whose value is consumed by push_back, emplace, assignment, lambda
capture, or a function call and is never read again afterward.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* clang: use std::make_shared

* clang: use std::make_unique

* address feedback

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-07 14:40:38 +09:00
Goober5000andClaude Opus 4.6 fa86575606 Suppress Coverity GLOBAL_INIT_ORDER false positives for safe globals
Add coverity[GLOBAL_INIT_ORDER] annotations to ~50 global variables
across 27 files. These were all analyzed and confirmed safe:

- ~48 OptionBuilder::finish() globals use a Meyers singleton
  (OptionsManager::instance()), which guarantees safe init order.
  Destruction is also safe due to shared_ptr ref-counting.
- 6 default-constructed container globals (vectors, maps) have no
  cross-TU dependencies at construction or destruction time.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-03-22 15:00:25 -04:00
Goober5000 3d68bf2c7a goto considered useful
The `continue` statement in these error checks had no effect because the error checks are macros implemented in a `do` ... `while (false)` loop.  So, use `goto`.  There is precedent with other instances of `OpenAL_ErrorCheck` in the code.

This may fix the issue where sound would occasionally randomly stop, requiring a pause or a screen change to get it back.  This would be difficult to verify though.

Thanks to Coverity for flagging this situation!
2025-05-08 02:50:29 -04:00
John Fernandez a7fc64389f Use the correct method to get index to Sounds
Our sound code is extremely confusing, so it's no wonder that the author of these functions could not find snd_get_sound_id.
2024-07-05 00:44:29 -04:00
Mike Nelson 7fdcd4abc7 Basic implementation of some audio options in-game (#5927)
* Basic implementation of some audio options in-game

* Unused param

* do localization
2024-03-24 21:46:02 -04:00
Goober5000 f4669db41c constify some turret code
Apply `const` to a whole bunch of functions.  Also change a bunch of ints to bools.
2023-12-30 00:00:31 -05:00
mjn-mixael 5d6c34c2ab Upgrade lua sound handle with pause/resume methods and channel selection 2023-10-25 08:31:06 -05:00
Mike Nelson ad27664ebc Pause and Resume voices (#5636)
* pause and resume voices

* Use newer styling rather than the sound.cpp styling
2023-10-21 10:23:53 -04:00
Taylor Richards 072e1123d9 avoid playing voice messages with aux effects (EFX) (#4923) 2022-11-22 11:04:13 -05:00
David Gibson bc2fca0469 Made allowances to not monopolize the reported max channels 2022-04-17 16:42:10 -05:00
David Gibson 1ecebe3ef3 Made the maximum number of channels used by openAL dynamic 2022-04-16 21:26:12 -05:00
Goober5000 90c6c91e4f add newlines to mprintf and nprintf 2020-03-02 00:51:58 -05:00
asarium 2dc2295a59 Make FFmpeg an optional requirement
This does some refactoring to make it possible to cimpile and run FSO
without needing to link to FFmpeg. Since that eliminates support for
cutscenes or sound this is mostly useful for running a standalone server
which has no need for this anyway.

This reduces the image size of the standalone Docker image to only 20MB
and also resolves any licensing issues that might have existed.
2020-02-29 17:24:56 +01:00
MageKing17 39bd7cfdce Make 2D sounds play from front speakers instead of rear.
The Z coordinate, from negative to positive, means "front to back", so a Z value of 1.0 (with relative playback, which is what 2D sounds use) means "as far back as possible", i.e. the rear speakers. It's hard to know if this was intentional or not, but feedback from an actual user with a surround setup is that the opposite is preferable.
2019-12-04 17:10:23 -08:00
CasparKielwein e693367dd0 remove unused functions in sound 2018-12-29 16:41:23 +01:00
asarium 2ded9aa35d Format changes with clang-format 2018-07-16 10:21:52 +02:00
asarium ad54f588bb Use strongly typed handles for sound handles
This is similar to the other changes I already posted. Here the sound
instance handles are converted to their own handle type which will make
it easier to use the sound API.
2018-07-16 10:21:52 +02:00
asarium eeed22b91a Enable misc-unused-parameters
clang-tidy was used for fixing the warnings. It is not clear if this is
actually an improvement so this may still be disabled later.
2018-04-25 11:57:55 +02:00
asarium 48873185ce Another batch of misc- checks 2018-04-25 11:13:20 +02:00
asarium 0ff8a2c159 Add support for multiple sounds in one game sound entry
This adds support for specifying multiple sounds for a single game sound
entry. The engine then selects which sound will be played based on the
strategy provided by the game data. This required a few changes to some
of the game code since previously every game sound had exactly one sound
file attached to it. The most notable change is that it is no longer
possible to determine the exact duration a sound can have so instead the
new code computes the maximum duration a sound can have and uses that
where appropriate.

This also adds support for randomizing the pitch and volume of the sound
to provide a more varied experience even if only a single sound is used.

One possible issue that exists is that the "sequential" strategy only
works globally at the moment so if two sources use the same game sound
concurrently then the two sources will share the sequence of sounds
since there is no sound instance data at the moment. That can be added
in a future change but should not present a huge issue for most
use-cases.

Visual Studio on Appveyor somehow causes deprecation error on _our_
definition of vsprintf. I have no idea why these changes introduced this
warning but I won't debug Visual Studio compiler bugs that I can't
reproduce with my Visual Studio version so I just disabled those
warnings.
2017-10-17 10:57:22 +02:00
asarium 62226e71e7 Remove Ogg/Theora/Vorbis and ACM library files
They are no longer needed since decoding is provided by FFmpeg
2016-10-07 11:27:43 +02:00
asarium 73034ed9d2 Fix audio clipping of sounds 2016-10-05 14:57:13 +02:00
asarium c58195f20d Fix MSVC warnings 2016-10-05 11:02:36 +02:00
asarium 1cf11d31fe Use FFmpeg for normal audio loading
This is the last part of our code that does audio loading on its own.
After this is merged the WAV/ACM/Ogg code can be removed.
2016-10-05 11:02:36 +02:00
m!m 22c0255277 Fix a bunch of 64-bit MSVC warnings (#709)
* Fix a bunch of 64-bit warnings

* Fix Linux compilation error

* Fix Mac error

* Fix some issues

* Fix more GCC warnings

* Remote unwanted change

* Remove accidentally readded file

* Fix wrong limit check

* Use BEAM_INDEX macro for getting beam object index

* Fix 32-bit warning

* Use BEAM_INDEX instead of pointer arithmetic
2016-08-09 11:08:54 -07:00
asarium 7b352e511c Add new memory tracking subsystem
This expands the existing system which only worked on Windows to all
supported platforms.

If the MSVC debug runtime is not present then its behavior is emulated
by adding a header to each allocated memory block.
2016-07-29 11:02:45 +02:00
niffiwan 5c74720265 Fix memory leak in ds_load_buffer 2015-11-01 19:33:10 +10:00
asarium 03b26baf55 Fix format warning in ds.cpp 2015-08-19 11:26:30 +02:00
Goober5000 bd3cd7eb18 Merge pull request #195 from Echelon9/fix/sort-uniq-includes
Review and refactor #include's
2015-08-19 00:05:02 -04:00
jg18 b50bd7586c Log OpenAL info for selected device.
Fix the issue pointed out by Yarn where the OpenAL info for the default
device was being logged instead of the info for the selected
device. http://www.hard-light.net/forums/index.php?topic=90070.0.
2015-07-30 15:27:36 -07:00
Echelon9 c5493bb480 Scripted sort and uniq on (internal) project includes. Improves search time and as a by product removed a number of duplicative includes. 2015-06-22 20:24:30 +10:00
jg18 4d6d679c7b Log usage status of enhanced sound. 2015-06-19 23:50:14 -07:00
jg18 7fe5ba8db8 Make enhanced sound on by default. 2015-06-01 11:18:07 -07:00
jg18 faa0c5e9ee Make minor corrections to enhanced sound. 2015-06-01 10:24:07 -07:00
jg18 ad910280e7 Add support for enhanced sound.
Add support for enhanced in-mission sound, with 128 audio channels and a
new system for specifying per-sound priorities and concurrent playback
limits using modular extensions of soudns.tbl.
2015-05-29 23:05:30 -07:00
niffiwan 0ff8c8191f Remove gcc -Wshadow warnings 2015-04-29 20:55:56 +10:00
chief1983 26adf935f7 Globalize various file extension lists littered throughout the code so they can be referenced from other classes as needed, instead of being hardcoded multiple times.
git-svn-id: svn://svn.icculus.org/fs2open/trunk/fs2_open@11327 387891d4-d844-0410-90c0-e4c51a9137d3
2015-04-23 12:09:18 +10:00
Zacam 2db5a3b991 Fix for Mantis 2725: Beam sounds not panning correctly
git-svn-id: svn://svn.icculus.org/fs2open/trunk/fs2_open@10798 387891d4-d844-0410-90c0-e4c51a9137d3
2014-06-14 13:07:20 +10:00
Goober5000 a916633b46 onlyjob's spelling fixes, per Mantis #2777 2013-01-13 09:50:08 +00:00
IssMneur 76a889a027 Fixes 2266 by reverting ds_get_free_channel to retail 2012-08-16 04:42:21 +00:00
Valathil 21de0f9f73 Fixed the annoying OpenAL error messages in the log. AL_DOPPLER_FACTOR is only valid for alGet. Changed all instances to the correct alDopplerFactor. 2012-02-07 19:12:21 +00:00
Echelon9 8543045b15 STL types again. Some of these are just inefficient, like reserving one extra slot for each additional element, and then pushing that element onto the STL type 2011-10-17 13:07:24 +00:00
Echelon9 6d4f266e52 Use SCP_* types to access STL types wherever possible. This allows more complete memory monitoring 2011-10-03 09:06:56 +00:00
Zacam b306018b92 This is now in the .14 Branch, we'll keep it there and leave the "final" code for putting to Trunk when AP is merged/Final is released. 2011-09-27 21:23:46 +00:00
IssMneur 3ec2689d39 A bunch of audio code hacks to address the concerns in http://www.hard-light.net/forums/index.php?topic=77889.0 until proper fixes of the sound code are completed.
+F -donotenforce = to turn off concurrent playback limit for sounds.
+F -percent_flashtobang = sets the default percentage of nebula flashes get converted to bangs.  Default is 50, max 100, min 0.
+T lightning.tbl +flash_to_bang_percent: = sets the percentage of nebula flashes that get converted to bangs for the storm type.
-- Audio gain of OpenAL is set to 65% of max.
2011-09-27 03:04:11 +00:00
The_E 834e383c26 Marking a bunch of PVS Studio warnings as false alarms. While the warnings are technically correct, none of these are in places where performance matters. 2011-09-04 12:31:33 +00:00
Echelon9 d208740bcd PVS-Studio fix: V524 It is odd that the body of 'ds_eax_set_preset' function is fully equivalent to the body of 'ds_eax_set_environment' function (ds.cpp, line 2091). 2011-08-24 15:06:22 +00:00
Echelon9 a248a37d58 PVS-Studio: Fix V805. Decreased performance. It is inefficient to identify an empty string by using 'strlen(str) > 0' construct 2011-08-24 13:37:01 +00:00
Echelon9 e55068ccf1 ds.cpp: Back this change back out until the wholesale change can be made at once 2011-05-01 14:59:31 +00:00
Echelon9 aa708f6d26 Fix Valgrind report: Use of uninitialised value &freq in alcGetIntergerv(); requires braces to address GCC crosses initialisation error due to the goto in this function 2011-05-01 11:07:26 +00:00