mirror of
https://github.com/open-goal/jak-project.git
synced 2024-11-23 14:20:07 +00:00
Switch to std::span (#3376)
Now that we have cpp20 we can ditch nonstd::span. Depends on #3375
This commit is contained in:
parent
0011fb4b2b
commit
4e569f0115
7
.github/workflows/linux-build-gcc.yaml
vendored
7
.github/workflows/linux-build-gcc.yaml
vendored
@ -31,10 +31,15 @@ jobs:
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install build-essential cmake \
|
||||
clang gcc g++ lcov make nasm libxrandr-dev \
|
||||
clang gcc-10 g++-10 lcov make nasm libxrandr-dev \
|
||||
libxinerama-dev libxcursor-dev libpulse-dev \
|
||||
libxi-dev zip ninja-build libgl1-mesa-dev libssl-dev
|
||||
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
|
||||
sudo update-alternatives --set gcc /usr/bin/gcc-10
|
||||
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
|
||||
sudo update-alternatives --set g++ /usr/bin/g++-10
|
||||
|
||||
- name: Setup Buildcache
|
||||
uses: mikehardy/buildcache-action@v2.1.0
|
||||
with:
|
||||
|
@ -7,16 +7,15 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/util/Assert.h"
|
||||
|
||||
#include "third-party/span.hpp"
|
||||
|
||||
class BinaryReader {
|
||||
public:
|
||||
explicit BinaryReader(nonstd::span<const uint8_t> _span) : m_span(_span) {}
|
||||
explicit BinaryReader(std::span<const uint8_t> _span) : m_span(_span) {}
|
||||
|
||||
template <typename T>
|
||||
T read() {
|
||||
@ -39,6 +38,6 @@ class BinaryReader {
|
||||
void set_seek(u32 seek) { m_seek = seek; }
|
||||
|
||||
private:
|
||||
nonstd::span<const u8> m_span;
|
||||
std::span<const u8> m_span;
|
||||
uint32_t m_seek = 0;
|
||||
};
|
||||
|
@ -210,7 +210,7 @@ struct AudioFileInfo {
|
||||
};
|
||||
|
||||
AudioFileInfo process_audio_file(const fs::path& output_folder,
|
||||
nonstd::span<const uint8_t> data,
|
||||
std::span<const uint8_t> data,
|
||||
const std::string& name,
|
||||
const std::string& suffix,
|
||||
bool stereo) {
|
||||
@ -276,7 +276,7 @@ void process_streamed_audio(const decompiler::Config& config,
|
||||
}
|
||||
|
||||
lg::info("File {}, total {:.2f} minutes", entry.name, audio_len / 60.0);
|
||||
auto data = nonstd::span(wad_data).subspan(entry.start_byte);
|
||||
auto data = std::span(wad_data).subspan(entry.start_byte);
|
||||
auto info = process_audio_file(output_path, data, entry.name, suffix, entry.stereo);
|
||||
audio_len += info.length_seconds;
|
||||
filename_data[i][lang_id + 1] = info.filename;
|
||||
|
@ -191,7 +191,7 @@ static Grain ReadGrainV2(BinaryReader& data, BinaryReader grainData, u8* samples
|
||||
return grain;
|
||||
};
|
||||
|
||||
SFXBlock* SFXBlock::ReadBlock(nonstd::span<u8> bank_data, nonstd::span<u8> samples) {
|
||||
SFXBlock* SFXBlock::ReadBlock(std::span<u8> bank_data, std::span<u8> samples) {
|
||||
BinaryReader data(bank_data);
|
||||
// auto block = std::make_unique<SFXBlock>();
|
||||
auto block = new SFXBlock();
|
||||
@ -313,9 +313,9 @@ SFXBlock* SFXBlock::ReadBlock(nonstd::span<u8> bank_data, nonstd::span<u8> sampl
|
||||
return block;
|
||||
}
|
||||
|
||||
MusicBank* MusicBank::ReadBank(nonstd::span<u8> bank_data,
|
||||
nonstd::span<u8> samples,
|
||||
nonstd::span<u8> midi_data) {
|
||||
MusicBank* MusicBank::ReadBank(std::span<u8> bank_data,
|
||||
std::span<u8> samples,
|
||||
std::span<u8> midi_data) {
|
||||
BinaryReader data(bank_data);
|
||||
// auto bank = std::make_unique<MusicBank>();
|
||||
auto bank = new MusicBank();
|
||||
@ -388,7 +388,7 @@ MusicBank* MusicBank::ReadBank(nonstd::span<u8> bank_data,
|
||||
}
|
||||
}
|
||||
|
||||
auto seq_buf = nonstd::span<u8>(bank->SeqData.get(), midi_data.size_bytes());
|
||||
auto seq_buf = std::span<u8>(bank->SeqData.get(), midi_data.size_bytes());
|
||||
BinaryReader seq_data(seq_buf);
|
||||
FileAttributes fa;
|
||||
fa.Read(seq_data);
|
||||
@ -407,7 +407,7 @@ MusicBank* MusicBank::ReadBank(nonstd::span<u8> bank_data,
|
||||
return bank;
|
||||
}
|
||||
|
||||
BankHandle Loader::BankLoad(nonstd::span<u8> bank) {
|
||||
BankHandle Loader::BankLoad(std::span<u8> bank) {
|
||||
BinaryReader reader(bank);
|
||||
FileAttributes fa;
|
||||
fa.Read(reader);
|
||||
@ -419,17 +419,15 @@ BankHandle Loader::BankLoad(nonstd::span<u8> bank) {
|
||||
|
||||
reader.set_seek(fa.where[0].offset);
|
||||
u32 fourcc = reader.read<u32>();
|
||||
nonstd::span<u8> bank_data(nonstd::span<u8>(bank).subspan(fa.where[0].offset, fa.where[0].size));
|
||||
nonstd::span<u8> sample_data(
|
||||
nonstd::span<u8>(bank).subspan(fa.where[1].offset, fa.where[1].size));
|
||||
std::span<u8> bank_data(std::span<u8>(bank).subspan(fa.where[0].offset, fa.where[0].size));
|
||||
std::span<u8> sample_data(std::span<u8>(bank).subspan(fa.where[1].offset, fa.where[1].size));
|
||||
|
||||
if (fourcc == snd::fourcc("SBv2")) {
|
||||
if (fa.num_chunks != 3) {
|
||||
fmt::print("SBv2 without midi data not supported\n");
|
||||
return 0;
|
||||
}
|
||||
nonstd::span<u8> midi_data(
|
||||
nonstd::span<u8>(bank).subspan(fa.where[2].offset, fa.where[2].size));
|
||||
std::span<u8> midi_data(std::span<u8>(bank).subspan(fa.where[2].offset, fa.where[2].size));
|
||||
|
||||
auto bank = MusicBank::ReadBank(bank_data, sample_data, midi_data);
|
||||
mBanks.emplace_back(bank);
|
||||
|
@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include "soundbank.h"
|
||||
@ -10,8 +11,6 @@
|
||||
#include "common/common_types.h"
|
||||
#include "common/util/BinaryReader.h"
|
||||
|
||||
#include "third-party/span.hpp"
|
||||
|
||||
namespace snd {
|
||||
|
||||
using BankHandle = SoundBank*;
|
||||
@ -37,7 +36,7 @@ class Loader {
|
||||
|
||||
void UnloadBank(BankHandle id);
|
||||
|
||||
BankHandle BankLoad(nonstd::span<u8> bank);
|
||||
BankHandle BankLoad(std::span<u8> bank);
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<SoundBank>> mBanks;
|
||||
|
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
#include <span>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "soundbank.h"
|
||||
|
||||
#include "third-party/span.hpp"
|
||||
|
||||
namespace snd {
|
||||
|
||||
struct Midi {
|
||||
@ -63,9 +62,9 @@ class MusicBank : public SoundBank {
|
||||
std::unique_ptr<u8[]> SeqData;
|
||||
std::variant<Midi, MultiMidi> MidiData;
|
||||
|
||||
static MusicBank* ReadBank(nonstd::span<u8> bank_data,
|
||||
nonstd::span<u8> samples,
|
||||
nonstd::span<u8> midi_data);
|
||||
static MusicBank* ReadBank(std::span<u8> bank_data,
|
||||
std::span<u8> samples,
|
||||
std::span<u8> midi_data);
|
||||
|
||||
std::optional<std::unique_ptr<SoundHandler>> MakeHandler(VoiceManager& vm,
|
||||
u32 sound_id,
|
||||
|
@ -233,7 +233,7 @@ void Player::SetMasterVolume(u32 group, s32 volume) {
|
||||
}
|
||||
}
|
||||
|
||||
BankHandle Player::LoadBank(nonstd::span<u8> bank) {
|
||||
BankHandle Player::LoadBank(std::span<u8> bank) {
|
||||
std::scoped_lock lock(mTickLock);
|
||||
return mLoader.BankLoad(bank);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <span>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@ -18,7 +19,6 @@
|
||||
#include "game/sound/989snd/vagvoice.h"
|
||||
|
||||
#include "third-party/cubeb/cubeb/include/cubeb/cubeb.h"
|
||||
#include "third-party/span.hpp"
|
||||
|
||||
namespace snd {
|
||||
|
||||
@ -32,7 +32,7 @@ class Player {
|
||||
// player(player&& other) noexcept = default;
|
||||
// player& operator=(player&& other) noexcept = default;
|
||||
|
||||
BankHandle LoadBank(nonstd::span<u8> bank);
|
||||
BankHandle LoadBank(std::span<u8> bank);
|
||||
|
||||
u32 PlaySound(BankHandle bank, u32 sound, s32 vol, s32 pan, s32 pm, s32 pb);
|
||||
u32 PlaySoundByName(BankHandle bank,
|
||||
|
@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include "sfxgrain.h"
|
||||
#include "soundbank.h"
|
||||
|
||||
#include "third-party/span.hpp"
|
||||
|
||||
namespace snd {
|
||||
|
||||
struct SFXUserData { // 0x10
|
||||
@ -46,7 +45,7 @@ class SFXBlock : public SoundBank {
|
||||
std::map<std::string, u32> Names;
|
||||
std::unique_ptr<u8[]> SampleData;
|
||||
|
||||
static SFXBlock* ReadBlock(nonstd::span<u8> bank_data, nonstd::span<u8> samples);
|
||||
static SFXBlock* ReadBlock(std::span<u8> bank_data, std::span<u8> samples);
|
||||
|
||||
std::optional<std::unique_ptr<SoundHandler>> MakeHandler(VoiceManager& vm,
|
||||
u32 sound_id,
|
||||
|
@ -214,7 +214,7 @@ snd::BankHandle snd_BankLoadEx(const char* filename,
|
||||
if (player) {
|
||||
// TODO put the load on the thread pool?
|
||||
auto file_buf = file_util::read_binary_file(std::string(filename));
|
||||
return player->LoadBank(nonstd::span(file_buf).subspan(offset));
|
||||
return player->LoadBank(std::span(file_buf).subspan(offset));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
1884
third-party/span.hpp
generated
vendored
1884
third-party/span.hpp
generated
vendored
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user