Commit Graph

5666 Commits

Author SHA1 Message Date
Patrik Nilsson 7d398919a0 Address review feedback and improve code style
- Moved end-of-line comments to preceding lines for better readability and to avoid potential line length issues across various files modified in previous commits.
- In the RageSoundReader_Chain constructor: Removed redundant initialization of m_iPreferredSampleRate. Replaced hardcoded 44100 with kFallbackSampleRate. Removed an unnecessary comment.
- Added braces consistently to single-statement if/else blocks across all recently modified sound system files. This enhances code clarity and maintainability by explicitly defining block scopes.
2025-06-01 08:37:19 -07:00
Patrik Nilsson 72c7316671 Centralize fallback sample rate with kFallbackSampleRate
Replaces hardcoded 44100Hz values (used as fallbacks or for the "Default" sample rate preference) with a new constant `constexpr int kFallbackSampleRate = 44100;` defined in RageSound.h.

This constant is now used in:
- RageSoundReader_Silence
- RageSoundManager (for unloaded driver scenarios)
- All sound drivers' initialization logic for the "Default (0)" preference (DSound, WaveOut, AU, PulseAudio, OSS, WDMKS, Null)
- DSound primary buffer setup.
2025-06-01 08:37:19 -07:00
Patrik Nilsson 2e18b57da0 Implement configurable Sample Rate in options
Key changes:
- Added "Sample Rate" to `ScreenOptionsGraphicsSound` with choices:
    - "Default" (resolves to 44100 Hz for now)
    - "44100 Hz"
    - "48000 Hz"
- Created a new ConfOption "PreferredSampleRate" in `ScreenOptionsMasterPrefs.cpp` mapping UI choices to the integer values (0, 44100, 48000) for the existing `m_iSoundPreferredSampleRate` preference.
- Updated relevant sound drivers:
    - DirectSound (RageSoundDriver_DSound_Software): Primary buffer now attempts to use the preferred rate. Secondary buffers already handled it correctly.
    - WaveOut (RageSoundDriver_WaveOut): Already handled 0 as 44.1kHz correctly.
    - PulseAudio (RageSoundDriver_PulseAudio): Ensured m_InitStream uses the constructor-initialized rate based on preference.
    - AudioUnit (RageSoundDriver_AU): Already handled 0 as 44.1kHz and attempts to set hardware rate.
    - OSS (RageSoundDriver_OSS): Updated to read and apply the preferred sample rate.
    - WDMKS (RageSoundDriver_WDMKS): Updated to pass the resolved preferred rate to its stream opening logic.
    - Null (RageSoundDriver_Null): Already handled 0 as 44.1kHz correctly.
- Updated `RageSoundReader_Chain` constructor to use the preferred system sample rate for its internal default.
- Added English localization for the new option title and explanation.

