• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Razakhel / RaZ / 18059902851

27 Sep 2025 12:32PM UTC coverage: 74.093% (+0.04%) from 74.05%
18059902851

push

github

Razakhel
[Utils/Logger] Added formatted logging overloads

- Formatted calls to logging functions and made use of std::format() in several other places

100 of 170 new or added lines in 36 files covered. (58.82%)

4 existing lines in 2 files now uncovered.

8334 of 11248 relevant lines covered (74.09%)

1757.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/src/RaZ/Audio/SoundEffectSlot.cpp
1
#include "RaZ/Audio/SoundEffect.hpp"
2
#include "RaZ/Audio/SoundEffectSlot.hpp"
3
#include "RaZ/Utils/CompilerUtils.hpp"
4
#include "RaZ/Utils/Logger.hpp"
5

6
#include "tracy/Tracy.hpp"
7

8
#include <AL/al.h>
9
#if !defined(RAZ_PLATFORM_EMSCRIPTEN)
10
#include <AL/efx.h>
11
#endif
12

13
namespace Raz {
14

15
namespace {
16

17
constexpr const char* recoverAlErrorStr(int errorCode) {
×
18
  switch (errorCode) {
×
19
    case AL_INVALID_NAME:      return "Invalid name";
×
20
    case AL_INVALID_ENUM:      return "Invalid enum";
×
21
    case AL_INVALID_VALUE:     return "Invalid value";
×
22
    case AL_INVALID_OPERATION: return "Invalid operation";
×
23
    case AL_OUT_OF_MEMORY:     return "Out of memory";
×
24
    case AL_NO_ERROR:          return "No error";
×
25
    default:                   return "Unknown error";
×
26
  }
27
}
28

29
inline void checkError(const std::string& errorMsg) {
7✔
30
  const int errorCode = alGetError();
7✔
31

32
  if (errorCode != AL_NO_ERROR)
7✔
NEW
33
    Logger::error("[OpenAL] {} ({})", errorMsg, recoverAlErrorStr(errorCode));
×
34
}
7✔
35

36
// Auxiliary effect slot functions
37
LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots;
38
LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots;
39
LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot;
40
LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti;
41
//LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv;
42
//LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf;
43
//LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv;
44
//LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti;
45
//LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv;
46
//LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf;
47
//LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
48

49
inline bool loadFunctions() noexcept {
1✔
50
  PUSH_WARNINGS_STATE
51
  DISABLE_WARNING_GCC(-Wconditionally-supported)
52

53
  alGenAuxiliaryEffectSlots    = reinterpret_cast<LPALGENAUXILIARYEFFECTSLOTS>(alGetProcAddress("alGenAuxiliaryEffectSlots"));
1✔
54
  alDeleteAuxiliaryEffectSlots = reinterpret_cast<LPALDELETEAUXILIARYEFFECTSLOTS>(alGetProcAddress("alDeleteAuxiliaryEffectSlots"));
1✔
55
  alIsAuxiliaryEffectSlot      = reinterpret_cast<LPALISAUXILIARYEFFECTSLOT>(alGetProcAddress("alIsAuxiliaryEffectSlot"));
1✔
56
  alAuxiliaryEffectSloti       = reinterpret_cast<LPALAUXILIARYEFFECTSLOTI>(alGetProcAddress("alAuxiliaryEffectSloti"));
1✔
57
  //alAuxiliaryEffectSlotiv      = reinterpret_cast<LPALAUXILIARYEFFECTSLOTIV>(alGetProcAddress("alAuxiliaryEffectSlotiv"));
58
  //alAuxiliaryEffectSlotf       = reinterpret_cast<LPALAUXILIARYEFFECTSLOTF>(alGetProcAddress("alAuxiliaryEffectSlotf"));
59
  //alAuxiliaryEffectSlotfv      = reinterpret_cast<LPALAUXILIARYEFFECTSLOTFV>(alGetProcAddress("alAuxiliaryEffectSlotfv"));
60
  //alGetAuxiliaryEffectSloti    = reinterpret_cast<LPALGETAUXILIARYEFFECTSLOTI>(alGetProcAddress("alGetAuxiliaryEffectSloti"));
61
  //alGetAuxiliaryEffectSlotiv   = reinterpret_cast<LPALGETAUXILIARYEFFECTSLOTIV>(alGetProcAddress("alGetAuxiliaryEffectSlotiv"));
62
  //alGetAuxiliaryEffectSlotf    = reinterpret_cast<LPALGETAUXILIARYEFFECTSLOTF>(alGetProcAddress("alGetAuxiliaryEffectSlotf"));
63
  //alGetAuxiliaryEffectSlotfv   = reinterpret_cast<LPALGETAUXILIARYEFFECTSLOTFV>(alGetProcAddress("alGetAuxiliaryEffectSlotfv"));
64

65
  POP_WARNINGS_STATE
66

67
  return true;
1✔
68
}
69

70
} // namespace
71

72
void SoundEffectSlot::init() {
3✔
73
  ZoneScopedN("SoundEffectSlot::init");
74

75
  if (!alcIsExtensionPresent(alcGetContextsDevice(alcGetCurrentContext()), "ALC_EXT_EFX")) {
3✔
76
    Logger::error("[SoundEffectSlot] Sound effects are unavailable");
×
77
    return;
×
78
  }
79

80
  [[maybe_unused]] static const bool funcsLoaded = loadFunctions();
3✔
81

82
  Logger::debug("[SoundEffectSlot] Initializing...");
3✔
83

84
  alGetError(); // Flushing errors
3✔
85

86
  destroy();
3✔
87

88
  alGenAuxiliaryEffectSlots(1, &m_index.get());
3✔
89
  checkError("Failed to create a sound effect slot");
3✔
90

91
  Logger::debug("[SoundEffectSlot] Initialized (ID: {})", m_index.get());
3✔
92
}
93

94
void SoundEffectSlot::loadEffect(const SoundEffect& effect) const noexcept {
1✔
95
  ZoneScopedN("SoundEffectSlot::loadEffect");
96

97
  alAuxiliaryEffectSloti(m_index, AL_EFFECTSLOT_EFFECT, static_cast<int>(effect.getIndex()));
1✔
98
  checkError("Failed to load the sound effect");
1✔
99
}
1✔
100

101
void SoundEffectSlot::destroy() {
6✔
102
  ZoneScopedN("SoundEffectSlot::destroy");
103

104
  if (!m_index.isValid())
6✔
105
    return;
3✔
106

107
  Logger::debug("[SoundEffectSlot] Destroying (ID: {})...", m_index.get());
3✔
108

109
  if (alIsAuxiliaryEffectSlot(m_index)) {
3✔
110
    alDeleteAuxiliaryEffectSlots(1, &m_index.get());
3✔
111
    checkError("Failed to delete sound effect slot");
6✔
112
  }
113

114
  m_index.reset();
3✔
115

116
  Logger::debug("[SoundEffectSlot] Destroyed");
6✔
117
}
118

119
} // namespace Raz
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc