mirror of
https://github.com/SysRay/psOff_public.git
synced 2024-11-23 06:19:41 +00:00
Fix ngs2 mess
This commit is contained in:
parent
c61019b855
commit
d4933b5d0a
@ -457,4 +457,36 @@ EXPORT SYSV_ABI newhandler_func __NID(_ZSt15get_new_handlerv)() {
|
||||
LOG_ERR(L"Unimplemented std::get_new_handler()");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief malloc
|
||||
*
|
||||
*/
|
||||
EXPORT SYSV_ABI void* __NID(malloc)(size_t size) {
|
||||
return ::malloc(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief free
|
||||
*
|
||||
*/
|
||||
EXPORT SYSV_ABI void __NID(free)(void* ptr) {
|
||||
return ::free(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief fopen
|
||||
*
|
||||
*/
|
||||
EXPORT SYSV_ABI FILE* __NID(fopen)(const char* name, const char* mode) {
|
||||
return ::fopen(name, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief fclose
|
||||
*
|
||||
*/
|
||||
EXPORT SYSV_ABI int __NID(fclose)(FILE* file) {
|
||||
return ::fclose(file);
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ EXPORT SYSV_ABI int32_t sceNgs2SystemCreateWithAllocator(const SceNgs2SystemOpti
|
||||
return ret;
|
||||
}
|
||||
|
||||
*outh = new (cbi.hostBuffer) SceNgs2Handle_system(alloc, sysopt ? sysopt->sampleRate : 48000);
|
||||
*outh = new (cbi.hostBuffer) SceNgs2Handle_system(alloc, sysopt);
|
||||
getPimpl()->handles.emplace(*outh);
|
||||
|
||||
LOG_DEBUG(L"-> System: 0x%08llx", (uint64_t)*outh);
|
||||
@ -263,7 +263,7 @@ EXPORT SYSV_ABI int32_t sceNgs2SystemCreate(const SceNgs2SystemOption* sysopt, c
|
||||
if (sysopt != nullptr && sysopt->size < sizeof(SceNgs2SystemOption)) return Err::Ngs2::INVALID_OPTION_SIZE;
|
||||
if (cbi == nullptr || cbi->hostBuffer == nullptr || cbi->hostBufferSize < sizeof(SceNgs2Handle)) return Err::Ngs2::INVALID_BUFFER_ADDRESS;
|
||||
|
||||
*outh = new (cbi->hostBuffer) SceNgs2Handle_system(nullptr, sysopt ? sysopt->sampleRate : 48000);
|
||||
*outh = new (cbi->hostBuffer) SceNgs2Handle_system(nullptr, sysopt);
|
||||
|
||||
if (sysopt) getPimpl()->handles.emplace(*outh);
|
||||
|
||||
@ -566,7 +566,7 @@ EXPORT SYSV_ABI int32_t sceNgs2SystemRender(SceNgs2Handle* sysh, SceNgs2RenderBu
|
||||
if (rbi->waveType >= SceNgs2WaveFormType::MAX_TYPES) return Err::Ngs2::INVALID_WAVEFORM_TYPE;
|
||||
if (rbi->channelsCount > SceNgs2ChannelsCount::CH_7_1) return Err::Ngs2::INVALID_NUM_CHANNELS;
|
||||
|
||||
uint32_t const numSamples = rbi->bufferSize / ((uint32_t)rbi->channelsCount * getSampleBytes(rbi->waveType));
|
||||
uint32_t const numSamples = system->outNumSamples;
|
||||
|
||||
if (system->sampler == nullptr) {
|
||||
//
|
||||
@ -582,7 +582,7 @@ EXPORT SYSV_ABI int32_t sceNgs2SystemRender(SceNgs2Handle* sysh, SceNgs2RenderBu
|
||||
std::memset(rbi[i].bufferPtr, 0, rbi[i].bufferSize);
|
||||
for (auto& voice: system->sampler->voices) {
|
||||
if (voice.second.reader != nullptr) {
|
||||
// voice.second.reader->getAudio(&rbi[i], numSamples, system->outSampleRate);
|
||||
voice.second.reader->getAudio(&rbi[i], numSamples, system->outSampleRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -273,31 +273,16 @@ bool Reader::getAudioUncompressed(SceNgs2RenderBufferInfo* rbi, uint32_t numOutS
|
||||
}
|
||||
// -
|
||||
|
||||
uint32_t const readSize = std::min(rbi->bufferSize, (size_t)pimpl->block.size - pimpl->curOffset);
|
||||
|
||||
auto const [formatIn, bytesIn] = convFormat(voice->info.type);
|
||||
auto const [formatOut, bytesOut] = convFormat(rbi->waveType);
|
||||
|
||||
std::vector<uint8_t*> audioBuffers(((int)rbi->channelsCount));
|
||||
|
||||
auto const channelSizeOut = (uint32_t)rbi->channelsCount * bytesOut;
|
||||
for (uint8_t n = 0; n < audioBuffers.size(); ++n) {
|
||||
audioBuffers[n] = &((uint8_t*)rbi->bufferPtr)[0];
|
||||
}
|
||||
|
||||
if (pimpl->block.numSamples > 0) {
|
||||
std::vector<uint8_t const*> audioBuffersIn(((int)voice->info.channelsCount));
|
||||
|
||||
auto const channelSizeIn = (uint32_t)voice->info.channelsCount * bytesOut;
|
||||
for (uint8_t n = 0; n < audioBuffersIn.size(); ++n) {
|
||||
audioBuffersIn[n] = &((uint8_t*)pimpl->data)[0];
|
||||
}
|
||||
|
||||
auto numSamples = swr_convert(pimpl->swrCtx, (uint8_t**)&rbi->bufferPtr, numOutSamples, &pimpl->data, pimpl->block.numSamples);
|
||||
swr_convert(pimpl->swrCtx, (uint8_t**)&rbi->bufferPtr, numOutSamples, &pimpl->data, pimpl->block.numSamples);
|
||||
|
||||
pimpl->block.numSamples = 0;
|
||||
} else {
|
||||
auto numSamples = swr_convert(pimpl->swrCtx, (uint8_t**)&rbi->bufferPtr, numOutSamples, nullptr, 0);
|
||||
|
||||
if (numSamples == 0) {
|
||||
m_state.numDecodedSamples += pimpl->block.numSamples;
|
||||
m_state.decodedDataSize += pimpl->block.size;
|
||||
|
@ -220,6 +220,16 @@ struct SceNgs2Handle {
|
||||
virtual ~SceNgs2Handle() = default;
|
||||
};
|
||||
|
||||
struct SceNgs2SystemOption {
|
||||
size_t size;
|
||||
char name[16];
|
||||
uint32_t flags;
|
||||
uint32_t maxGrainSamples;
|
||||
uint32_t numGrainSamples;
|
||||
uint32_t sampleRate;
|
||||
int8_t pad[24];
|
||||
};
|
||||
|
||||
struct SceNgs2Handle_system: public SceNgs2Handle {
|
||||
SceNgs2BufferAllocator alloc;
|
||||
|
||||
@ -234,12 +244,14 @@ struct SceNgs2Handle_system: public SceNgs2Handle {
|
||||
|
||||
// Options
|
||||
uint32_t outSampleRate;
|
||||
uint32_t outNumSamples;
|
||||
|
||||
// -
|
||||
|
||||
SceNgs2Handle_system(SceNgs2BufferAllocator const* alloc_, uint32_t outrate): SceNgs2Handle(SceNgs2HandleType::System) {
|
||||
SceNgs2Handle_system(SceNgs2BufferAllocator const* alloc_, const SceNgs2SystemOption* sysopt): SceNgs2Handle(SceNgs2HandleType::System) {
|
||||
if (alloc_ != nullptr) alloc = *alloc_;
|
||||
outSampleRate = outrate;
|
||||
outSampleRate = sysopt ? sysopt->sampleRate : 48000;
|
||||
outNumSamples = sysopt ? sysopt->numGrainSamples : 256;
|
||||
}
|
||||
|
||||
virtual ~SceNgs2Handle_system() = default;
|
||||
@ -312,16 +324,6 @@ struct SceNgs2WaveformFormat {
|
||||
SceNgs2WaveformBlock block[4];
|
||||
};
|
||||
|
||||
struct SceNgs2SystemOption {
|
||||
size_t size;
|
||||
char name[16];
|
||||
uint32_t flags;
|
||||
uint32_t : 32;
|
||||
uint32_t : 32;
|
||||
uint32_t sampleRate;
|
||||
int8_t pad[24];
|
||||
};
|
||||
|
||||
struct SceNgs2GeomListenerWork;
|
||||
struct SceNgs2GeomListenerParam;
|
||||
|
||||
@ -482,4 +484,4 @@ struct SceNgs2PanParam {
|
||||
float lfeLevel;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
#pragma pack(pop)
|
||||
|
Loading…
Reference in New Issue
Block a user