The implementation ensures that if the preference is 0 (Default), the system currently defaults to 44100 Hz across all drivers. This lays the groundwork for future dynamic hardware rate detection. A game restart is recommended for the new sample rate to take full effect.
2025-06-01 08:37:19 -07:00
Patrik Nilsson af127ca23b Audio: Update default sample rate to 48kHz to mitigate sync issues 2025-06-01 08:37:19 -07:00
Sergio Perez Fernandez 2517959050 do not write any logs in disk when LogToDisk=0 2025-05-30 13:51:09 -07:00
sukibaby 1e667de589 Use a range-based for loop to avoid manual iterator handling 2025-05-28 14:56:29 -07:00
sukibaby 281cd8cb51 Change the video looping log to Info level.
Doesn't need to be written to disk right away every time a video loops.
2025-05-27 22:27:21 -07:00
Scott Brenner 7a3fa88c7a Update src/RageSoundReader_ChannelSplit.cpp 2025-05-25 21:09:54 -07:00
Scott Brenner 6cdf64afc8 Fix for code scanning alert: Multiplication result converted to larger type
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-05-25 21:09:54 -07:00
Scott Brenner 24fce53629 Update src/RageSurfaceUtils.cpp 2025-05-25 21:09:32 -07:00
Scott Brenner 146702430b Fix for code scanning alert: Multiplication result converted to larger type
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-05-25 21:09:32 -07:00
Scott Brenner fc2d5dbf17 Fix for code scanning alert: Multiplication result converted to larger type
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-05-25 21:09:01 -07:00
Scott Brenner 7ff2002bec Update src/RageSurfaceUtils.cpp 2025-05-25 21:08:36 -07:00
Scott Brenner f0908b58ad Fix for code scanning alert no. 479: Multiplication result converted to larger type
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-05-25 21:08:36 -07:00
Scott Brenner 57d54a0c89 Fix for code scanning alert: Multiplication result converted to larger type
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-05-25 00:31:23 -07:00
Scott Brenner 90176a1f1c Fix for code scanning alert: Multiplication result converted to larger type
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-05-25 00:29:25 -07:00
Scott Brenner 72b3590097 Fix for code scanning alert: Multiplication result converted to larger type
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-05-25 00:28:38 -07:00
teejusb 44f5d8932a Include <utility> for std::swap 2025-05-23 23:39:55 -05:00
sukibaby 7792a82e7a OS-agnostic log warning for invalid sound driver entry. 2025-05-23 19:49:42 -07:00
sukibaby 45925badfd Update Windows build flags
/MP2 limits the build processes to a maximum of 2. Many CPU's nowadays have more than two cores, so the integer specifier is removed so that the build is not artificially constrained to two cores.

/FS allows multiple compiler processes to write to the .pdb file; it should be used in conjunction with /MP to speed up the build.

/permissive- disables certain MSVC-specific extensions and follows the C standard more closely. Using this flag should help to ensure behavior matches gcc & clang a little more closely.

