2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-04-21 02:57:30 +00:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include "audio_core/behavior_info.h"
|
|
|
|
#include "audio_core/common.h"
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
|
|
|
|
namespace AudioCore {
|
|
|
|
|
2020-07-12 11:59:14 +00:00
|
|
|
BehaviorInfo::BehaviorInfo() : process_revision(AudioCommon::CURRENT_PROCESS_REVISION) {}
|
2020-04-21 02:57:30 +00:00
|
|
|
BehaviorInfo::~BehaviorInfo() = default;
|
|
|
|
|
|
|
|
bool BehaviorInfo::UpdateOutput(std::vector<u8>& buffer, std::size_t offset) {
|
2020-07-12 11:59:14 +00:00
|
|
|
if (!AudioCommon::CanConsumeBuffer(buffer.size(), offset, sizeof(OutParams))) {
|
2020-04-21 02:57:30 +00:00
|
|
|
LOG_ERROR(Audio, "Buffer is an invalid size!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
OutParams params{};
|
|
|
|
std::memcpy(params.errors.data(), errors.data(), sizeof(ErrorInfo) * errors.size());
|
|
|
|
params.error_count = static_cast<u32_le>(error_count);
|
|
|
|
std::memcpy(buffer.data() + offset, ¶ms, sizeof(OutParams));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BehaviorInfo::ClearError() {
|
|
|
|
error_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BehaviorInfo::UpdateFlags(u64_le dest_flags) {
|
|
|
|
flags = dest_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BehaviorInfo::SetUserRevision(u32_le revision) {
|
|
|
|
user_revision = revision;
|
|
|
|
}
|
|
|
|
|
2020-07-12 11:59:14 +00:00
|
|
|
u32_le BehaviorInfo::GetUserRevision() const {
|
|
|
|
return user_revision;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32_le BehaviorInfo::GetProcessRevision() const {
|
|
|
|
return process_revision;
|
|
|
|
}
|
|
|
|
|
2020-04-21 02:57:30 +00:00
|
|
|
bool BehaviorInfo::IsAdpcmLoopContextBugFixed() const {
|
2020-07-12 11:59:14 +00:00
|
|
|
return AudioCommon::IsRevisionSupported(2, user_revision);
|
2020-04-21 02:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsSplitterSupported() const {
|
2020-07-12 11:59:14 +00:00
|
|
|
return AudioCommon::IsRevisionSupported(2, user_revision);
|
2020-04-21 02:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsLongSizePreDelaySupported() const {
|
2020-07-12 11:59:14 +00:00
|
|
|
return AudioCommon::IsRevisionSupported(3, user_revision);
|
2020-04-21 02:57:30 +00:00
|
|
|
}
|
|
|
|
|
2020-09-25 21:14:02 +00:00
|
|
|
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit80PercentSupported() const {
|
2020-07-12 11:59:14 +00:00
|
|
|
return AudioCommon::IsRevisionSupported(5, user_revision);
|
2020-04-21 02:57:30 +00:00
|
|
|
}
|
|
|
|
|
2020-09-25 21:14:02 +00:00
|
|
|
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit75PercentSupported() const {
|
2020-07-12 11:59:14 +00:00
|
|
|
return AudioCommon::IsRevisionSupported(4, user_revision);
|
2020-04-21 02:57:30 +00:00
|
|
|
}
|
|
|
|
|
2020-09-25 21:14:02 +00:00
|
|
|
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit70PercentSupported() const {
|
2020-07-12 11:59:14 +00:00
|
|
|
return AudioCommon::IsRevisionSupported(1, user_revision);
|
2020-04-21 02:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsElapsedFrameCountSupported() const {
|
2020-07-12 11:59:14 +00:00
|
|
|
return AudioCommon::IsRevisionSupported(5, user_revision);
|
2020-04-21 02:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsMemoryPoolForceMappingEnabled() const {
|
|
|
|
return (flags & 1) != 0;
|
|
|
|
}
|
|
|
|
|
2020-07-12 11:59:14 +00:00
|
|
|
bool BehaviorInfo::IsFlushVoiceWaveBuffersSupported() const {
|
|
|
|
return AudioCommon::IsRevisionSupported(5, user_revision);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsVoicePlayedSampleCountResetAtLoopPointSupported() const {
|
|
|
|
return AudioCommon::IsRevisionSupported(5, user_revision);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsVoicePitchAndSrcSkippedSupported() const {
|
|
|
|
return AudioCommon::IsRevisionSupported(5, user_revision);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsMixInParameterDirtyOnlyUpdateSupported() const {
|
|
|
|
return AudioCommon::IsRevisionSupported(7, user_revision);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsSplitterBugFixed() const {
|
|
|
|
return AudioCommon::IsRevisionSupported(5, user_revision);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BehaviorInfo::CopyErrorInfo(BehaviorInfo::OutParams& dst) {
|
|
|
|
dst.error_count = static_cast<u32>(error_count);
|
2020-07-25 02:32:05 +00:00
|
|
|
std::copy(errors.begin(), errors.begin() + error_count, dst.errors.begin());
|
2020-07-12 11:59:14 +00:00
|
|
|
}
|
|
|
|
|
2020-04-21 02:57:30 +00:00
|
|
|
} // namespace AudioCore
|