Combine the two Analyze functions

This commit is contained in:
Henrik Rydgård committed 2025-03-16 12:59:32 +01:00
1 parent fe0edc0bda
commit 3979b6af54
5 files changed
+20 -35

No files matched your search

+5 -14
View File
@@ -241,7 +241,7 @@ void Track::DebugLog() {
DEBUG_LOG(Log::ME, "loopStartSample: %d loopEndSample: %d", loopStartSample, loopEndSample);
}
int Atrac::Analyze(const Track &track, u32 addr, u32 size) {
int Atrac::Analyze(const Track &track, u32 addr, u32 size, u32 fileSize) {
first_ = {};
first_.addr = addr;
first_.size = size;
@@ -258,14 +258,16 @@ int Atrac::Analyze(const Track &track, u32 addr, u32 size) {
return SCE_KERNEL_ERROR_ILLEGAL_ADDRESS;
}
bool aa3 = fileSize != 0;
// TODO: Validate stuff.
if (Memory::ReadUnchecked_U32(addr) != RIFF_CHUNK_MAGIC) {
if (!aa3 && Memory::ReadUnchecked_U32(addr) != RIFF_CHUNK_MAGIC) {
ERROR_LOG(Log::ME, "Couldn't find RIFF header");
return SCE_ERROR_ATRAC_UNKNOWN_FORMAT;
}
track_ = track;
first_._filesize_dontuse = track_.fileSize;
first_._filesize_dontuse = aa3 ? fileSize : track_.fileSize;
track_.DebugLog();
return 0;
}
@@ -536,17 +538,6 @@ int AnalyzeAA3Track(u32 addr, u32 size, u32 fileSize, Track *track) {
return 0;
}
int Atrac::AnalyzeAA3(const Track &track, u32 addr, u32 size, u32 fileSize) {
first_.addr = addr;
first_.size = size;
first_._filesize_dontuse = fileSize;
AnalyzeReset();
track_ = track;
return 0;
}
int Atrac::GetSoundSample(int *endSample, int *loopStartSample, int *loopEndSample) const {
*endSample = track_.endSample;
*loopStartSample = track_.loopStartSample == -1 ? -1 : track_.loopStartSample - track_.FirstSampleOffsetFull();
+3 -4
View File
@@ -223,8 +223,8 @@ public:
virtual int BytesPerFrame() const = 0;
virtual int SamplesPerFrame() const = 0;
virtual int Analyze(const Track &track, u32 addr, u32 size) = 0;
virtual int AnalyzeAA3(const Track &track, u32 addr, u32 size, u32 filesize) = 0;
// Set filesize to 0 for autodetect, unless you are using aa3.
virtual int Analyze(const Track &track, u32 addr, u32 size, u32 filesize) = 0;
void UpdateContextFromPSPMem();
virtual void WriteContextToPSPMem() = 0;
@@ -275,8 +275,7 @@ public:
void DoState(PointerWrap &p) override;
void WriteContextToPSPMem() override;
int Analyze(const Track &track, u32 addr, u32 size) override;
int AnalyzeAA3(const Track &track, u32 addr, u32 size, u32 filesize) override;
int Analyze(const Track &track, u32 addr, u32 size, u32 filesize) override;
int GetNextDecodePosition(int *pos) const override;
int RemainingFrames() const override;
+1 -5
View File
@@ -46,11 +46,7 @@ void Atrac2::DoState(PointerWrap &p) {
void Atrac2::WriteContextToPSPMem() {
}
int Atrac2::Analyze(const Track &track, u32 addr, u32 size) {
return 0;
}
int Atrac2::AnalyzeAA3(const Track &track, u32 addr, u32 size, u32 filesize) {
int Atrac2::Analyze(const Track &track, u32 addr, u32 size, u32 filesize) {
return 0;
}
+1 -2
View File
@@ -11,8 +11,7 @@ public:
void DoState(PointerWrap &p) override;
void WriteContextToPSPMem() override;
int Analyze(const Track &track, u32 addr, u32 size) override;
int AnalyzeAA3(const Track &track, u32 addr, u32 size, u32 filesize) override;
int Analyze(const Track &track, u32 addr, u32 size, u32 filesize) override;
void SetID(int id) override {}
int GetID() const override { return 0; }
+10 -10
View File
@@ -581,7 +581,7 @@ static u32 sceAtracSetHalfwayBuffer(int atracID, u32 buffer, u32 readSize, u32 b
return hleLogError(Log::ME, SCE_ERROR_ATRAC_WRONG_CODECTYPE, "atracID uses different codec type than data");
}
ret = atrac->Analyze(track, buffer, readSize);
ret = atrac->Analyze(track, buffer, readSize, 0);
if (ret < 0) {
return hleLogError(Log::ME, ret);
}
@@ -616,7 +616,7 @@ static u32 sceAtracSetData(int atracID, u32 buffer, u32 bufferSize) {
return hleReportError(Log::ME, SCE_ERROR_ATRAC_WRONG_CODECTYPE, "atracID uses different codec type than data");
}
ret = atrac->Analyze(track, buffer, bufferSize);
ret = atrac->Analyze(track, buffer, bufferSize, 0);
if (ret < 0) {
return hleLogError(Log::ME, ret);
}
@@ -639,7 +639,7 @@ static int sceAtracSetDataAndGetID(u32 buffer, int bufferSize) {
}
AtracBase *atrac = allocAtrac();
ret = atrac->Analyze(track, buffer, bufferSize);
ret = atrac->Analyze(track, buffer, bufferSize, 0);
if (ret < 0) {
delete atrac;
return hleLogError(Log::ME, ret);
@@ -671,7 +671,7 @@ static int sceAtracSetHalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 buffer
}
AtracBase *atrac = allocAtrac();
ret = atrac->Analyze(track, buffer, readSize);
ret = atrac->Analyze(track, buffer, readSize, 0);
if (ret < 0) {
delete atrac;
return hleLogError(Log::ME, ret);
@@ -795,7 +795,7 @@ static int sceAtracSetMOutHalfwayBuffer(int atracID, u32 buffer, u32 readSize, u
return hleLogError(Log::ME, ret);
}
ret = atrac->Analyze(track, buffer, readSize);
ret = atrac->Analyze(track, buffer, readSize, 0);
if (ret < 0) {
return hleLogError(Log::ME, ret);
}
@@ -819,7 +819,7 @@ static u32 sceAtracSetMOutData(int atracID, u32 buffer, u32 bufferSize) {
return hleLogError(Log::ME, ret);
}
ret = atrac->Analyze(track, buffer, bufferSize);
ret = atrac->Analyze(track, buffer, bufferSize, 0);
if (ret < 0) {
return hleLogError(Log::ME, ret);
}
@@ -840,7 +840,7 @@ static int sceAtracSetMOutDataAndGetID(u32 buffer, u32 bufferSize) {
}
AtracBase *atrac = allocAtrac();
ret = atrac->Analyze(track, buffer, bufferSize);
ret = atrac->Analyze(track, buffer, bufferSize, 0);
if (ret < 0) {
delete atrac;
return hleLogError(Log::ME, ret);
@@ -874,7 +874,7 @@ static int sceAtracSetMOutHalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 bu
}
AtracBase *atrac = allocAtrac();
ret = atrac->Analyze(track, buffer, readSize);
ret = atrac->Analyze(track, buffer, readSize, 0);
if (ret < 0) {
delete atrac;
return hleLogError(Log::ME, ret);
@@ -902,7 +902,7 @@ static int sceAtracSetAA3DataAndGetID(u32 buffer, u32 bufferSize, u32 fileSize,
}
AtracBase *atrac = allocAtrac();
ret = atrac->AnalyzeAA3(track, buffer, bufferSize, fileSize);
ret = atrac->Analyze(track, buffer, bufferSize, fileSize);
if (ret < 0) {
delete atrac;
return hleLogError(Log::ME, ret);
@@ -1035,7 +1035,7 @@ static int sceAtracSetAA3HalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 buf
}
AtracBase *atrac = allocAtrac();
ret = atrac->AnalyzeAA3(track, buffer, readSize, fileSize);
ret = atrac->Analyze(track, buffer, readSize, fileSize);
if (ret < 0) {
delete atrac;
return hleLogError(Log::ME, ret);