Revert "core: Fix clang build"
This commit is contained in:
parent
fdd9154069
commit
3d592972dc
105 changed files with 667 additions and 906 deletions
|
@ -51,9 +51,8 @@ if (NOT MSVC)
|
|||
-Werror=implicit-fallthrough
|
||||
-Werror=reorder
|
||||
-Werror=sign-compare
|
||||
-Werror=sign-conversion
|
||||
$<$<CXX_COMPILER_ID:GNU>:-Werror=unused-but-set-parameter>
|
||||
$<$<CXX_COMPILER_ID:GNU>:-Werror=unused-but-set-variable>
|
||||
-Werror=unused-but-set-parameter
|
||||
-Werror=unused-but-set-variable
|
||||
-Werror=unused-variable
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -167,8 +167,8 @@ std::vector<s16> Interpolate(InterpolationState& state, std::vector<s16> input,
|
|||
output.reserve(static_cast<std::size_t>(static_cast<double>(input.size()) / ratio +
|
||||
InterpolationState::taps));
|
||||
|
||||
for (std::size_t frame = 0; frame < num_frames; ++frame) {
|
||||
const auto lut_index{static_cast<size_t>(state.fraction >> 8) * InterpolationState::taps};
|
||||
for (std::size_t frame{}; frame < num_frames; ++frame) {
|
||||
const std::size_t lut_index{(state.fraction >> 8) * InterpolationState::taps};
|
||||
|
||||
std::rotate(state.history.begin(), state.history.end() - 1, state.history.end());
|
||||
state.history[0][0] = input[frame * 2 + 0];
|
||||
|
@ -225,7 +225,7 @@ void Resample(s32* output, const s32* input, s32 pitch, s32& fraction, std::size
|
|||
|
||||
output[i] = (l0 * s0 + l1 * s1 + l2 * s2 + l3 * s3) >> 15;
|
||||
fraction += pitch;
|
||||
index += static_cast<size_t>(fraction >> 15);
|
||||
index += (fraction >> 15);
|
||||
fraction &= 0x7fff;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,8 +187,8 @@ void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) {
|
|||
const auto& in_params = final_mix.GetInParams();
|
||||
std::vector<s32*> mix_buffers(channel_count);
|
||||
for (std::size_t i = 0; i < channel_count; i++) {
|
||||
mix_buffers[i] = command_generator.GetMixBuffer(
|
||||
static_cast<u32>(in_params.buffer_offset) + buffer_offsets[i]);
|
||||
mix_buffers[i] =
|
||||
command_generator.GetMixBuffer(in_params.buffer_offset + buffer_offsets[i]);
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < BUFFER_SIZE; i++) {
|
||||
|
|
|
@ -32,7 +32,7 @@ std::vector<s16> DecodeADPCM(const u8* const data, std::size_t size, const ADPCM
|
|||
for (std::size_t framei = 0; framei < NUM_FRAMES; framei++) {
|
||||
const int frame_header = data[framei * FRAME_LEN];
|
||||
const int scale = 1 << (frame_header & 0xF);
|
||||
const auto idx = static_cast<size_t>((frame_header >> 4) & 0x7);
|
||||
const int idx = (frame_header >> 4) & 0x7;
|
||||
|
||||
// Coefficients are fixed point with 11 bits fractional part.
|
||||
const int coef1 = coeff[idx * 2 + 0];
|
||||
|
@ -57,11 +57,11 @@ std::vector<s16> DecodeADPCM(const u8* const data, std::size_t size, const ADPCM
|
|||
std::size_t outputi = framei * SAMPLES_PER_FRAME;
|
||||
std::size_t datai = framei * FRAME_LEN + 1;
|
||||
for (std::size_t i = 0; i < SAMPLES_PER_FRAME && outputi < sample_count; i += 2) {
|
||||
const s16 sample1 = decode_sample(SIGNED_NIBBLES[static_cast<u32>(data[datai] >> 4)]);
|
||||
const s16 sample1 = decode_sample(SIGNED_NIBBLES[data[datai] >> 4]);
|
||||
ret[outputi] = sample1;
|
||||
outputi++;
|
||||
|
||||
const s16 sample2 = decode_sample(SIGNED_NIBBLES[static_cast<u32>(data[datai] & 0xF)]);
|
||||
const s16 sample2 = decode_sample(SIGNED_NIBBLES[data[datai] & 0xF]);
|
||||
ret[outputi] = sample2;
|
||||
outputi++;
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ constexpr std::size_t MIX_BUFFER_SIZE = 0x3f00;
|
|||
constexpr std::size_t SCALED_MIX_BUFFER_SIZE = MIX_BUFFER_SIZE << 15ULL;
|
||||
|
||||
template <std::size_t N>
|
||||
void ApplyMix(s32* output, const s32* input, s32 gain, std::size_t sample_count) {
|
||||
for (std::size_t i = 0; i < sample_count; i += N) {
|
||||
void ApplyMix(s32* output, const s32* input, s32 gain, s32 sample_count) {
|
||||
for (std::size_t i = 0; i < static_cast<std::size_t>(sample_count); i += N) {
|
||||
for (std::size_t j = 0; j < N; j++) {
|
||||
output[i + j] +=
|
||||
static_cast<s32>((static_cast<s64>(input[i + j]) * gain + 0x4000) >> 15);
|
||||
|
@ -111,8 +111,7 @@ void CommandGenerator::GenerateVoiceCommand(ServerVoiceInfo& voice_info) {
|
|||
const auto channel_count = in_params.channel_count;
|
||||
|
||||
for (s32 channel = 0; channel < channel_count; channel++) {
|
||||
const auto resource_id =
|
||||
static_cast<u32>(in_params.voice_channel_resource_id[static_cast<u32>(channel)]);
|
||||
const auto resource_id = in_params.voice_channel_resource_id[channel];
|
||||
auto& dsp_state = voice_context.GetDspSharedState(resource_id);
|
||||
auto& channel_resource = voice_context.GetChannelResource(resource_id);
|
||||
|
||||
|
@ -133,15 +132,14 @@ void CommandGenerator::GenerateVoiceCommand(ServerVoiceInfo& voice_info) {
|
|||
|
||||
if (in_params.mix_id != AudioCommon::NO_MIX) {
|
||||
// If we're using a mix id
|
||||
auto& mix_info = mix_context.GetInfo(static_cast<u32>(in_params.mix_id));
|
||||
auto& mix_info = mix_context.GetInfo(in_params.mix_id);
|
||||
const auto& dest_mix_params = mix_info.GetInParams();
|
||||
|
||||
// Voice Mixing
|
||||
GenerateVoiceMixCommand(
|
||||
channel_resource.GetCurrentMixVolume(), channel_resource.GetLastMixVolume(),
|
||||
dsp_state, static_cast<u32>(dest_mix_params.buffer_offset),
|
||||
static_cast<u32>(dest_mix_params.buffer_count),
|
||||
worker_params.mix_buffer_count + static_cast<u32>(channel), in_params.node_id);
|
||||
dsp_state, dest_mix_params.buffer_offset, dest_mix_params.buffer_count,
|
||||
worker_params.mix_buffer_count + channel, in_params.node_id);
|
||||
|
||||
// Update last mix volumes
|
||||
channel_resource.UpdateLastMixVolumes();
|
||||
|
@ -158,15 +156,12 @@ void CommandGenerator::GenerateVoiceCommand(ServerVoiceInfo& voice_info) {
|
|||
continue;
|
||||
}
|
||||
|
||||
const auto& mix_info =
|
||||
mix_context.GetInfo(static_cast<u32>(destination_data->GetMixId()));
|
||||
const auto& mix_info = mix_context.GetInfo(destination_data->GetMixId());
|
||||
const auto& dest_mix_params = mix_info.GetInParams();
|
||||
GenerateVoiceMixCommand(
|
||||
destination_data->CurrentMixVolumes(), destination_data->LastMixVolumes(),
|
||||
dsp_state, static_cast<u32>(dest_mix_params.buffer_offset),
|
||||
static_cast<u32>(dest_mix_params.buffer_count),
|
||||
worker_params.mix_buffer_count + static_cast<u32>(channel),
|
||||
in_params.node_id);
|
||||
dsp_state, dest_mix_params.buffer_offset, dest_mix_params.buffer_count,
|
||||
worker_params.mix_buffer_count + channel, in_params.node_id);
|
||||
destination_data->MarkDirty();
|
||||
}
|
||||
}
|
||||
|
@ -224,10 +219,9 @@ void CommandGenerator::GenerateDataSourceCommand(ServerVoiceInfo& voice_info, Vo
|
|||
|
||||
if (depop) {
|
||||
if (in_params.mix_id != AudioCommon::NO_MIX) {
|
||||
auto& mix_info = mix_context.GetInfo(static_cast<u32>(in_params.mix_id));
|
||||
auto& mix_info = mix_context.GetInfo(in_params.mix_id);
|
||||
const auto& mix_in = mix_info.GetInParams();
|
||||
GenerateDepopPrepareCommand(dsp_state, static_cast<u32>(mix_in.buffer_count),
|
||||
static_cast<u32>(mix_in.buffer_offset));
|
||||
GenerateDepopPrepareCommand(dsp_state, mix_in.buffer_count, mix_in.buffer_offset);
|
||||
} else if (in_params.splitter_info_id != AudioCommon::NO_SPLITTER) {
|
||||
s32 index{};
|
||||
while (const auto* destination =
|
||||
|
@ -235,24 +229,23 @@ void CommandGenerator::GenerateDataSourceCommand(ServerVoiceInfo& voice_info, Vo
|
|||
if (!destination->IsConfigured()) {
|
||||
continue;
|
||||
}
|
||||
auto& mix_info = mix_context.GetInfo(static_cast<u32>(destination->GetMixId()));
|
||||
auto& mix_info = mix_context.GetInfo(destination->GetMixId());
|
||||
const auto& mix_in = mix_info.GetInParams();
|
||||
GenerateDepopPrepareCommand(dsp_state, static_cast<u32>(mix_in.buffer_count),
|
||||
static_cast<u32>(mix_in.buffer_offset));
|
||||
GenerateDepopPrepareCommand(dsp_state, mix_in.buffer_count, mix_in.buffer_offset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (in_params.sample_format) {
|
||||
case SampleFormat::Pcm16:
|
||||
DecodeFromWaveBuffers(voice_info, GetChannelMixBuffer(channel), dsp_state, channel,
|
||||
static_cast<s32>(worker_params.sample_rate),
|
||||
static_cast<s32>(worker_params.sample_count), in_params.node_id);
|
||||
worker_params.sample_rate, worker_params.sample_count,
|
||||
in_params.node_id);
|
||||
break;
|
||||
case SampleFormat::Adpcm:
|
||||
ASSERT(channel == 0 && in_params.channel_count == 1);
|
||||
DecodeFromWaveBuffers(voice_info, GetChannelMixBuffer(0), dsp_state, 0,
|
||||
static_cast<s32>(worker_params.sample_rate),
|
||||
static_cast<s32>(worker_params.sample_count), in_params.node_id);
|
||||
worker_params.sample_rate, worker_params.sample_count,
|
||||
in_params.node_id);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE_MSG("Unimplemented sample format={}", in_params.sample_format);
|
||||
|
@ -262,7 +255,7 @@ void CommandGenerator::GenerateDataSourceCommand(ServerVoiceInfo& voice_info, Vo
|
|||
|
||||
void CommandGenerator::GenerateBiquadFilterCommandForVoice(ServerVoiceInfo& voice_info,
|
||||
VoiceState& dsp_state,
|
||||
u32 mix_buffer_count, s32 channel) {
|
||||
s32 mix_buffer_count, s32 channel) {
|
||||
for (std::size_t i = 0; i < AudioCommon::MAX_BIQUAD_FILTERS; i++) {
|
||||
const auto& in_params = voice_info.GetInParams();
|
||||
auto& biquad_filter = in_params.biquad_filter[i];
|
||||
|
@ -342,8 +335,8 @@ void CommandGenerator::GenerateDepopForMixBuffersCommand(std::size_t mix_buffer_
|
|||
continue;
|
||||
}
|
||||
|
||||
depop_buffer[i] = ApplyMixDepop(GetMixBuffer(i), depop_buffer[i], delta,
|
||||
static_cast<s32>(worker_params.sample_count));
|
||||
depop_buffer[i] =
|
||||
ApplyMixDepop(GetMixBuffer(i), depop_buffer[i], delta, worker_params.sample_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,7 +348,7 @@ void CommandGenerator::GenerateEffectCommand(ServerMixInfo& mix_info) {
|
|||
if (index == AudioCommon::NO_EFFECT_ORDER) {
|
||||
break;
|
||||
}
|
||||
auto* info = effect_context.GetInfo(static_cast<u32>(index));
|
||||
auto* info = effect_context.GetInfo(index);
|
||||
const auto type = info->GetType();
|
||||
|
||||
// TODO(ogniK): Finish remaining effects
|
||||
|
@ -384,11 +377,11 @@ void CommandGenerator::GenerateI3dl2ReverbEffectCommand(s32 mix_buffer_offset, E
|
|||
}
|
||||
const auto& params = dynamic_cast<EffectI3dl2Reverb*>(info)->GetParams();
|
||||
const auto channel_count = params.channel_count;
|
||||
for (size_t i = 0; i < channel_count; i++) {
|
||||
for (s32 i = 0; i < channel_count; i++) {
|
||||
// TODO(ogniK): Actually implement reverb
|
||||
if (params.input[i] != params.output[i]) {
|
||||
const auto* input = GetMixBuffer(static_cast<u32>(mix_buffer_offset + params.input[i]));
|
||||
auto* output = GetMixBuffer(static_cast<u32>(mix_buffer_offset + params.output[i]));
|
||||
const auto* input = GetMixBuffer(mix_buffer_offset + params.input[i]);
|
||||
auto* output = GetMixBuffer(mix_buffer_offset + params.output[i]);
|
||||
ApplyMix<1>(output, input, 32768, worker_params.sample_count);
|
||||
}
|
||||
}
|
||||
|
@ -399,14 +392,13 @@ void CommandGenerator::GenerateBiquadFilterEffectCommand(s32 mix_buffer_offset,
|
|||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& params = dynamic_cast<EffectBiquadFilter*>(info)->GetParams();
|
||||
const auto channel_count = static_cast<u32>(params.channel_count);
|
||||
for (size_t i = 0; i < channel_count; i++) {
|
||||
const auto channel_count = params.channel_count;
|
||||
for (s32 i = 0; i < channel_count; i++) {
|
||||
// TODO(ogniK): Actually implement biquad filter
|
||||
if (params.input[i] != params.output[i]) {
|
||||
const auto* input = GetMixBuffer(static_cast<u32>(mix_buffer_offset + params.input[i]));
|
||||
auto* output = GetMixBuffer(static_cast<u32>(mix_buffer_offset + params.output[i]));
|
||||
const auto* input = GetMixBuffer(mix_buffer_offset + params.input[i]);
|
||||
auto* output = GetMixBuffer(mix_buffer_offset + params.output[i]);
|
||||
ApplyMix<1>(output, input, 32768, worker_params.sample_count);
|
||||
}
|
||||
}
|
||||
|
@ -433,30 +425,26 @@ void CommandGenerator::GenerateAuxCommand(s32 mix_buffer_offset, EffectBase* inf
|
|||
memory.ReadBlock(aux->GetSendInfo(), &send_info, sizeof(AuxInfoDSP));
|
||||
memory.ReadBlock(aux->GetRecvInfo(), &recv_info, sizeof(AuxInfoDSP));
|
||||
|
||||
WriteAuxBuffer(send_info, aux->GetSendBuffer(),
|
||||
static_cast<u32>(params.sample_count),
|
||||
GetMixBuffer(static_cast<u32>(input_index)),
|
||||
worker_params.sample_count, offset, write_count);
|
||||
WriteAuxBuffer(send_info, aux->GetSendBuffer(), params.sample_count,
|
||||
GetMixBuffer(input_index), worker_params.sample_count, offset,
|
||||
write_count);
|
||||
memory.WriteBlock(aux->GetSendInfo(), &send_info, sizeof(AuxInfoDSP));
|
||||
|
||||
const auto samples_read = ReadAuxBuffer(
|
||||
recv_info, aux->GetRecvBuffer(), static_cast<u32>(params.sample_count),
|
||||
GetMixBuffer(static_cast<u32>(output_index)), worker_params.sample_count,
|
||||
offset, write_count);
|
||||
recv_info, aux->GetRecvBuffer(), params.sample_count,
|
||||
GetMixBuffer(output_index), worker_params.sample_count, offset, write_count);
|
||||
memory.WriteBlock(aux->GetRecvInfo(), &recv_info, sizeof(AuxInfoDSP));
|
||||
|
||||
if (samples_read != static_cast<int>(worker_params.sample_count) &&
|
||||
samples_read <= params.sample_count) {
|
||||
std::memset(GetMixBuffer(static_cast<u32>(output_index)), 0,
|
||||
static_cast<size_t>(params.sample_count - samples_read));
|
||||
std::memset(GetMixBuffer(output_index), 0, params.sample_count - samples_read);
|
||||
}
|
||||
} else {
|
||||
AuxInfoDSP empty{};
|
||||
memory.WriteBlock(aux->GetSendInfo(), &empty, sizeof(AuxInfoDSP));
|
||||
memory.WriteBlock(aux->GetRecvInfo(), &empty, sizeof(AuxInfoDSP));
|
||||
if (output_index != input_index) {
|
||||
std::memcpy(GetMixBuffer(static_cast<u32>(output_index)),
|
||||
GetMixBuffer(static_cast<u32>(input_index)),
|
||||
std::memcpy(GetMixBuffer(output_index), GetMixBuffer(input_index),
|
||||
worker_params.sample_count * sizeof(s32));
|
||||
}
|
||||
}
|
||||
|
@ -470,8 +458,7 @@ ServerSplitterDestinationData* CommandGenerator::GetDestinationData(s32 splitter
|
|||
if (splitter_id == AudioCommon::NO_SPLITTER) {
|
||||
return nullptr;
|
||||
}
|
||||
return splitter_context.GetDestinationData(static_cast<u32>(splitter_id),
|
||||
static_cast<u32>(index));
|
||||
return splitter_context.GetDestinationData(splitter_id, index);
|
||||
}
|
||||
|
||||
s32 CommandGenerator::WriteAuxBuffer(AuxInfoDSP& dsp_info, VAddr send_buffer, u32 max_samples,
|
||||
|
@ -501,7 +488,7 @@ s32 CommandGenerator::WriteAuxBuffer(AuxInfoDSP& dsp_info, VAddr send_buffer, u3
|
|||
if (write_count != 0) {
|
||||
dsp_info.write_offset = (dsp_info.write_offset + write_count) % max_samples;
|
||||
}
|
||||
return static_cast<s32>(sample_count);
|
||||
return sample_count;
|
||||
}
|
||||
|
||||
s32 CommandGenerator::ReadAuxBuffer(AuxInfoDSP& recv_info, VAddr recv_buffer, u32 max_samples,
|
||||
|
@ -531,7 +518,7 @@ s32 CommandGenerator::ReadAuxBuffer(AuxInfoDSP& recv_info, VAddr recv_buffer, u3
|
|||
if (read_count != 0) {
|
||||
recv_info.read_offset = (recv_info.read_offset + read_count) % max_samples;
|
||||
}
|
||||
return static_cast<s32>(sample_count);
|
||||
return sample_count;
|
||||
}
|
||||
|
||||
void CommandGenerator::GenerateVolumeRampCommand(float last_volume, float current_volume,
|
||||
|
@ -550,15 +537,15 @@ void CommandGenerator::GenerateVolumeRampCommand(float last_volume, float curren
|
|||
}
|
||||
// Apply generic gain on samples
|
||||
ApplyGain(GetChannelMixBuffer(channel), GetChannelMixBuffer(channel), last, delta,
|
||||
static_cast<s32>(worker_params.sample_count));
|
||||
worker_params.sample_count);
|
||||
}
|
||||
|
||||
void CommandGenerator::GenerateVoiceMixCommand(const MixVolumeBuffer& mix_volumes,
|
||||
const MixVolumeBuffer& last_mix_volumes,
|
||||
VoiceState& dsp_state, u32 mix_buffer_offset,
|
||||
u32 mix_buffer_count, u32 voice_index, s32 node_id) {
|
||||
VoiceState& dsp_state, s32 mix_buffer_offset,
|
||||
s32 mix_buffer_count, s32 voice_index, s32 node_id) {
|
||||
// Loop all our mix buffers
|
||||
for (size_t i = 0; i < mix_buffer_count; i++) {
|
||||
for (s32 i = 0; i < mix_buffer_count; i++) {
|
||||
if (last_mix_volumes[i] != 0.0f || mix_volumes[i] != 0.0f) {
|
||||
const auto delta = static_cast<float>((mix_volumes[i] - last_mix_volumes[i])) /
|
||||
static_cast<float>(worker_params.sample_count);
|
||||
|
@ -571,9 +558,9 @@ void CommandGenerator::GenerateVoiceMixCommand(const MixVolumeBuffer& mix_volume
|
|||
mix_volumes[i]);
|
||||
}
|
||||
|
||||
dsp_state.previous_samples[i] = ApplyMixRamp(
|
||||
GetMixBuffer(mix_buffer_offset + i), GetMixBuffer(voice_index), last_mix_volumes[i],
|
||||
delta, static_cast<s32>(worker_params.sample_count));
|
||||
dsp_state.previous_samples[i] =
|
||||
ApplyMixRamp(GetMixBuffer(mix_buffer_offset + i), GetMixBuffer(voice_index),
|
||||
last_mix_volumes[i], delta, worker_params.sample_count);
|
||||
} else {
|
||||
dsp_state.previous_samples[i] = 0;
|
||||
}
|
||||
|
@ -585,8 +572,7 @@ void CommandGenerator::GenerateSubMixCommand(ServerMixInfo& mix_info) {
|
|||
LOG_DEBUG(Audio, "(DSP_TRACE) GenerateSubMixCommand");
|
||||
}
|
||||
const auto& in_params = mix_info.GetInParams();
|
||||
GenerateDepopForMixBuffersCommand(static_cast<u32>(in_params.buffer_count),
|
||||
static_cast<u32>(in_params.buffer_offset),
|
||||
GenerateDepopForMixBuffersCommand(in_params.buffer_count, in_params.buffer_offset,
|
||||
in_params.sample_rate);
|
||||
|
||||
GenerateEffectCommand(mix_info);
|
||||
|
@ -600,18 +586,18 @@ void CommandGenerator::GenerateMixCommands(ServerMixInfo& mix_info) {
|
|||
}
|
||||
const auto& in_params = mix_info.GetInParams();
|
||||
if (in_params.dest_mix_id != AudioCommon::NO_MIX) {
|
||||
const auto& dest_mix = mix_context.GetInfo(static_cast<u32>(in_params.dest_mix_id));
|
||||
const auto& dest_mix = mix_context.GetInfo(in_params.dest_mix_id);
|
||||
const auto& dest_in_params = dest_mix.GetInParams();
|
||||
|
||||
const auto buffer_count = static_cast<u32>(in_params.buffer_count);
|
||||
const auto buffer_count = in_params.buffer_count;
|
||||
|
||||
for (u32 i = 0; i < buffer_count; i++) {
|
||||
for (u32 j = 0; j < static_cast<u32>(dest_in_params.buffer_count); j++) {
|
||||
for (s32 i = 0; i < buffer_count; i++) {
|
||||
for (s32 j = 0; j < dest_in_params.buffer_count; j++) {
|
||||
const auto mixed_volume = in_params.volume * in_params.mix_volume[i][j];
|
||||
if (mixed_volume != 0.0f) {
|
||||
GenerateMixCommand(static_cast<size_t>(dest_in_params.buffer_offset) + j,
|
||||
static_cast<size_t>(in_params.buffer_offset) + i,
|
||||
mixed_volume, static_cast<s32>(in_params.node_id));
|
||||
GenerateMixCommand(dest_in_params.buffer_offset + j,
|
||||
in_params.buffer_offset + i, mixed_volume,
|
||||
in_params.node_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -622,17 +608,15 @@ void CommandGenerator::GenerateMixCommands(ServerMixInfo& mix_info) {
|
|||
continue;
|
||||
}
|
||||
|
||||
const auto& dest_mix =
|
||||
mix_context.GetInfo(static_cast<u32>(destination_data->GetMixId()));
|
||||
const auto& dest_mix = mix_context.GetInfo(destination_data->GetMixId());
|
||||
const auto& dest_in_params = dest_mix.GetInParams();
|
||||
const auto mix_index = (base - 1) % in_params.buffer_count + in_params.buffer_offset;
|
||||
for (std::size_t i = 0; i < static_cast<std::size_t>(dest_in_params.buffer_count);
|
||||
i++) {
|
||||
const auto mixed_volume = in_params.volume * destination_data->GetMixVolume(i);
|
||||
if (mixed_volume != 0.0f) {
|
||||
GenerateMixCommand(static_cast<size_t>(dest_in_params.buffer_offset) + i,
|
||||
static_cast<size_t>(mix_index), mixed_volume,
|
||||
static_cast<s32>(in_params.node_id));
|
||||
GenerateMixCommand(dest_in_params.buffer_offset + i, mix_index, mixed_volume,
|
||||
in_params.node_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -651,8 +635,7 @@ void CommandGenerator::GenerateMixCommand(std::size_t output_offset, std::size_t
|
|||
auto* output = GetMixBuffer(output_offset);
|
||||
const auto* input = GetMixBuffer(input_offset);
|
||||
|
||||
const auto gain = static_cast<s32>(volume * 32768.0f);
|
||||
|
||||
const s32 gain = static_cast<s32>(volume * 32768.0f);
|
||||
// Mix with loop unrolling
|
||||
if (worker_params.sample_count % 4 == 0) {
|
||||
ApplyMix<4>(output, input, gain, worker_params.sample_count);
|
||||
|
@ -670,8 +653,7 @@ void CommandGenerator::GenerateFinalMixCommand() {
|
|||
auto& mix_info = mix_context.GetFinalMixInfo();
|
||||
const auto& in_params = mix_info.GetInParams();
|
||||
|
||||
GenerateDepopForMixBuffersCommand(static_cast<u32>(in_params.buffer_count),
|
||||
static_cast<u32>(in_params.buffer_offset),
|
||||
GenerateDepopForMixBuffersCommand(in_params.buffer_count, in_params.buffer_offset,
|
||||
in_params.sample_rate);
|
||||
|
||||
GenerateEffectCommand(mix_info);
|
||||
|
@ -685,16 +667,16 @@ void CommandGenerator::GenerateFinalMixCommand() {
|
|||
in_params.node_id, in_params.buffer_offset + i, in_params.buffer_offset + i,
|
||||
in_params.volume);
|
||||
}
|
||||
ApplyGainWithoutDelta(GetMixBuffer(static_cast<size_t>(in_params.buffer_offset + i)),
|
||||
GetMixBuffer(static_cast<size_t>(in_params.buffer_offset + i)), gain,
|
||||
static_cast<s32>(worker_params.sample_count));
|
||||
ApplyGainWithoutDelta(GetMixBuffer(in_params.buffer_offset + i),
|
||||
GetMixBuffer(in_params.buffer_offset + i), gain,
|
||||
worker_params.sample_count);
|
||||
}
|
||||
}
|
||||
|
||||
s32 CommandGenerator::DecodePcm16(ServerVoiceInfo& voice_info, VoiceState& dsp_state,
|
||||
s32 sample_count, s32 channel, std::size_t mix_offset) {
|
||||
const auto& in_params = voice_info.GetInParams();
|
||||
const auto& wave_buffer = in_params.wave_buffer[static_cast<u32>(dsp_state.wave_buffer_index)];
|
||||
const auto& wave_buffer = in_params.wave_buffer[dsp_state.wave_buffer_index];
|
||||
if (wave_buffer.buffer_address == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -707,26 +689,24 @@ s32 CommandGenerator::DecodePcm16(ServerVoiceInfo& voice_info, VoiceState& dsp_s
|
|||
const auto samples_remaining =
|
||||
(wave_buffer.end_sample_offset - wave_buffer.start_sample_offset) - dsp_state.offset;
|
||||
const auto start_offset =
|
||||
static_cast<size_t>((wave_buffer.start_sample_offset + dsp_state.offset) *
|
||||
in_params.channel_count) *
|
||||
((wave_buffer.start_sample_offset + dsp_state.offset) * in_params.channel_count) *
|
||||
sizeof(s16);
|
||||
const auto buffer_pos = wave_buffer.buffer_address + start_offset;
|
||||
const auto samples_processed = std::min(sample_count, samples_remaining);
|
||||
|
||||
if (in_params.channel_count == 1) {
|
||||
std::vector<s16> buffer(static_cast<size_t>(samples_processed));
|
||||
std::vector<s16> buffer(samples_processed);
|
||||
memory.ReadBlock(buffer_pos, buffer.data(), buffer.size() * sizeof(s16));
|
||||
for (std::size_t i = 0; i < buffer.size(); i++) {
|
||||
sample_buffer[mix_offset + i] = buffer[i];
|
||||
}
|
||||
} else {
|
||||
const auto channel_count = in_params.channel_count;
|
||||
std::vector<s16> buffer(static_cast<size_t>(samples_processed * channel_count));
|
||||
std::vector<s16> buffer(samples_processed * channel_count);
|
||||
memory.ReadBlock(buffer_pos, buffer.data(), buffer.size() * sizeof(s16));
|
||||
|
||||
for (std::size_t i = 0; i < static_cast<std::size_t>(samples_processed); i++) {
|
||||
sample_buffer[mix_offset + i] =
|
||||
buffer[i * static_cast<u32>(channel_count) + static_cast<u32>(channel)];
|
||||
sample_buffer[mix_offset + i] = buffer[i * channel_count + channel];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -736,7 +716,7 @@ s32 CommandGenerator::DecodePcm16(ServerVoiceInfo& voice_info, VoiceState& dsp_s
|
|||
s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_state,
|
||||
s32 sample_count, s32 channel, std::size_t mix_offset) {
|
||||
const auto& in_params = voice_info.GetInParams();
|
||||
const auto& wave_buffer = in_params.wave_buffer[static_cast<u32>(dsp_state.wave_buffer_index)];
|
||||
const auto& wave_buffer = in_params.wave_buffer[dsp_state.wave_buffer_index];
|
||||
if (wave_buffer.buffer_address == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -756,7 +736,7 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s
|
|||
constexpr std::size_t SAMPLES_PER_FRAME = 14;
|
||||
|
||||
auto frame_header = dsp_state.context.header;
|
||||
auto idx = static_cast<size_t>((frame_header >> 4) & 0xf);
|
||||
s32 idx = (frame_header >> 4) & 0xf;
|
||||
s32 scale = frame_header & 0xf;
|
||||
s16 yn1 = dsp_state.context.yn1;
|
||||
s16 yn2 = dsp_state.context.yn2;
|
||||
|
@ -773,10 +753,9 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s
|
|||
const auto samples_processed = std::min(sample_count, samples_remaining);
|
||||
const auto sample_pos = wave_buffer.start_sample_offset + dsp_state.offset;
|
||||
|
||||
const auto samples_remaining_in_frame = static_cast<u32>(sample_pos) % SAMPLES_PER_FRAME;
|
||||
auto position_in_frame =
|
||||
((static_cast<u32>(sample_pos) / SAMPLES_PER_FRAME) * NIBBLES_PER_SAMPLE) +
|
||||
samples_remaining_in_frame + (samples_remaining_in_frame != 0 ? 2 : 0);
|
||||
const auto samples_remaining_in_frame = sample_pos % SAMPLES_PER_FRAME;
|
||||
auto position_in_frame = ((sample_pos / SAMPLES_PER_FRAME) * NIBBLES_PER_SAMPLE) +
|
||||
samples_remaining_in_frame + (samples_remaining_in_frame != 0 ? 2 : 0);
|
||||
|
||||
const auto decode_sample = [&](const int nibble) -> s16 {
|
||||
const int xn = nibble * (1 << scale);
|
||||
|
@ -795,7 +774,7 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s
|
|||
|
||||
std::size_t buffer_offset{};
|
||||
std::vector<u8> buffer(
|
||||
std::max((static_cast<u32>(samples_processed) / FRAME_LEN) * SAMPLES_PER_FRAME, FRAME_LEN));
|
||||
std::max((samples_processed / FRAME_LEN) * SAMPLES_PER_FRAME, FRAME_LEN));
|
||||
memory.ReadBlock(wave_buffer.buffer_address + (position_in_frame / 2), buffer.data(),
|
||||
buffer.size());
|
||||
std::size_t cur_mix_offset = mix_offset;
|
||||
|
@ -805,7 +784,7 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s
|
|||
if (position_in_frame % NIBBLES_PER_SAMPLE == 0) {
|
||||
// Read header
|
||||
frame_header = buffer[buffer_offset++];
|
||||
idx = static_cast<size_t>((frame_header >> 4) & 0xf);
|
||||
idx = (frame_header >> 4) & 0xf;
|
||||
scale = frame_header & 0xf;
|
||||
coef1 = coeffs[idx * 2];
|
||||
coef2 = coeffs[idx * 2 + 1];
|
||||
|
@ -815,8 +794,8 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s
|
|||
if (remaining_samples >= static_cast<int>(SAMPLES_PER_FRAME)) {
|
||||
for (std::size_t i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
|
||||
// Sample 1
|
||||
const s32 s0 = SIGNED_NIBBLES[static_cast<u32>(buffer[buffer_offset] >> 4)];
|
||||
const s32 s1 = SIGNED_NIBBLES[static_cast<u32>(buffer[buffer_offset++] & 0xf)];
|
||||
const s32 s0 = SIGNED_NIBBLES[buffer[buffer_offset] >> 4];
|
||||
const s32 s1 = SIGNED_NIBBLES[buffer[buffer_offset++] & 0xf];
|
||||
const s16 sample_1 = decode_sample(s0);
|
||||
const s16 sample_2 = decode_sample(s1);
|
||||
sample_buffer[cur_mix_offset++] = sample_1;
|
||||
|
@ -828,14 +807,14 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s
|
|||
}
|
||||
}
|
||||
// Decode mid frame
|
||||
auto current_nibble = static_cast<s32>(buffer[buffer_offset]);
|
||||
if ((position_in_frame++ & 1) != 0) {
|
||||
s32 current_nibble = buffer[buffer_offset];
|
||||
if (position_in_frame++ & 0x1) {
|
||||
current_nibble &= 0xf;
|
||||
buffer_offset++;
|
||||
} else {
|
||||
current_nibble >>= 4;
|
||||
}
|
||||
const s16 sample = decode_sample(SIGNED_NIBBLES[static_cast<u32>(current_nibble)]);
|
||||
const s16 sample = decode_sample(SIGNED_NIBBLES[current_nibble]);
|
||||
sample_buffer[cur_mix_offset++] = sample;
|
||||
remaining_samples--;
|
||||
}
|
||||
|
@ -856,7 +835,7 @@ const s32* CommandGenerator::GetMixBuffer(std::size_t index) const {
|
|||
}
|
||||
|
||||
std::size_t CommandGenerator::GetMixChannelBufferOffset(s32 channel) const {
|
||||
return worker_params.mix_buffer_count + static_cast<u32>(channel);
|
||||
return worker_params.mix_buffer_count + channel;
|
||||
}
|
||||
|
||||
std::size_t CommandGenerator::GetTotalMixBufferCount() const {
|
||||
|
@ -864,11 +843,11 @@ std::size_t CommandGenerator::GetTotalMixBufferCount() const {
|
|||
}
|
||||
|
||||
s32* CommandGenerator::GetChannelMixBuffer(s32 channel) {
|
||||
return GetMixBuffer(worker_params.mix_buffer_count + static_cast<u32>(channel));
|
||||
return GetMixBuffer(worker_params.mix_buffer_count + channel);
|
||||
}
|
||||
|
||||
const s32* CommandGenerator::GetChannelMixBuffer(s32 channel) const {
|
||||
return GetMixBuffer(worker_params.mix_buffer_count + static_cast<u32>(channel));
|
||||
return GetMixBuffer(worker_params.mix_buffer_count + channel);
|
||||
}
|
||||
|
||||
void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* output,
|
||||
|
@ -916,10 +895,9 @@ void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* o
|
|||
|
||||
s32 samples_read{};
|
||||
while (samples_read < samples_to_read) {
|
||||
const auto& wave_buffer =
|
||||
in_params.wave_buffer[static_cast<u32>(dsp_state.wave_buffer_index)];
|
||||
const auto& wave_buffer = in_params.wave_buffer[dsp_state.wave_buffer_index];
|
||||
// No more data can be read
|
||||
if (!dsp_state.is_wave_buffer_valid[static_cast<u32>(dsp_state.wave_buffer_index)]) {
|
||||
if (!dsp_state.is_wave_buffer_valid[dsp_state.wave_buffer_index]) {
|
||||
is_buffer_completed = true;
|
||||
break;
|
||||
}
|
||||
|
@ -943,7 +921,7 @@ void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* o
|
|||
UNREACHABLE_MSG("Unimplemented sample format={}", in_params.sample_format);
|
||||
}
|
||||
|
||||
temp_mix_offset += static_cast<size_t>(samples_decoded);
|
||||
temp_mix_offset += samples_decoded;
|
||||
samples_read += samples_decoded;
|
||||
dsp_state.offset += samples_decoded;
|
||||
dsp_state.played_sample_count += samples_decoded;
|
||||
|
@ -966,12 +944,10 @@ void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* o
|
|||
} else {
|
||||
|
||||
// Update our wave buffer states
|
||||
dsp_state.is_wave_buffer_valid[static_cast<u32>(dsp_state.wave_buffer_index)] =
|
||||
false;
|
||||
dsp_state.is_wave_buffer_valid[dsp_state.wave_buffer_index] = false;
|
||||
dsp_state.wave_buffer_consumed++;
|
||||
dsp_state.wave_buffer_index =
|
||||
static_cast<u32>(dsp_state.wave_buffer_index + 1) %
|
||||
AudioCommon::MAX_WAVE_BUFFERS;
|
||||
(dsp_state.wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS;
|
||||
if (wave_buffer.end_of_stream) {
|
||||
dsp_state.played_sample_count = 0;
|
||||
}
|
||||
|
@ -981,20 +957,16 @@ void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* o
|
|||
|
||||
if (in_params.behavior_flags.is_pitch_and_src_skipped.Value()) {
|
||||
// No need to resample
|
||||
std::memcpy(output, sample_buffer.data(),
|
||||
static_cast<size_t>(samples_read) * sizeof(s32));
|
||||
std::memcpy(output, sample_buffer.data(), samples_read * sizeof(s32));
|
||||
} else {
|
||||
{
|
||||
const auto begin = sample_buffer.begin() + static_cast<ptrdiff_t>(temp_mix_offset);
|
||||
const auto end = begin + (samples_to_read - samples_read);
|
||||
std::fill(begin, end, 0);
|
||||
}
|
||||
std::fill(sample_buffer.begin() + temp_mix_offset,
|
||||
sample_buffer.begin() + temp_mix_offset + (samples_to_read - samples_read),
|
||||
0);
|
||||
AudioCore::Resample(output, sample_buffer.data(), resample_rate, dsp_state.fraction,
|
||||
static_cast<size_t>(samples_to_output));
|
||||
samples_to_output);
|
||||
// Resample
|
||||
for (std::size_t i = 0; i < AudioCommon::MAX_SAMPLE_HISTORY; i++) {
|
||||
dsp_state.sample_history[i] =
|
||||
sample_buffer[static_cast<size_t>(samples_to_read) + i];
|
||||
dsp_state.sample_history[i] = sample_buffer[samples_to_read + i];
|
||||
}
|
||||
}
|
||||
output += samples_to_output;
|
||||
|
|
|
@ -50,12 +50,12 @@ public:
|
|||
private:
|
||||
void GenerateDataSourceCommand(ServerVoiceInfo& voice_info, VoiceState& dsp_state, s32 channel);
|
||||
void GenerateBiquadFilterCommandForVoice(ServerVoiceInfo& voice_info, VoiceState& dsp_state,
|
||||
u32 mix_buffer_count, s32 channel);
|
||||
s32 mix_buffer_count, s32 channel);
|
||||
void GenerateVolumeRampCommand(float last_volume, float current_volume, s32 channel,
|
||||
s32 node_id);
|
||||
void GenerateVoiceMixCommand(const MixVolumeBuffer& mix_volumes,
|
||||
const MixVolumeBuffer& last_mix_volumes, VoiceState& dsp_state,
|
||||
u32 mix_buffer_offset, u32 mix_buffer_count, u32 voice_index,
|
||||
s32 mix_buffer_offset, s32 mix_buffer_count, s32 voice_index,
|
||||
s32 node_id);
|
||||
void GenerateSubMixCommand(ServerMixInfo& mix_info);
|
||||
void GenerateMixCommands(ServerMixInfo& mix_info);
|
||||
|
|
|
@ -202,7 +202,7 @@ long CubebSinkStream::DataCallback(cubeb_stream* stream, void* user_data, const
|
|||
}
|
||||
|
||||
const std::size_t num_channels = impl->GetNumChannels();
|
||||
const std::size_t samples_to_write = num_channels * static_cast<u64>(num_frames);
|
||||
const std::size_t samples_to_write = num_channels * num_frames;
|
||||
std::size_t samples_written;
|
||||
|
||||
/*
|
||||
|
|
|
@ -27,7 +27,7 @@ private:
|
|||
std::vector<SinkStreamPtr> sink_streams;
|
||||
|
||||
#ifdef _WIN32
|
||||
s32 com_init_result = 0;
|
||||
u32 com_init_result = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ ResultCode InfoUpdater::UpdateMixes(MixContext& mix_context, std::size_t mix_buf
|
|||
std::size_t total_buffer_count{};
|
||||
for (std::size_t i = 0; i < mix_count; i++) {
|
||||
const auto& in = mix_in_params[i];
|
||||
total_buffer_count += static_cast<size_t>(in.buffer_count);
|
||||
total_buffer_count += in.buffer_count;
|
||||
if (static_cast<std::size_t>(in.dest_mix_id) > mix_count &&
|
||||
in.dest_mix_id != AudioCommon::NO_MIX && in.mix_id != AudioCommon::FINAL_MIX) {
|
||||
LOG_ERROR(
|
||||
|
@ -379,7 +379,7 @@ ResultCode InfoUpdater::UpdateMixes(MixContext& mix_context, std::size_t mix_buf
|
|||
const auto& mix_in = mix_in_params[i];
|
||||
std::size_t target_mix{};
|
||||
if (behavior_info.IsMixInParameterDirtyOnlyUpdateSupported()) {
|
||||
target_mix = static_cast<size_t>(mix_in.mix_id);
|
||||
target_mix = mix_in.mix_id;
|
||||
} else {
|
||||
// Non dirty supported games just use i instead of the actual mix_id
|
||||
target_mix = i;
|
||||
|
|
|
@ -62,7 +62,7 @@ void MixContext::UpdateDistancesFromFinalMix() {
|
|||
distance_to_final_mix = AudioCommon::NO_FINAL_MIX;
|
||||
break;
|
||||
} else {
|
||||
const auto& dest_mix = GetInfo(static_cast<u32>(mix_id));
|
||||
const auto& dest_mix = GetInfo(mix_id);
|
||||
const auto dest_mix_distance = dest_mix.GetInParams().final_mix_distance;
|
||||
|
||||
if (dest_mix_distance == AudioCommon::NO_FINAL_MIX) {
|
||||
|
@ -129,7 +129,7 @@ bool MixContext::TsortInfo(SplitterContext& splitter_context) {
|
|||
std::size_t info_id{};
|
||||
for (auto itr = sorted_list.rbegin(); itr != sorted_list.rend(); ++itr) {
|
||||
// Set our sorted info
|
||||
sorted_info[info_id++] = &GetInfo(static_cast<u32>(*itr));
|
||||
sorted_info[info_id++] = &GetInfo(*itr);
|
||||
}
|
||||
|
||||
// Calculate the mix buffer offset
|
||||
|
@ -218,8 +218,7 @@ bool ServerMixInfo::Update(EdgeMatrix& edge_matrix, const MixInfo::InParams& mix
|
|||
for (std::size_t i = 0; i < effect_count; i++) {
|
||||
auto* effect_info = effect_context.GetInfo(i);
|
||||
if (effect_info->GetMixID() == in_params.mix_id) {
|
||||
const auto processing_order = static_cast<u32>(effect_info->GetProcessingOrder());
|
||||
effect_processing_order[processing_order] = static_cast<s32>(i);
|
||||
effect_processing_order[effect_info->GetProcessingOrder()] = static_cast<s32>(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +265,7 @@ bool ServerMixInfo::UpdateConnection(EdgeMatrix& edge_matrix, const MixInfo::InP
|
|||
if (in_params.dest_mix_id == mix_in.dest_mix_id &&
|
||||
in_params.splitter_id == mix_in.splitter_id &&
|
||||
((in_params.splitter_id == AudioCommon::NO_SPLITTER) ||
|
||||
!splitter_context.GetInfo(static_cast<u32>(in_params.splitter_id)).HasNewConnection())) {
|
||||
!splitter_context.GetInfo(in_params.splitter_id).HasNewConnection())) {
|
||||
return false;
|
||||
}
|
||||
// Remove current edges for mix id
|
||||
|
@ -276,11 +275,11 @@ bool ServerMixInfo::UpdateConnection(EdgeMatrix& edge_matrix, const MixInfo::InP
|
|||
edge_matrix.Connect(in_params.mix_id, mix_in.dest_mix_id);
|
||||
} else if (mix_in.splitter_id != AudioCommon::NO_SPLITTER) {
|
||||
// Recurse our splitter linked and set our edges
|
||||
auto& splitter_info = splitter_context.GetInfo(static_cast<u32>(mix_in.splitter_id));
|
||||
const auto length = static_cast<size_t>(splitter_info.GetLength());
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
auto& splitter_info = splitter_context.GetInfo(mix_in.splitter_id);
|
||||
const auto length = splitter_info.GetLength();
|
||||
for (s32 i = 0; i < length; i++) {
|
||||
const auto* splitter_destination =
|
||||
splitter_context.GetDestinationData(static_cast<u32>(mix_in.splitter_id), i);
|
||||
splitter_context.GetDestinationData(mix_in.splitter_id, i);
|
||||
if (splitter_destination == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -23,9 +23,8 @@ bool SinkContext::InUse() const {
|
|||
}
|
||||
|
||||
std::vector<u8> SinkContext::OutputBuffers() const {
|
||||
const auto output_use_count = static_cast<size_t>(use_count);
|
||||
std::vector<u8> buffer_ret(output_use_count);
|
||||
std::memcpy(buffer_ret.data(), buffers.data(), output_use_count);
|
||||
std::vector<u8> buffer_ret(use_count);
|
||||
std::memcpy(buffer_ret.data(), buffers.data(), use_count);
|
||||
return buffer_ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ std::size_t ServerSplitterInfo::Update(SplitterInfo::InInfoPrams& header) {
|
|||
new_connection = true;
|
||||
// We need to update the size here due to the splitter bug being present and providing an
|
||||
// incorrect size. We're suppose to also update the header here but we just ignore and continue
|
||||
return (sizeof(s32_le) * static_cast<size_t>(header.length - 1)) + (sizeof(s32_le) * 3);
|
||||
return (sizeof(s32_le) * (header.length - 1)) + (sizeof(s32_le) * 3);
|
||||
}
|
||||
|
||||
ServerSplitterDestinationData* ServerSplitterInfo::GetHead() {
|
||||
|
@ -306,14 +306,13 @@ bool SplitterContext::UpdateInfo(const std::vector<u8>& input, std::size_t& inpu
|
|||
break;
|
||||
}
|
||||
|
||||
const auto send_id = static_cast<std::size_t>(header.send_id);
|
||||
if (header.send_id < 0 || send_id > info_count) {
|
||||
if (header.send_id < 0 || static_cast<std::size_t>(header.send_id) > info_count) {
|
||||
LOG_ERROR(Audio, "Bad splitter data id");
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateOffsets(sizeof(SplitterInfo::InInfoPrams));
|
||||
auto& info = GetInfo(send_id);
|
||||
auto& info = GetInfo(header.send_id);
|
||||
if (!RecomposeDestination(info, header, input, input_offset)) {
|
||||
LOG_ERROR(Audio, "Failed to recompose destination for splitter!");
|
||||
return false;
|
||||
|
@ -349,12 +348,11 @@ bool SplitterContext::UpdateData(const std::vector<u8>& input, std::size_t& inpu
|
|||
break;
|
||||
}
|
||||
|
||||
const auto splitter_id = static_cast<std::size_t>(header.splitter_id);
|
||||
if (header.splitter_id < 0 || splitter_id > data_count) {
|
||||
if (header.splitter_id < 0 || static_cast<std::size_t>(header.splitter_id) > data_count) {
|
||||
LOG_ERROR(Audio, "Bad splitter data id");
|
||||
break;
|
||||
}
|
||||
GetData(splitter_id).Update(header);
|
||||
GetData(header.splitter_id).Update(header);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -388,9 +386,9 @@ bool SplitterContext::RecomposeDestination(ServerSplitterInfo& info,
|
|||
return true;
|
||||
}
|
||||
|
||||
auto* start_head = &GetData(static_cast<u32>(header.resource_id_base));
|
||||
auto* start_head = &GetData(header.resource_id_base);
|
||||
current_head = start_head;
|
||||
std::vector<s32_le> resource_ids(static_cast<size_t>(size - 1));
|
||||
std::vector<s32_le> resource_ids(size - 1);
|
||||
if (!AudioCommon::CanConsumeBuffer(input.size(), input_offset,
|
||||
resource_ids.size() * sizeof(s32_le))) {
|
||||
LOG_ERROR(Audio, "Buffer is an invalid size!");
|
||||
|
@ -399,8 +397,8 @@ bool SplitterContext::RecomposeDestination(ServerSplitterInfo& info,
|
|||
std::memcpy(resource_ids.data(), input.data() + input_offset,
|
||||
resource_ids.size() * sizeof(s32_le));
|
||||
|
||||
for (const auto resource_id : resource_ids) {
|
||||
auto* head = &GetData(static_cast<u32>(resource_id));
|
||||
for (auto resource_id : resource_ids) {
|
||||
auto* head = &GetData(resource_id);
|
||||
current_head->SetNextDestination(head);
|
||||
current_head = head;
|
||||
}
|
||||
|
@ -446,7 +444,7 @@ bool NodeStates::DepthFirstSearch(EdgeMatrix& edge_matrix) {
|
|||
const auto node_id = static_cast<s32>(i);
|
||||
|
||||
// If we don't have a state, send to our index stack for work
|
||||
if (GetState(i) == State::NoState) {
|
||||
if (GetState(i) == NodeStates::State::NoState) {
|
||||
index_stack.push(node_id);
|
||||
}
|
||||
|
||||
|
@ -455,19 +453,19 @@ bool NodeStates::DepthFirstSearch(EdgeMatrix& edge_matrix) {
|
|||
// Get the current node
|
||||
const auto current_stack_index = index_stack.top();
|
||||
// Check if we've seen the node yet
|
||||
const auto index_state = GetState(static_cast<u32>(current_stack_index));
|
||||
if (index_state == State::NoState) {
|
||||
const auto index_state = GetState(current_stack_index);
|
||||
if (index_state == NodeStates::State::NoState) {
|
||||
// Mark the node as seen
|
||||
UpdateState(State::InFound, static_cast<u32>(current_stack_index));
|
||||
} else if (index_state == State::InFound) {
|
||||
UpdateState(NodeStates::State::InFound, current_stack_index);
|
||||
} else if (index_state == NodeStates::State::InFound) {
|
||||
// We've seen this node before, mark it as completed
|
||||
UpdateState(State::InCompleted, static_cast<u32>(current_stack_index));
|
||||
UpdateState(NodeStates::State::InCompleted, current_stack_index);
|
||||
// Update our index list
|
||||
PushTsortResult(current_stack_index);
|
||||
// Pop the stack
|
||||
index_stack.pop();
|
||||
continue;
|
||||
} else if (index_state == State::InCompleted) {
|
||||
} else if (index_state == NodeStates::State::InCompleted) {
|
||||
// If our node is already sorted, clear it
|
||||
index_stack.pop();
|
||||
continue;
|
||||
|
@ -481,11 +479,11 @@ bool NodeStates::DepthFirstSearch(EdgeMatrix& edge_matrix) {
|
|||
}
|
||||
|
||||
// Check if our node exists
|
||||
const auto node_state = GetState(static_cast<u32>(j));
|
||||
if (node_state == State::NoState) {
|
||||
const auto node_state = GetState(j);
|
||||
if (node_state == NodeStates::State::NoState) {
|
||||
// Add more work
|
||||
index_stack.push(j);
|
||||
} else if (node_state == State::InFound) {
|
||||
} else if (node_state == NodeStates::State::InFound) {
|
||||
UNREACHABLE_MSG("Node start marked as found");
|
||||
ResetState();
|
||||
return false;
|
||||
|
@ -509,17 +507,17 @@ void NodeStates::ResetState() {
|
|||
}
|
||||
}
|
||||
|
||||
void NodeStates::UpdateState(State state, std::size_t i) {
|
||||
void NodeStates::UpdateState(NodeStates::State state, std::size_t i) {
|
||||
switch (state) {
|
||||
case State::NoState:
|
||||
case NodeStates::State::NoState:
|
||||
was_node_found[i] = false;
|
||||
was_node_completed[i] = false;
|
||||
break;
|
||||
case State::InFound:
|
||||
case NodeStates::State::InFound:
|
||||
was_node_found[i] = true;
|
||||
was_node_completed[i] = false;
|
||||
break;
|
||||
case State::InCompleted:
|
||||
case NodeStates::State::InCompleted:
|
||||
was_node_found[i] = false;
|
||||
was_node_completed[i] = true;
|
||||
break;
|
||||
|
@ -530,13 +528,13 @@ NodeStates::State NodeStates::GetState(std::size_t i) {
|
|||
ASSERT(i < node_count);
|
||||
if (was_node_found[i]) {
|
||||
// If our node exists in our found list
|
||||
return State::InFound;
|
||||
return NodeStates::State::InFound;
|
||||
} else if (was_node_completed[i]) {
|
||||
// If node is in the completed list
|
||||
return State::InCompleted;
|
||||
return NodeStates::State::InCompleted;
|
||||
} else {
|
||||
// If in neither
|
||||
return State::NoState;
|
||||
return NodeStates::State::NoState;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -603,16 +601,16 @@ std::size_t EdgeMatrix::GetNodeCount() const {
|
|||
|
||||
void EdgeMatrix::SetState(s32 a, s32 b, bool state) {
|
||||
ASSERT(InRange(a, b));
|
||||
edge_matrix.at(static_cast<u32>(a) * node_count + static_cast<u32>(b)) = state;
|
||||
edge_matrix.at(a * node_count + b) = state;
|
||||
}
|
||||
|
||||
bool EdgeMatrix::GetState(s32 a, s32 b) {
|
||||
ASSERT(InRange(a, b));
|
||||
return edge_matrix.at(static_cast<u32>(a) * node_count + static_cast<u32>(b));
|
||||
return edge_matrix.at(a * node_count + b);
|
||||
}
|
||||
|
||||
bool EdgeMatrix::InRange(s32 a, s32 b) const {
|
||||
const std::size_t pos = static_cast<u32>(a) * node_count + static_cast<u32>(b);
|
||||
const std::size_t pos = a * node_count + b;
|
||||
return pos < (node_count * node_count);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include "common/common_types.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#endif
|
||||
#include <SoundTouch.h>
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace AudioCore {
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ void ServerVoiceInfo::UpdateParameters(const VoiceInfo::InParams& voice_in,
|
|||
BehaviorInfo& behavior_info) {
|
||||
in_params.in_use = voice_in.is_in_use;
|
||||
in_params.id = voice_in.id;
|
||||
in_params.node_id = static_cast<s32>(voice_in.node_id);
|
||||
in_params.node_id = voice_in.node_id;
|
||||
in_params.last_playstate = in_params.current_playstate;
|
||||
switch (voice_in.play_state) {
|
||||
case PlayState::Paused:
|
||||
|
@ -220,10 +220,8 @@ void ServerVoiceInfo::UpdateWaveBuffer(ServerWaveBuffer& out_wavebuffer,
|
|||
if (sample_format == SampleFormat::Pcm16) {
|
||||
const auto buffer_size = in_wave_buffer.buffer_size;
|
||||
if (in_wave_buffer.start_sample_offset < 0 || in_wave_buffer.end_sample_offset < 0 ||
|
||||
(buffer_size <
|
||||
(sizeof(s16) * static_cast<u32>(in_wave_buffer.start_sample_offset))) ||
|
||||
(buffer_size <
|
||||
(sizeof(s16) * static_cast<u32>(in_wave_buffer.end_sample_offset)))) {
|
||||
(buffer_size < (sizeof(s16) * in_wave_buffer.start_sample_offset)) ||
|
||||
(buffer_size < (sizeof(s16) * in_wave_buffer.end_sample_offset))) {
|
||||
// TODO(ogniK): Write error info
|
||||
return;
|
||||
}
|
||||
|
@ -256,8 +254,8 @@ void ServerVoiceInfo::WriteOutStatus(
|
|||
voice_out.played_sample_count = 0;
|
||||
voice_out.voice_dropped = false;
|
||||
} else if (!in_params.is_new) {
|
||||
voice_out.wave_buffer_consumed = static_cast<u32>(voice_states[0]->wave_buffer_consumed);
|
||||
voice_out.played_sample_count = static_cast<u64>(voice_states[0]->played_sample_count);
|
||||
voice_out.wave_buffer_consumed = voice_states[0]->wave_buffer_consumed;
|
||||
voice_out.played_sample_count = voice_states[0]->played_sample_count;
|
||||
voice_out.voice_dropped = in_params.voice_drop_flag;
|
||||
} else {
|
||||
voice_out.wave_buffer_consumed = 0;
|
||||
|
@ -295,8 +293,8 @@ bool ServerVoiceInfo::UpdateForCommandGeneration(VoiceContext& voice_context) {
|
|||
in_params.is_new = false;
|
||||
}
|
||||
|
||||
const auto channel_count = static_cast<size_t>(in_params.channel_count);
|
||||
for (size_t i = 0; i < channel_count; i++) {
|
||||
const s32 channel_count = in_params.channel_count;
|
||||
for (s32 i = 0; i < channel_count; i++) {
|
||||
const auto channel_resource = in_params.voice_channel_resource_id[i];
|
||||
dsp_voice_states[i] =
|
||||
&voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource));
|
||||
|
@ -305,9 +303,8 @@ bool ServerVoiceInfo::UpdateForCommandGeneration(VoiceContext& voice_context) {
|
|||
}
|
||||
|
||||
void ServerVoiceInfo::ResetResources(VoiceContext& voice_context) {
|
||||
const auto channel_count = static_cast<size_t>(in_params.channel_count);
|
||||
|
||||
for (size_t i = 0; i < channel_count; i++) {
|
||||
const s32 channel_count = in_params.channel_count;
|
||||
for (s32 i = 0; i < channel_count; i++) {
|
||||
const auto channel_resource = in_params.voice_channel_resource_id[i];
|
||||
auto& dsp_state =
|
||||
voice_context.GetDspSharedState(static_cast<std::size_t>(channel_resource));
|
||||
|
@ -328,9 +325,9 @@ bool ServerVoiceInfo::UpdateParametersForCommandGeneration(
|
|||
|
||||
switch (in_params.current_playstate) {
|
||||
case ServerPlayState::Play: {
|
||||
for (size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) {
|
||||
for (std::size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) {
|
||||
if (!in_params.wave_buffer[i].sent_to_dsp) {
|
||||
for (size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) {
|
||||
for (s32 channel = 0; channel < channel_count; channel++) {
|
||||
dsp_voice_states[channel]->is_wave_buffer_valid[i] = true;
|
||||
}
|
||||
in_params.wave_buffer[i].sent_to_dsp = true;
|
||||
|
@ -347,13 +344,12 @@ bool ServerVoiceInfo::UpdateParametersForCommandGeneration(
|
|||
case ServerPlayState::RequestStop: {
|
||||
for (std::size_t i = 0; i < AudioCommon::MAX_WAVE_BUFFERS; i++) {
|
||||
in_params.wave_buffer[i].sent_to_dsp = true;
|
||||
for (std::size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) {
|
||||
for (s32 channel = 0; channel < channel_count; channel++) {
|
||||
auto* dsp_state = dsp_voice_states[channel];
|
||||
|
||||
if (dsp_state->is_wave_buffer_valid[i]) {
|
||||
dsp_state->wave_buffer_index =
|
||||
static_cast<s32>(static_cast<u32>(dsp_state->wave_buffer_index + 1) %
|
||||
AudioCommon::MAX_WAVE_BUFFERS);
|
||||
(dsp_state->wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS;
|
||||
dsp_state->wave_buffer_consumed++;
|
||||
}
|
||||
|
||||
|
@ -361,7 +357,7 @@ bool ServerVoiceInfo::UpdateParametersForCommandGeneration(
|
|||
}
|
||||
}
|
||||
|
||||
for (size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) {
|
||||
for (s32 channel = 0; channel < channel_count; channel++) {
|
||||
auto* dsp_state = dsp_voice_states[channel];
|
||||
dsp_state->offset = 0;
|
||||
dsp_state->played_sample_count = 0;
|
||||
|
@ -387,16 +383,15 @@ void ServerVoiceInfo::FlushWaveBuffers(
|
|||
auto wave_head = in_params.wave_bufffer_head;
|
||||
|
||||
for (u8 i = 0; i < flush_count; i++) {
|
||||
in_params.wave_buffer[static_cast<u16>(wave_head)].sent_to_dsp = true;
|
||||
for (size_t channel = 0; channel < static_cast<size_t>(channel_count); channel++) {
|
||||
in_params.wave_buffer[wave_head].sent_to_dsp = true;
|
||||
for (s32 channel = 0; channel < channel_count; channel++) {
|
||||
auto* dsp_state = dsp_voice_states[channel];
|
||||
dsp_state->wave_buffer_consumed++;
|
||||
dsp_state->is_wave_buffer_valid[static_cast<u16>(wave_head)] = false;
|
||||
dsp_state->wave_buffer_index = static_cast<s32>(
|
||||
static_cast<u32>(dsp_state->wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS);
|
||||
dsp_state->is_wave_buffer_valid[wave_head] = false;
|
||||
dsp_state->wave_buffer_index =
|
||||
(dsp_state->wave_buffer_index + 1) % AudioCommon::MAX_WAVE_BUFFERS;
|
||||
}
|
||||
wave_head =
|
||||
static_cast<s16>(static_cast<u32>(wave_head + 1) % AudioCommon::MAX_WAVE_BUFFERS);
|
||||
wave_head = (wave_head + 1) % AudioCommon::MAX_WAVE_BUFFERS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,7 +483,7 @@ s32 VoiceContext::DecodePcm16(s32* output_buffer, ServerWaveBuffer* wave_buffer,
|
|||
const auto samples_remaining =
|
||||
(wave_buffer->end_sample_offset - wave_buffer->start_sample_offset) - buffer_offset;
|
||||
const auto start_offset = (wave_buffer->start_sample_offset + buffer_offset) * channel_count;
|
||||
const auto buffer_pos = wave_buffer->buffer_address + static_cast<VAddr>(start_offset);
|
||||
const auto buffer_pos = wave_buffer->buffer_address + start_offset;
|
||||
|
||||
s16* buffer_data = reinterpret_cast<s16*>(memory.GetPointer(buffer_pos));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue