Merge pull request #135 from TakaRikka/pjb-audio

Audio
This commit is contained in:
TakaRikka
2026-03-27 20:36:06 -07:00
committed by GitHub
111 changed files with 2651 additions and 966 deletions
+2 -2
View File
@@ -2,13 +2,13 @@
#define DUSK_AUDIO_H
#if TARGET_PC
#define DUSK_AUDIO_DISABLED 1
#define DUSK_AUDIO_DISABLED 0
#else
#define DUSK_AUDIO_DISABLED 0
#endif
#if TARGET_PC
#define DUSK_AUDIO_SKIP(...) return __VA_ARGS__;
#define DUSK_AUDIO_SKIP(...)
#else
#define DUSK_AUDIO_SKIP(...)
#endif
+16
View File
@@ -0,0 +1,16 @@
#pragma once
#include <dolphin/types.h>
namespace dusk::audio {
/**
* Initialize the audio system and start playing audio.
*/
void Initialize();
void SetMasterVolume(f32 value);
u32 GetResetCount(int channelIdx);
f32 VolumeFromU16(u16 value);
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef DUSK_MAIN_H
#define DUSK_MAIN_H
namespace dusk {
extern bool IsShuttingDown;
}
#endif // DUSK_MAIN_H
+14
View File
@@ -0,0 +1,14 @@
#ifndef DUSK_OS_H
#define DUSK_OS_H
#ifdef __cplusplus
extern "C" {
#endif
void OSSetCurrentThreadName(const char* name);
#ifdef __cplusplus
}
#endif
#endif // DUSK_OS_H
+58
View File
@@ -0,0 +1,58 @@
#ifndef DUSK_STRING_HPP
#define DUSK_STRING_HPP
#include "global.h"
#include <cstring>
#include <dolphin/os.h>
namespace dusk {
inline void strncpyProxy(char* dst, const char* src, size_t count) {
#if _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996)
#endif
strncpy(dst, src, count);
#if _MSC_VER
#pragma warning(pop)
#endif
}
/**
* Copy a string to a fixed-size array.
* Truncates if the destination is not large enough, always inserts a null terminator (padding the remainder of the buffer with zeroes.)
*/
template <size_t BufSize>
void SafeStringCopyTruncate(char (&buffer)[BufSize], const char* src) {
static_assert(BufSize > 0, "Target buffer cannot be size zero");
if (buffer == src) {
CRASH("Cannot copy string to same buffer");
}
strncpyProxy(buffer, src, BufSize);
buffer[BufSize - 1] = 0;
}
/**
* Copy a string to a fixed-size array.
* Aborts if the destination is not large enough, always inserts a null terminator (padding the remainder of the buffer with zeroes.)
*/
template <size_t BufSize>
void SafeStringCopy(char (&buffer)[BufSize], const char* src) {
static_assert(BufSize > 0, "Target buffer cannot be size zero");
if (buffer == src) {
CRASH("Cannot copy string to same buffer");
}
if (strlen(src) > BufSize - 1) {
CRASH("Destination buffer too small!");
}
strncpyProxy(buffer, src, BufSize);
buffer[BufSize - 1] = 0;
}
}
#endif // DUSK_STRING_HPP