Reduce CDFileProcessor size and add configuratable buffer size
This commit is contained in:
@@ -3,13 +3,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
namespace JabyEngine {
|
||||
static constexpr auto NormalCircularBufferSize = 5;
|
||||
static constexpr auto DisabledCircularBufferSize = 512;
|
||||
|
||||
void CDFileProcessor :: start_cur_job() {
|
||||
void CDFileProcessor :: start_cur_job(const AutoLBAEntry* lba, const BufferConfiguration& buf_cfg) {
|
||||
using CD::internal::SectorBufferAllocator;
|
||||
const auto configurate_for = [this](const CDFile& file, bool is_lz4) -> FileProcessor::State {
|
||||
const uint32_t* data_adr = [this](const CDFile& file, bool is_lz4) -> const uint32_t* {
|
||||
const auto configurate_for = [this](const CDFile& file, const BufferConfiguration& buf_cfg, bool is_lz4) -> FileProcessor::State {
|
||||
const uint32_t* data_adr = [this](const CDFile& file, const BufferConfiguration& buf_cfg, bool is_lz4) -> const uint32_t* {
|
||||
const auto disable_lz4 = [this](uint32_t* work_area, size_t size, uint32_t* overwrite_dst = nullptr) -> uint32_t* {
|
||||
uint8_t*const dst_adr = reinterpret_cast<uint8_t*>(this->circular_buffer.setup(reinterpret_cast<CD_IO::DataSector*>(work_area), size));
|
||||
|
||||
@@ -29,13 +28,13 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
if(file.type == CDFileType::CopyTo) {
|
||||
return is_lz4 ? enable_lz4(this->tmp_area, NormalCircularBufferSize, file.payload.overlay.dst) : disable_lz4(file.payload.copy_to.dst, DisabledCircularBufferSize);
|
||||
return is_lz4 ? enable_lz4(buf_cfg.adr, buf_cfg.sector_count, file.payload.overlay.dst) : disable_lz4(file.payload.copy_to.dst, DisabledCircularBufferSize);
|
||||
}
|
||||
|
||||
else {
|
||||
return is_lz4 ? enable_lz4(this->tmp_area, NormalCircularBufferSize) : disable_lz4(this->tmp_area, DisabledCircularBufferSize);
|
||||
return is_lz4 ? enable_lz4(buf_cfg.adr, buf_cfg.sector_count) : disable_lz4(buf_cfg.adr, DisabledCircularBufferSize);
|
||||
}
|
||||
}(file, is_lz4);
|
||||
}(file, buf_cfg, is_lz4);
|
||||
|
||||
switch(file.type) {
|
||||
case CDFileType::SimpleTIM:
|
||||
@@ -48,9 +47,9 @@ namespace JabyEngine {
|
||||
};
|
||||
|
||||
const auto& cur_job = *this->jobs.files;
|
||||
const auto& cur_lba = this->lba[cur_job.rel_lba_idx];
|
||||
const auto& cur_lba = lba[cur_job.rel_lba_idx];
|
||||
|
||||
this->file_state = configurate_for(cur_job, cur_lba.is_lz4());
|
||||
this->file_state = configurate_for(cur_job, buf_cfg, cur_lba.is_lz4());
|
||||
CD::internal::read_file(cur_lba, SectorBufferAllocator::create(this,
|
||||
[](void* ctx) -> CD_IO::DataSector* {
|
||||
CDFileProcessor &self = *reinterpret_cast<CDFileProcessor*>(ctx);
|
||||
@@ -82,12 +81,9 @@ namespace JabyEngine {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDFileProcessor :: setup(const volatile AutoLBAEntry* lba, JobArray jobs, uint32_t* tmp_area) {
|
||||
this->lba = const_cast<const AutoLBAEntry*>(lba);
|
||||
this->jobs = jobs;
|
||||
|
||||
this->tmp_area = tmp_area;
|
||||
CDFileProcessor::start_cur_job();
|
||||
void CDFileProcessor :: setup(const volatile AutoLBAEntry* lba, JobArray jobs, const BufferConfiguration& buf_cfg) {
|
||||
this->jobs = jobs;
|
||||
CDFileProcessor::start_cur_job(const_cast<const AutoLBAEntry*>(lba), buf_cfg);
|
||||
}
|
||||
|
||||
Progress CDFileProcessor :: process() {
|
||||
@@ -100,7 +96,7 @@ namespace JabyEngine {
|
||||
We are done now!
|
||||
The user decides if he wants the next value
|
||||
*/
|
||||
//while(this->file_state.process(0) != Progress::Done);
|
||||
//while(this->file_state.process(0) != Progress::Done);
|
||||
return Progress::Done;
|
||||
|
||||
case CD::internal::State::BufferFull:
|
||||
|
Reference in New Issue
Block a user