forked from shadps4-emu/shadPS4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ajm: Initial ajm implementation * AJM code improvements (shadps4-emu#1453) * Fix sideband buffer order (shadps4-emu#1454) * ajm: Attempt to add gapless support * ajm_at9: Return superframes decoded in a single job * WIP (shadps4-emu#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 <[email protected]> Co-authored-by: Vladislav Mikhalin <[email protected]> Co-authored-by: IndecisiveTurtle <[email protected]>
- Loading branch information
1 parent
76f4408
commit f068f13
Showing
17 changed files
with
1,678 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.