mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Move more validation logic into AtracBase
This commit is contained in:
parent
beaced1c87
commit
5bd1ae5bae
3 changed files with 16 additions and 10 deletions
|
@ -853,6 +853,10 @@ u32 Atrac::AddStreamDataSas(u32 bufPtr, u32 bytesToAdd) {
|
|||
}
|
||||
|
||||
u32 Atrac::GetNextSamples() {
|
||||
if (CurrentSample() >= track_.endSample) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// It seems like the PSP aligns the sample position to 0x800...?
|
||||
u32 skipSamples = track_.FirstSampleOffsetFull();
|
||||
u32 firstSamples = (track_.SamplesPerFrame() - skipSamples) % track_.SamplesPerFrame();
|
||||
|
|
|
@ -191,6 +191,13 @@ public:
|
|||
return track_;
|
||||
}
|
||||
|
||||
int Channels() const {
|
||||
return track_.channels;
|
||||
}
|
||||
int SamplesPerFrame() const {
|
||||
return track_.SamplesPerFrame();
|
||||
}
|
||||
|
||||
int GetOutputChannels() const {
|
||||
return outputChannels_;
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ static u32 sceAtracGetChannel(int atracID, u32 channelAddr) {
|
|||
}
|
||||
|
||||
if (Memory::IsValidAddress(channelAddr)){
|
||||
Memory::WriteUnchecked_U32(atrac->GetTrack().channels, channelAddr);
|
||||
Memory::WriteUnchecked_U32(atrac->Channels(), channelAddr);
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
} else {
|
||||
return hleLogError(Log::ME, 0, "invalid address");
|
||||
|
@ -390,7 +390,7 @@ static u32 sceAtracGetMaxSample(int atracID, u32 maxSamplesAddr) {
|
|||
}
|
||||
|
||||
if (Memory::IsValidAddress(maxSamplesAddr)) {
|
||||
Memory::WriteUnchecked_U32(atrac->GetTrack().SamplesPerFrame(), maxSamplesAddr);
|
||||
Memory::WriteUnchecked_U32(atrac->SamplesPerFrame(), maxSamplesAddr);
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
} else {
|
||||
return hleLogError(Log::ME, 0, "invalid address");
|
||||
|
@ -423,16 +423,11 @@ static u32 sceAtracGetNextSample(int atracID, u32 outNAddr) {
|
|||
if (err != 0) {
|
||||
return hleLogError(Log::ME, err);
|
||||
}
|
||||
if (atrac->CurrentSample() >= atrac->GetTrack().endSample) {
|
||||
if (Memory::IsValidAddress(outNAddr))
|
||||
Memory::WriteUnchecked_U32(0, outNAddr);
|
||||
return hleLogDebug(Log::ME, 0, "0 samples left");
|
||||
}
|
||||
|
||||
u32 numSamples = atrac->GetNextSamples();
|
||||
|
||||
if (Memory::IsValidAddress(outNAddr))
|
||||
int numSamples = atrac->GetNextSamples();
|
||||
if (Memory::IsValidAddress(outNAddr)) {
|
||||
Memory::WriteUnchecked_U32(numSamples, outNAddr);
|
||||
}
|
||||
return hleLogDebug(Log::ME, 0, "%d samples left", numSamples);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue