Merge pull request #4719 from lioncash/audio-warn

audio_core: Resolve sign conversion warnings
This commit is contained in:
bunnei 2020-09-27 01:52:59 -07:00 committed by GitHub
commit a8be822e8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 38 deletions

View File

@ -44,6 +44,16 @@ add_library(audio_core STATIC
create_target_directory_groups(audio_core) create_target_directory_groups(audio_core)
if (NOT MSVC)
target_compile_options(audio_core PRIVATE
-Werror=ignored-qualifiers
-Werror=implicit-fallthrough
-Werror=reorder
-Werror=sign-compare
-Werror=unused-variable
)
endif()
target_link_libraries(audio_core PUBLIC common core) target_link_libraries(audio_core PUBLIC common core)
target_link_libraries(audio_core PRIVATE SoundTouch) target_link_libraries(audio_core PRIVATE SoundTouch)

View File

@ -152,7 +152,7 @@ void CommandGenerator::GenerateVoiceCommand(ServerVoiceInfo& voice_info) {
if (!destination_data->IsConfigured()) { if (!destination_data->IsConfigured()) {
continue; continue;
} }
if (destination_data->GetMixId() >= mix_context.GetCount()) { if (destination_data->GetMixId() >= static_cast<int>(mix_context.GetCount())) {
continue; continue;
} }
@ -435,7 +435,7 @@ void CommandGenerator::GenerateAuxCommand(s32 mix_buffer_offset, EffectBase* inf
GetMixBuffer(output_index), worker_params.sample_count, offset, write_count); GetMixBuffer(output_index), worker_params.sample_count, offset, write_count);
memory.WriteBlock(aux->GetRecvInfo(), &recv_info, sizeof(AuxInfoDSP)); memory.WriteBlock(aux->GetRecvInfo(), &recv_info, sizeof(AuxInfoDSP));
if (samples_read != worker_params.sample_count && if (samples_read != static_cast<int>(worker_params.sample_count) &&
samples_read <= params.sample_count) { samples_read <= params.sample_count) {
std::memset(GetMixBuffer(output_index), 0, params.sample_count - samples_read); std::memset(GetMixBuffer(output_index), 0, params.sample_count - samples_read);
} }
@ -611,7 +611,8 @@ void CommandGenerator::GenerateMixCommands(ServerMixInfo& mix_info) {
const auto& dest_mix = mix_context.GetInfo(destination_data->GetMixId()); const auto& dest_mix = mix_context.GetInfo(destination_data->GetMixId());
const auto& dest_in_params = dest_mix.GetInParams(); const auto& dest_in_params = dest_mix.GetInParams();
const auto mix_index = (base - 1) % in_params.buffer_count + in_params.buffer_offset; const auto mix_index = (base - 1) % in_params.buffer_count + in_params.buffer_offset;
for (std::size_t i = 0; i < dest_in_params.buffer_count; i++) { 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); const auto mixed_volume = in_params.volume * destination_data->GetMixVolume(i);
if (mixed_volume != 0.0f) { if (mixed_volume != 0.0f) {
GenerateMixCommand(dest_in_params.buffer_offset + i, mix_index, mixed_volume, GenerateMixCommand(dest_in_params.buffer_offset + i, mix_index, mixed_volume,
@ -704,7 +705,7 @@ s32 CommandGenerator::DecodePcm16(ServerVoiceInfo& voice_info, VoiceState& dsp_s
std::vector<s16> buffer(samples_processed * channel_count); std::vector<s16> buffer(samples_processed * channel_count);
memory.ReadBlock(buffer_pos, buffer.data(), buffer.size() * sizeof(s16)); memory.ReadBlock(buffer_pos, buffer.data(), buffer.size() * sizeof(s16));
for (std::size_t i = 0; i < samples_processed; i++) { for (std::size_t i = 0; i < static_cast<std::size_t>(samples_processed); i++) {
sample_buffer[mix_offset + i] = buffer[i * channel_count + channel]; sample_buffer[mix_offset + i] = buffer[i * channel_count + channel];
} }
} }
@ -789,7 +790,7 @@ s32 CommandGenerator::DecodeAdpcm(ServerVoiceInfo& voice_info, VoiceState& dsp_s
position_in_frame += 2; position_in_frame += 2;
// Decode entire frame // Decode entire frame
if (remaining_samples >= SAMPLES_PER_FRAME) { if (remaining_samples >= static_cast<int>(SAMPLES_PER_FRAME)) {
for (std::size_t i = 0; i < SAMPLES_PER_FRAME / 2; i++) { for (std::size_t i = 0; i < SAMPLES_PER_FRAME / 2; i++) {
// Sample 1 // Sample 1
@ -866,7 +867,6 @@ void CommandGenerator::DecodeFromWaveBuffers(ServerVoiceInfo& voice_info, s32* o
const auto resample_rate = static_cast<s32>( const auto resample_rate = static_cast<s32>(
static_cast<float>(in_params.sample_rate) / static_cast<float>(target_sample_rate) * static_cast<float>(in_params.sample_rate) / static_cast<float>(target_sample_rate) *
static_cast<float>(static_cast<s32>(in_params.pitch * 32768.0f))); static_cast<float>(static_cast<s32>(in_params.pitch * 32768.0f)));
auto* output_base = output;
if (dsp_state.fraction + sample_count * resample_rate > if (dsp_state.fraction + sample_count * resample_rate >
static_cast<s32>(SCALED_MIX_BUFFER_SIZE - 4ULL)) { static_cast<s32>(SCALED_MIX_BUFFER_SIZE - 4ULL)) {
return; return;

View File

@ -184,19 +184,19 @@ void EffectAuxInfo::UpdateForCommandGeneration() {
} }
} }
const VAddr EffectAuxInfo::GetSendInfo() const { VAddr EffectAuxInfo::GetSendInfo() const {
return send_info; return send_info;
} }
const VAddr EffectAuxInfo::GetSendBuffer() const { VAddr EffectAuxInfo::GetSendBuffer() const {
return send_buffer; return send_buffer;
} }
const VAddr EffectAuxInfo::GetRecvInfo() const { VAddr EffectAuxInfo::GetRecvInfo() const {
return recv_info; return recv_info;
} }
const VAddr EffectAuxInfo::GetRecvBuffer() const { VAddr EffectAuxInfo::GetRecvBuffer() const {
return recv_buffer; return recv_buffer;
} }

View File

@ -166,13 +166,13 @@ public:
std::array<u8, 0xa0> raw; std::array<u8, 0xa0> raw;
}; };
}; };
static_assert(sizeof(EffectInfo::InParams) == 0xc0, "InParams is an invalid size"); static_assert(sizeof(InParams) == 0xc0, "InParams is an invalid size");
struct OutParams { struct OutParams {
UsageStatus status{}; UsageStatus status{};
INSERT_PADDING_BYTES(15); INSERT_PADDING_BYTES(15);
}; };
static_assert(sizeof(EffectInfo::OutParams) == 0x10, "OutParams is an invalid size"); static_assert(sizeof(OutParams) == 0x10, "OutParams is an invalid size");
}; };
struct AuxAddress { struct AuxAddress {
@ -184,8 +184,8 @@ struct AuxAddress {
class EffectBase { class EffectBase {
public: public:
EffectBase(EffectType effect_type); explicit EffectBase(EffectType effect_type);
~EffectBase(); virtual ~EffectBase();
virtual void Update(EffectInfo::InParams& in_params) = 0; virtual void Update(EffectInfo::InParams& in_params) = 0;
virtual void UpdateForCommandGeneration() = 0; virtual void UpdateForCommandGeneration() = 0;
@ -206,8 +206,7 @@ protected:
template <typename T> template <typename T>
class EffectGeneric : public EffectBase { class EffectGeneric : public EffectBase {
public: public:
EffectGeneric(EffectType effect_type) : EffectBase::EffectBase(effect_type) {} explicit EffectGeneric(EffectType effect_type) : EffectBase(effect_type) {}
~EffectGeneric() = default;
T& GetParams() { T& GetParams() {
return internal_params; return internal_params;
@ -224,7 +223,7 @@ private:
class EffectStubbed : public EffectBase { class EffectStubbed : public EffectBase {
public: public:
explicit EffectStubbed(); explicit EffectStubbed();
~EffectStubbed(); ~EffectStubbed() override;
void Update(EffectInfo::InParams& in_params) override; void Update(EffectInfo::InParams& in_params) override;
void UpdateForCommandGeneration() override; void UpdateForCommandGeneration() override;
@ -233,7 +232,7 @@ public:
class EffectI3dl2Reverb : public EffectGeneric<I3dl2ReverbParams> { class EffectI3dl2Reverb : public EffectGeneric<I3dl2ReverbParams> {
public: public:
explicit EffectI3dl2Reverb(); explicit EffectI3dl2Reverb();
~EffectI3dl2Reverb(); ~EffectI3dl2Reverb() override;
void Update(EffectInfo::InParams& in_params) override; void Update(EffectInfo::InParams& in_params) override;
void UpdateForCommandGeneration() override; void UpdateForCommandGeneration() override;
@ -245,7 +244,7 @@ private:
class EffectBiquadFilter : public EffectGeneric<BiquadFilterParams> { class EffectBiquadFilter : public EffectGeneric<BiquadFilterParams> {
public: public:
explicit EffectBiquadFilter(); explicit EffectBiquadFilter();
~EffectBiquadFilter(); ~EffectBiquadFilter() override;
void Update(EffectInfo::InParams& in_params) override; void Update(EffectInfo::InParams& in_params) override;
void UpdateForCommandGeneration() override; void UpdateForCommandGeneration() override;
@ -254,14 +253,14 @@ public:
class EffectAuxInfo : public EffectGeneric<AuxInfo> { class EffectAuxInfo : public EffectGeneric<AuxInfo> {
public: public:
explicit EffectAuxInfo(); explicit EffectAuxInfo();
~EffectAuxInfo(); ~EffectAuxInfo() override;
void Update(EffectInfo::InParams& in_params) override; void Update(EffectInfo::InParams& in_params) override;
void UpdateForCommandGeneration() override; void UpdateForCommandGeneration() override;
const VAddr GetSendInfo() const; VAddr GetSendInfo() const;
const VAddr GetSendBuffer() const; VAddr GetSendBuffer() const;
const VAddr GetRecvInfo() const; VAddr GetRecvInfo() const;
const VAddr GetRecvBuffer() const; VAddr GetRecvBuffer() const;
private: private:
VAddr send_info{}; VAddr send_info{};
@ -275,7 +274,7 @@ private:
class EffectDelay : public EffectGeneric<DelayParams> { class EffectDelay : public EffectGeneric<DelayParams> {
public: public:
explicit EffectDelay(); explicit EffectDelay();
~EffectDelay(); ~EffectDelay() override;
void Update(EffectInfo::InParams& in_params) override; void Update(EffectInfo::InParams& in_params) override;
void UpdateForCommandGeneration() override; void UpdateForCommandGeneration() override;
@ -287,7 +286,7 @@ private:
class EffectBufferMixer : public EffectGeneric<BufferMixerParams> { class EffectBufferMixer : public EffectGeneric<BufferMixerParams> {
public: public:
explicit EffectBufferMixer(); explicit EffectBufferMixer();
~EffectBufferMixer(); ~EffectBufferMixer() override;
void Update(EffectInfo::InParams& in_params) override; void Update(EffectInfo::InParams& in_params) override;
void UpdateForCommandGeneration() override; void UpdateForCommandGeneration() override;
@ -296,7 +295,7 @@ public:
class EffectReverb : public EffectGeneric<ReverbParams> { class EffectReverb : public EffectGeneric<ReverbParams> {
public: public:
explicit EffectReverb(); explicit EffectReverb();
~EffectReverb(); ~EffectReverb() override;
void Update(EffectInfo::InParams& in_params) override; void Update(EffectInfo::InParams& in_params) override;
void UpdateForCommandGeneration() override; void UpdateForCommandGeneration() override;

View File

@ -64,7 +64,6 @@ bool InfoUpdater::UpdateBehaviorInfo(BehaviorInfo& in_behavior_info) {
} }
bool InfoUpdater::UpdateMemoryPools(std::vector<ServerMemoryPoolInfo>& memory_pool_info) { bool InfoUpdater::UpdateMemoryPools(std::vector<ServerMemoryPoolInfo>& memory_pool_info) {
const auto force_mapping = behavior_info.IsMemoryPoolForceMappingEnabled();
const auto memory_pool_count = memory_pool_info.size(); const auto memory_pool_count = memory_pool_info.size();
const auto total_memory_pool_in = sizeof(ServerMemoryPoolInfo::InParams) * memory_pool_count; const auto total_memory_pool_in = sizeof(ServerMemoryPoolInfo::InParams) * memory_pool_count;
const auto total_memory_pool_out = sizeof(ServerMemoryPoolInfo::OutParams) * memory_pool_count; const auto total_memory_pool_out = sizeof(ServerMemoryPoolInfo::OutParams) * memory_pool_count;
@ -174,7 +173,7 @@ bool InfoUpdater::UpdateVoices(VoiceContext& voice_context,
} }
// Voice states for each channel // Voice states for each channel
std::array<VoiceState*, AudioCommon::MAX_CHANNEL_COUNT> voice_states{}; std::array<VoiceState*, AudioCommon::MAX_CHANNEL_COUNT> voice_states{};
ASSERT(in_params.id < voice_count); ASSERT(static_cast<std::size_t>(in_params.id) < voice_count);
// Grab our current voice info // Grab our current voice info
auto& voice_info = voice_context.GetInfo(static_cast<std::size_t>(in_params.id)); auto& voice_info = voice_context.GetInfo(static_cast<std::size_t>(in_params.id));
@ -352,8 +351,8 @@ ResultCode InfoUpdater::UpdateMixes(MixContext& mix_context, std::size_t mix_buf
for (std::size_t i = 0; i < mix_count; i++) { for (std::size_t i = 0; i < mix_count; i++) {
const auto& in = mix_in_params[i]; const auto& in = mix_in_params[i];
total_buffer_count += in.buffer_count; total_buffer_count += in.buffer_count;
if (in.dest_mix_id > mix_count && in.dest_mix_id != AudioCommon::NO_MIX && if (static_cast<std::size_t>(in.dest_mix_id) > mix_count &&
in.mix_id != AudioCommon::FINAL_MIX) { in.dest_mix_id != AudioCommon::NO_MIX && in.mix_id != AudioCommon::FINAL_MIX) {
LOG_ERROR( LOG_ERROR(
Audio, Audio,
"Invalid mix destination, mix_id={:X}, dest_mix_id={:X}, mix_buffer_count={:X}", "Invalid mix destination, mix_id={:X}, dest_mix_id={:X}, mix_buffer_count={:X}",

View File

@ -53,7 +53,7 @@ void MixContext::UpdateDistancesFromFinalMix() {
auto mix_id = in_params.mix_id; auto mix_id = in_params.mix_id;
// Needs to be referenced out of scope // Needs to be referenced out of scope
s32 distance_to_final_mix{AudioCommon::FINAL_MIX}; s32 distance_to_final_mix{AudioCommon::FINAL_MIX};
for (; distance_to_final_mix < info_count; distance_to_final_mix++) { for (; distance_to_final_mix < static_cast<s32>(info_count); distance_to_final_mix++) {
if (mix_id == AudioCommon::FINAL_MIX) { if (mix_id == AudioCommon::FINAL_MIX) {
// If we're at the final mix, we're done // If we're at the final mix, we're done
break; break;
@ -77,7 +77,7 @@ void MixContext::UpdateDistancesFromFinalMix() {
} }
// If we're out of range for our distance, mark it as no final mix // If we're out of range for our distance, mark it as no final mix
if (distance_to_final_mix >= info_count) { if (distance_to_final_mix >= static_cast<s32>(info_count)) {
distance_to_final_mix = AudioCommon::NO_FINAL_MIX; distance_to_final_mix = AudioCommon::NO_FINAL_MIX;
} }

View File

@ -306,7 +306,7 @@ bool SplitterContext::UpdateInfo(const std::vector<u8>& input, std::size_t& inpu
break; break;
} }
if (header.send_id < 0 || header.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"); LOG_ERROR(Audio, "Bad splitter data id");
break; break;
} }
@ -348,7 +348,7 @@ bool SplitterContext::UpdateData(const std::vector<u8>& input, std::size_t& inpu
break; break;
} }
if (header.splitter_id < 0 || header.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"); LOG_ERROR(Audio, "Bad splitter data id");
break; break;
} }
@ -434,7 +434,7 @@ const std::vector<s32>& NodeStates::GetIndexList() const {
} }
void NodeStates::PushTsortResult(s32 index) { void NodeStates::PushTsortResult(s32 index) {
ASSERT(index < node_count); ASSERT(index < static_cast<s32>(node_count));
index_list[index_pos++] = index; index_list[index_pos++] = index;
} }

View File

@ -488,11 +488,11 @@ s32 VoiceContext::DecodePcm16(s32* output_buffer, ServerWaveBuffer* wave_buffer,
// Fast path // Fast path
if (channel_count == 1) { if (channel_count == 1) {
for (std::size_t i = 0; i < samples_processed; i++) { for (std::ptrdiff_t i = 0; i < samples_processed; i++) {
output_buffer[i] = buffer_data[i]; output_buffer[i] = buffer_data[i];
} }
} else { } else {
for (std::size_t i = 0; i < samples_processed; i++) { for (std::ptrdiff_t i = 0; i < samples_processed; i++) {
output_buffer[i] = buffer_data[i * channel_count + channel]; output_buffer[i] = buffer_data[i * channel_count + channel];
} }
} }