Note, /utf-8 does NOT build the program with Unicode support. It merely indicates to the compiler that the source files are using UTF-8 encoding.
2025-05-23 19:47:21 -07:00
sukibaby 71cb44bde3 Make SetThreadPrecedence return a std::string 2025-05-22 20:08:56 -07:00
sukibaby 6a29f651c7 Remove implicit conversion operator from RString to const char* (macOS)
Tested via CI (don't have a Mac).
2025-05-22 20:08:56 -07:00
din 0e00f57e45 sample udev rules to include hidapi 2025-05-22 11:42:50 -07:00
din 69f6a14935 additional HidDevice logging error conditions 2025-05-22 11:42:50 -07:00
Yauhen Artsiukhou 36e2dcbce8 Bring LinuxPacDrive back as GenericHID lights driver
This is actually generalized old LinuxPacDrive driver. It kept here for backward
compatibility. So people have time to migrate on better new implementation.

Set LightsDriver to "PacDrive" to test the new driver.

GenericHID uses USB libusb_control_transfer to send data (4 bytes) over the wire where first 2 are
lights state. So any HID-like usb device can read the data and control lights.
2025-05-22 11:40:50 -07:00
teejusb c18e7a68ae Add pack.ini file paths to error messages 2025-05-17 14:08:13 -07:00
Arthur Eubanks 995f0ea8c1 Change some RString methods to free functions
These ones aren't a std::string method. Doing this helps the RString to
std::string migration.
2025-05-17 14:02:12 -07:00
teejusb eaf6a24acf Ensure CodeNames sizes are the same even on invalid codes 2025-05-17 13:03:41 -07:00
teejusb e1c91e66f0 Remove the +Alt message for autoplay -- this feature had been removed 2025-05-17 12:22:18 -07:00
teejusb a780bdb7be Add Assist Clap text to the overlay 2025-05-17 12:19:21 -07:00
Arthur Eubanks ecfcb11a00 Remove implicit conversion operator from RString to const char*
This is required for the RString to std::string migration.

Mostly automated from https://github.com/aeubanks/rewriter/blob/main/c_str.cc, with some manual intervention required for fixing up `a + b.c_str()` to `(a + b).c_str()`.

Added some overloads for some common global functions like sm_crash to reduce the number of changes required here.
2025-05-15 21:14:54 -07:00
sukibaby 25b57c13d5 Replace some lrint's with GetTimeSinceStartSeconds()
Optimization to avoid several stages of integer-to-float and float-to-integer by making use of GetTimeSinceStartSeconds().
2025-05-10 10:09:44 -07:00
sukibaby d3ff9a0683 Replace GetRandomInt()
RageUtil already had a RandomInt function, this wasn't needed after all.
2025-05-10 09:27:05 -07:00
Michael Votaw b7bafbef93 Added note about checking dwi chart length of at least 2 characters 2025-05-10 09:22:01 -07:00
Michael Votaw 977f83a16f Bail out earlier when dealing with certain types of malformed DWI charts. 2025-05-10 09:22:01 -07:00
sukibaby 60f57cd337 Song::GetFileHash cleanup
Implement a range-based loop instead of a big list of if statements.

& prefer ssc to sm to all else

Song::GetFileHash: Fix indentation
2025-05-09 10:48:37 -07:00
sukibaby e84b774166 Remove an expensive but low-importance log
We only see this if & when we shut down cleanly. It's not worth calculating every time we mix a sound into the buffer.
2025-05-09 10:25:12 -07:00
Brandon W a4124aafe4 Unify practice mode song navigation with edit mode. 2025-05-09 10:09:05 -07:00
sukibaby d428bbbcd4 Fix for Code scanning alert #40 "Unsigned difference expression compared to zero" 2025-05-06 15:44:15 -07:00
sukibaby 33a6912778 Code scanning alert #487 "Multiplication result converted to larger type"
My own fix, not auto-generated.
m_iChannels is implicitly promoted to size_t.
2025-05-06 15:43:38 -07:00
sukibaby 21e6498414 Resolve critical CWE-134 warning
Resolves CWE-134: Use of Externally-Controlled Format String by using c_str on the path variable and removing an invalid string concatenation.
2025-05-06 15:43:03 -07:00
sukibaby f18dddd43e Fix a malformed CHECKPOINT_M
It uses %s, but there is no variable passed to it, so it literally prints "Driver %s successfully made", this fixes that.
2025-05-03 22:42:19 -07:00
sukibaby 79f2e2e5ee Revert "Fix two small RageFile bugs"
This reverts commit 5d2667add1.
2025-05-03 07:54:02 -07:00
sukibaby a517a3887c Use std::call_once in ArchHooks_Win32Static
Makes use of this <mutex> feature to ensure the timer is only initialized once. Reduces clutter, and improves thread-safety.
2025-05-03 07:53:33 -07:00
sukibaby a3eb3d8646 SaveScreenshot: remove unused timer
The timer is only used by the commented-out debug log methods, but the timer itself still runs. This removes the timer as well as the unused logs.
2025-05-01 13:10:30 -07:00
sukibaby b5a2f86277 SaveScreenshot: Use const & in function header
Pass sPath by reference to avoid unnecessary copies.
2025-05-01 13:10:12 -07:00
sukibaby 16b3ba488d SaveScreenshot: return the status boolean directly
Remake of PR #790 due to merge conflicts
2025-05-01 13:09:55 -07:00
sukibaby 64a1e3a49c SaveScreenshot: remove unneeded boolean 2025-05-01 00:25:09 -07:00
sukibaby dacf87fb3b SaveScreenshot: improve error logging
The existing code uses repeated error messages at different points in the code, making debugging very difficult. This makes every step more unique for easier state tracking. Also changes trace to warn, to make it a little easier to spot failed screenshots in the log.
2025-05-01 00:23:53 -07:00
sukibaby d50ad757cb Remove useless alias
This used to be a different function than GetTimeSinceStart which returned a lower precision value but we don't do that anymore.
2025-04-29 21:42:37 -07:00