Repository navigation
Expand file tree
/
Copy pathAudioOut2Mastering.cpp
More file actions
88 lines (75 loc) · 4.06 KB
/
Copy pathAudioOut2Mastering.cpp
File metadata and controls
88 lines (75 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <cstdint>
#include <cstring>
#include <atomic>
#include "SceTypes.hpp"
#include "prx/libc/include/General.hpp"
namespace {
constexpr int SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_API_PARAM = static_cast<int>(0x80268201);
constexpr int SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_STATES_ID = static_cast<int>(0x80268204);
constexpr int SCE_AUDIO_OUT2_ERROR_MASTERING_NOT_INITIALIZED = static_cast<int>(0x80268203);
constexpr int SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_FLAG = static_cast<int>(0x80268205);
constexpr int SCE_AUDIO_OUT2_ERROR_INVALID_POINTER = static_cast<int>(0x8026800C);
constexpr std::uint32_t AUDIO_OUT2_MASTERING_INIT_EX_MODE = 0x80000000u;
constexpr std::uint32_t AUDIO_OUT2_MASTERING_SET_PARAM_FLAGS_MAX = 1;
std::atomic<bool> g_masteringInitialized{false};
int InitializeMastering(uint32_t flags, uint32_t accepted) {
if (g_masteringInitialized.load()) return 0;
if ((flags & ~accepted) != 0) return SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_API_PARAM;
g_masteringInitialized.store(true);
return 0;
}
constexpr std::uint32_t AUDIO_OUT2_MASTERING_STATES_ID_DEFAULT = 1;
constexpr std::uint32_t AUDIO_OUT2_MASTERING_STATES_ID_V2 = 2;
constexpr std::uint32_t AUDIO_OUT2_MASTERING_STRUCT_ID_COMPRESSOR_DEFAULT = 0x01010001;
constexpr std::uint32_t AUDIO_OUT2_MASTERING_STRUCT_ID_COMPRESSOR_V2 = 0x01020001;
constexpr std::uint32_t AUDIO_OUT2_MASTERING_STRUCT_ID_LIMITER_DEFAULT = 0x01010003;
}
extern "C" {
int APS5_VABI sceAudioOut2MasteringInit(uint32_t flags) {
return InitializeMastering(flags, 0);
}
int APS5_VABI sceAudioOut2MasteringInitEx(uint32_t flags) {
return InitializeMastering(flags, AUDIO_OUT2_MASTERING_INIT_EX_MODE);
}
int APS5_VABI sceAudioOut2MasteringTerm(void) {
if (!g_masteringInitialized.exchange(false)) return SCE_AUDIO_OUT2_ERROR_MASTERING_NOT_INITIALIZED;
return 0;
}
int APS5_VABI sceAudioOut2MasteringGetState(AudioOut2MasteringStatesHeader* state, uint32_t output, AudioOut2UserHandle user) {
(void)output;
(void)user;
if (!g_masteringInitialized.load()) return SCE_AUDIO_OUT2_ERROR_MASTERING_NOT_INITIALIZED;
if (state == nullptr) return SCE_AUDIO_OUT2_ERROR_INVALID_POINTER;
switch (state->states_id) {
case AUDIO_OUT2_MASTERING_STATES_ID_DEFAULT: {
auto* full = static_cast<AudioOut2MasteringStates*>(static_cast<void*>(state));
std::memset(full, 0, sizeof(*full));
full->states_header.states_id = AUDIO_OUT2_MASTERING_STATES_ID_DEFAULT;
full->compressor_states.descriptor.id = AUDIO_OUT2_MASTERING_STRUCT_ID_COMPRESSOR_DEFAULT;
full->compressor_states.descriptor.size = sizeof(AudioOut2MasteringCompressorStates);
full->limiter_states.descriptor.id = AUDIO_OUT2_MASTERING_STRUCT_ID_LIMITER_DEFAULT;
full->limiter_states.descriptor.size = sizeof(AudioOut2MasteringLimiterStates);
return 0;
}
case AUDIO_OUT2_MASTERING_STATES_ID_V2: {
auto* full = static_cast<AudioOut2MasteringStatesV2*>(static_cast<void*>(state));
std::memset(full, 0, sizeof(*full));
full->states_header.states_id = AUDIO_OUT2_MASTERING_STATES_ID_V2;
full->compressor_states.descriptor.id = AUDIO_OUT2_MASTERING_STRUCT_ID_COMPRESSOR_V2;
full->compressor_states.descriptor.size = sizeof(AudioOut2MasteringCompressorStatesV2);
full->limiter_states.descriptor.id = AUDIO_OUT2_MASTERING_STRUCT_ID_LIMITER_DEFAULT;
full->limiter_states.descriptor.size = sizeof(AudioOut2MasteringLimiterStates);
return 0;
}
default:
return SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_STATES_ID;
}
}
int APS5_VABI sceAudioOut2MasteringSetParam(const AudioOut2MasteringParamsHeader* param, uint32_t output, uint32_t flags) {
(void)output;
if (!g_masteringInitialized.load()) return SCE_AUDIO_OUT2_ERROR_MASTERING_NOT_INITIALIZED;
if (param == nullptr) return SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_API_PARAM;
if (flags > AUDIO_OUT2_MASTERING_SET_PARAM_FLAGS_MAX) return SCE_AUDIO_OUT2_ERROR_MASTERING_INVALID_FLAG;
return 0;
}
}