fix: cppcheck (21 troballes)
This commit is contained in:
@@ -3,13 +3,14 @@
|
||||
// --- Includes ---
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <cstdint> // Para uint32_t, uint8_t
|
||||
#include <cstdio> // Para NULL, fseek, fclose, fopen, fread, ftell, FILE, SEEK_END, SEEK_SET
|
||||
#include <cstdlib> // Para free, malloc
|
||||
#include <iostream> // Para std::cout
|
||||
#include <memory> // Para std::unique_ptr
|
||||
#include <string> // Para std::string
|
||||
#include <vector> // Para std::vector
|
||||
#include <algorithm> // Para std::fill
|
||||
#include <cstdint> // Para uint32_t, uint8_t
|
||||
#include <cstdio> // Para NULL, fseek, fclose, fopen, fread, ftell, FILE, SEEK_END, SEEK_SET
|
||||
#include <cstdlib> // Para free, malloc
|
||||
#include <iostream> // Para std::cout
|
||||
#include <memory> // Para std::unique_ptr
|
||||
#include <string> // Para std::string
|
||||
#include <vector> // Para std::vector
|
||||
|
||||
#define STB_VORBIS_HEADER_ONLY
|
||||
#include "external/stb_vorbis.c" // NOLINT(bugprone-suspicious-include): stb header-only library
|
||||
@@ -270,9 +271,7 @@ inline void JA_Init(const int freq, const SDL_AudioFormat format, const int num_
|
||||
for (auto& channel : channels) {
|
||||
channel.state = JA_CHANNEL_FREE;
|
||||
}
|
||||
for (float& i : JA_soundVolume) {
|
||||
i = 0.5F;
|
||||
}
|
||||
std::fill(std::begin(JA_soundVolume), std::end(JA_soundVolume), 0.5F);
|
||||
}
|
||||
|
||||
inline void JA_Quit() {
|
||||
@@ -673,10 +672,10 @@ inline void JA_PauseChannel(const int channel) {
|
||||
}
|
||||
|
||||
if (channel == -1) {
|
||||
for (auto& channel : channels) {
|
||||
if (channel.state == JA_CHANNEL_PLAYING) {
|
||||
channel.state = JA_CHANNEL_PAUSED;
|
||||
SDL_UnbindAudioStream(channel.stream);
|
||||
for (auto& ch : channels) {
|
||||
if (ch.state == JA_CHANNEL_PLAYING) {
|
||||
ch.state = JA_CHANNEL_PAUSED;
|
||||
SDL_UnbindAudioStream(ch.stream);
|
||||
}
|
||||
}
|
||||
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
|
||||
@@ -693,10 +692,10 @@ inline void JA_ResumeChannel(const int channel) {
|
||||
}
|
||||
|
||||
if (channel == -1) {
|
||||
for (auto& channel : channels) {
|
||||
if (channel.state == JA_CHANNEL_PAUSED) {
|
||||
channel.state = JA_CHANNEL_PLAYING;
|
||||
SDL_BindAudioStream(sdlAudioDevice, channel.stream);
|
||||
for (auto& ch : channels) {
|
||||
if (ch.state == JA_CHANNEL_PAUSED) {
|
||||
ch.state = JA_CHANNEL_PLAYING;
|
||||
SDL_BindAudioStream(sdlAudioDevice, ch.stream);
|
||||
}
|
||||
}
|
||||
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
|
||||
@@ -709,15 +708,15 @@ inline void JA_ResumeChannel(const int channel) {
|
||||
|
||||
inline void JA_StopChannel(const int channel) {
|
||||
if (channel == -1) {
|
||||
for (auto& channel : channels) {
|
||||
if (channel.state != JA_CHANNEL_FREE) {
|
||||
if (channel.stream != nullptr) {
|
||||
SDL_DestroyAudioStream(channel.stream);
|
||||
for (auto& ch : channels) {
|
||||
if (ch.state != JA_CHANNEL_FREE) {
|
||||
if (ch.stream != nullptr) {
|
||||
SDL_DestroyAudioStream(ch.stream);
|
||||
}
|
||||
channel.stream = nullptr;
|
||||
channel.state = JA_CHANNEL_FREE;
|
||||
channel.pos = 0;
|
||||
channel.sound = nullptr;
|
||||
ch.stream = nullptr;
|
||||
ch.state = JA_CHANNEL_FREE;
|
||||
ch.pos = 0;
|
||||
ch.sound = nullptr;
|
||||
}
|
||||
}
|
||||
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) {
|
||||
@@ -748,9 +747,7 @@ inline auto JA_SetSoundVolume(float volume, const int group = -1) -> float {
|
||||
const float v = SDL_clamp(volume, 0.0F, 1.0F);
|
||||
|
||||
if (group == -1) {
|
||||
for (float& i : JA_soundVolume) {
|
||||
i = v;
|
||||
}
|
||||
std::fill(std::begin(JA_soundVolume), std::end(JA_soundVolume), v);
|
||||
} else if (group >= 0 && group < JA_MAX_GROUPS) {
|
||||
JA_soundVolume[group] = v;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user