* ajm: Initial ajm implementation

* AJM code improvements (#1453)

* Fix sideband buffer order (#1454)

* ajm: Attempt to add gapless support

* ajm_at9: Return superframes decoded in a single job

* WIP (#1460)

* Fix gapless decode and combine split buffers

* Fixed linux build

* fix number of samples reported with gapless decoding

* fixed number of remaining samples calculation

should fix the small crackling sounds that play every now and again

* refactor half ajm

* refactored most of ajm

* refactored ajm

* clang-format, in-repo libatrac9, removed debug stuff

---------

Co-authored-by: auser1337 <aaravsandhu10@outlook.com>
Co-authored-by: Vladislav Mikhalin <mikhalinvlad@gmail.com>
Co-authored-by: IndecisiveTurtle <geoster3d@gmail.com>
This commit is contained in:
georgemoralis 2024-11-05 09:16:57 +02:00 committed by GitHub
parent 76f440889b
commit f068f13e4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 1678 additions and 58 deletions

63
src/common/slot_array.h Normal file
View file

@ -0,0 +1,63 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
// #include <boost/icl/interval_set.hpp>
#include <limits>
#include <optional>
#include <shared_mutex>
#include <unordered_map>
#include <memory>
#include <numeric>
namespace Common {
template <class IndexType, class ResourceType,
IndexType MaxIndex = std::numeric_limits<IndexType>::max(), IndexType MinIndex = 0>
class SlotArray {
public:
SlotArray() {
std::iota(m_free_indices.begin(), m_free_indices.end(), MinIndex);
}
template <class... Types>
std::optional<IndexType> Create(Types&&... args) {
if (!HasFreeSlots()) {
return std::nullopt;
}
const auto index = m_free_indices[m_curr_cursor];
m_resources[index - MinIndex] = ResourceType(std::forward<Types>(args)...);
m_curr_cursor += 1;
return index;
}
bool Destroy(IndexType index) {
if (!m_resources[index - MinIndex].has_value()) {
return false;
}
m_curr_cursor -= 1;
m_free_indices[m_curr_cursor] = index;
m_resources[index - MinIndex] = std::nullopt;
return true;
}
ResourceType* Get(IndexType index) {
auto& resource = m_resources[index - MinIndex];
if (!resource.has_value()) {
return nullptr;
}
return &resource.value();
}
bool HasFreeSlots() {
return m_curr_cursor < m_free_indices.size();
}
private:
size_t m_curr_cursor = 0;
std::array<IndexType, MaxIndex - MinIndex> m_free_indices;
std::array<std::optional<ResourceType>, MaxIndex - MinIndex> m_resources;
};
} // namespace Common