2020-04-20 19:57:30 -07:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include "audio_core/behavior_info.h"
|
|
|
|
#include "audio_core/common.h"
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
|
|
|
|
namespace AudioCore {
|
|
|
|
|
2020-07-12 04:59:14 -07:00
|
|
|
BehaviorInfo::BehaviorInfo() : process_revision(AudioCommon::CURRENT_PROCESS_REVISION) {}
|
2020-04-20 19:57:30 -07:00
|
|
|
BehaviorInfo::~BehaviorInfo() = default;
|
|
|
|
|
|
|
|
bool BehaviorInfo::UpdateOutput(std::vector<u8>& buffer, std::size_t offset) {
|
2020-07-12 04:59:14 -07:00
|
|
|
if (!AudioCommon::CanConsumeBuffer(buffer.size(), offset, sizeof(OutParams))) {
|
2020-04-20 19:57:30 -07: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 04:59:14 -07:00
|
|
|
u32_le BehaviorInfo::GetUserRevision() const {
|
|
|
|
return user_revision;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32_le BehaviorInfo::GetProcessRevision() const {
|
|
|
|
return process_revision;
|
|
|
|
}
|
|
|
|
|
2020-04-20 19:57:30 -07:00
|
|
|
bool BehaviorInfo::IsAdpcmLoopContextBugFixed() const {
|
2020-07-12 04:59:14 -07:00
|
|
|
return AudioCommon::IsRevisionSupported(2, user_revision);
|
2020-04-20 19:57:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsSplitterSupported() const {
|
2020-07-12 04:59:14 -07:00
|
|
|
return AudioCommon::IsRevisionSupported(2, user_revision);
|
2020-04-20 19:57:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsLongSizePreDelaySupported() const {
|
2020-07-12 04:59:14 -07:00
|
|
|
return AudioCommon::IsRevisionSupported(3, user_revision);
|
2020-04-20 19:57:30 -07:00
|
|
|
}
|
|
|
|
|
2020-09-25 14:14:02 -07:00
|
|
|
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit80PercentSupported() const {
|
2020-07-12 04:59:14 -07:00
|
|
|
return AudioCommon::IsRevisionSupported(5, user_revision);
|
2020-04-20 19:57:30 -07:00
|
|
|
}
|
|
|
|
|
2020-09-25 14:14:02 -07:00
|
|
|
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit75PercentSupported() const {
|
2020-07-12 04:59:14 -07:00
|
|
|
return AudioCommon::IsRevisionSupported(4, user_revision);
|
2020-04-20 19:57:30 -07:00
|
|
|
}
|
|
|
|
|
2020-09-25 14:14:02 -07:00
|
|
|
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit70PercentSupported() const {
|
2020-07-12 04:59:14 -07:00
|
|
|
return AudioCommon::IsRevisionSupported(1, user_revision);
|
2020-04-20 19:57:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsElapsedFrameCountSupported() const {
|
2020-07-12 04:59:14 -07:00
|
|
|
return AudioCommon::IsRevisionSupported(5, user_revision);
|
2020-04-20 19:57:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BehaviorInfo::IsMemoryPoolForceMappingEnabled() const {
|
|
|
|
return (flags & 1) != 0;
|
|
|
|
}
|
|
|
|
|
2020-07-12 04:59:14 -07: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-24 19:32:05 -07:00
|
|
|
std::copy(errors.begin(), errors.begin() + error_count, dst.errors.begin());
|
2020-07-12 04:59:14 -07:00
|
|
|
}
|
|
|
|
|
2020-04-20 19:57:30 -07:00
|
|
|
} // namespace AudioCore
|