mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Finally get rid of the GetTrack() accessor
This commit is contained in:
parent
a3b43d8283
commit
3d143a0cba
5 changed files with 42 additions and 32 deletions
|
@ -548,9 +548,9 @@ int Atrac::AnalyzeAA3(u32 addr, u32 size, u32 fileSize) {
|
|||
}
|
||||
|
||||
int Atrac::GetSoundSample(int *endSample, int *loopStartSample, int *loopEndSample) const {
|
||||
*endSample = GetTrack().endSample;
|
||||
*loopStartSample = GetTrack().loopStartSample == -1 ? -1 : GetTrack().loopStartSample - GetTrack().FirstSampleOffsetFull();
|
||||
*loopEndSample = GetTrack().loopEndSample == -1 ? -1 : GetTrack().loopEndSample - GetTrack().FirstSampleOffsetFull();
|
||||
*endSample = track_.endSample;
|
||||
*loopStartSample = track_.loopStartSample == -1 ? -1 : track_.loopStartSample - track_.FirstSampleOffsetFull();
|
||||
*loopEndSample = track_.loopEndSample == -1 ? -1 : track_.loopEndSample - track_.FirstSampleOffsetFull();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1110,7 +1110,11 @@ u32 Atrac::DecodeData(u8 *outbuf, u32 outbufPtr, u32 *SamplesNum, u32 *finish, i
|
|||
return 0;
|
||||
}
|
||||
|
||||
void AtracBase::SetLoopNum(int loopNum) {
|
||||
int Atrac::SetLoopNum(int loopNum) {
|
||||
if (track_.loopinfo.size() == 0) {
|
||||
return SCE_ERROR_ATRAC_NO_LOOP_INFORMATION;
|
||||
}
|
||||
|
||||
// Spammed in MHU
|
||||
loopNum_ = loopNum;
|
||||
// Logic here looks wacky?
|
||||
|
@ -1122,13 +1126,14 @@ void AtracBase::SetLoopNum(int loopNum) {
|
|||
track_.loopEndSample = track_.endSample + track_.FirstSampleOffsetFull();
|
||||
}
|
||||
WriteContextToPSPMem();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Atrac::ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf, bool *delay) {
|
||||
*delay = false;
|
||||
if (BufferState() == ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER && SecondBufferSize() == 0) {
|
||||
return SCE_ERROR_ATRAC_SECOND_BUFFER_NEEDED;
|
||||
} else if ((u32)sample + GetTrack().firstSampleOffset > (u32)GetTrack().endSample + GetTrack().firstSampleOffset) {
|
||||
} else if ((u32)sample + track_.firstSampleOffset > (u32)track_.endSample + track_.firstSampleOffset) {
|
||||
// NOTE: Above we have to add firstSampleOffset to both sides - we seem to rely on wraparound.
|
||||
return SCE_ERROR_ATRAC_BAD_SAMPLE;
|
||||
}
|
||||
|
|
|
@ -184,13 +184,7 @@ public:
|
|||
|
||||
virtual void DoState(PointerWrap &p) = 0;
|
||||
|
||||
const Track &GetTrack() const {
|
||||
return track_;
|
||||
}
|
||||
|
||||
int Channels() const {
|
||||
return track_.channels;
|
||||
}
|
||||
virtual int Channels() const = 0;
|
||||
|
||||
int GetOutputChannels() const {
|
||||
return outputChannels_;
|
||||
|
@ -209,8 +203,10 @@ public:
|
|||
return bufferState_;
|
||||
}
|
||||
|
||||
virtual int SetLoopNum(int loopNum) = 0;
|
||||
virtual int LoopNum() const = 0;
|
||||
virtual int LoopStatus() const = 0;
|
||||
|
||||
u32 CodecType() const {
|
||||
return track_.codecType;
|
||||
}
|
||||
|
@ -224,6 +220,7 @@ public:
|
|||
virtual int RemainingFrames() const = 0;
|
||||
virtual u32 SecondBufferSize() const = 0;
|
||||
virtual int Bitrate() const = 0;
|
||||
virtual int BytesPerFrame() const = 0;
|
||||
virtual int SamplesPerFrame() const = 0;
|
||||
|
||||
virtual int Analyze(u32 addr, u32 size) = 0;
|
||||
|
@ -235,7 +232,6 @@ public:
|
|||
virtual void GetStreamDataInfo(u32 *writePtr, u32 *writableBytes, u32 *readOffset) = 0;
|
||||
virtual int AddStreamData(u32 bytesToAdd) = 0;
|
||||
virtual u32 AddStreamDataSas(u32 bufPtr, u32 bytesToAdd) = 0;
|
||||
virtual void SetLoopNum(int loopNum);
|
||||
virtual int ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf, bool *delay) = 0;
|
||||
virtual int GetResetBufferInfo(AtracResetBufferInfo *bufferInfo, int sample) = 0;
|
||||
virtual int SetData(u32 buffer, u32 readSize, u32 bufferSize, int outputChannels) = 0;
|
||||
|
@ -287,6 +283,9 @@ public:
|
|||
u32 SecondBufferSize() const override {
|
||||
return second_.size;
|
||||
}
|
||||
int Channels() const override {
|
||||
return track_.channels;
|
||||
}
|
||||
int LoopNum() const override {
|
||||
return loopNum_;
|
||||
}
|
||||
|
@ -299,6 +298,9 @@ public:
|
|||
int Bitrate() const override {
|
||||
return track_.Bitrate();
|
||||
}
|
||||
int BytesPerFrame() const override {
|
||||
return track_.BytesPerFrame();
|
||||
}
|
||||
int SamplesPerFrame() const override {
|
||||
return track_.SamplesPerFrame();
|
||||
}
|
||||
|
@ -308,6 +310,8 @@ public:
|
|||
return track_;
|
||||
}
|
||||
|
||||
int SetLoopNum(int loopNum) override;
|
||||
|
||||
// Ask where in memory new data should be written.
|
||||
void GetStreamDataInfo(u32 *writePtr, u32 *writableBytes, u32 *readOffset) override;
|
||||
// Notify the player that the user has written some new data.
|
||||
|
|
|
@ -20,6 +20,9 @@ public:
|
|||
int Bitrate() const override { return 0; }
|
||||
int LoopNum() const override { return 0; }
|
||||
int SamplesPerFrame() const override { return 0; }
|
||||
int Channels() const override { return 2; }
|
||||
int BytesPerFrame() const override { return 0; }
|
||||
int SetLoopNum(int loopNum) override { return 0; }
|
||||
|
||||
void GetStreamDataInfo(u32 *writePtr, u32 *writableBytes, u32 *readOffset) override;
|
||||
int AddStreamData(u32 bytesToAdd) override;
|
||||
|
|
|
@ -666,17 +666,13 @@ static u32 sceAtracSetLoopNum(int atracID, int loopNum) {
|
|||
if (err != 0) {
|
||||
return hleLogError(Log::ME, err);
|
||||
}
|
||||
if (atrac->GetTrack().loopinfo.size() == 0) {
|
||||
if (loopNum == -1) {
|
||||
// This is very common and not really a problem.
|
||||
return hleLogDebug(Log::ME, SCE_ERROR_ATRAC_NO_LOOP_INFORMATION, "no loop information to write to!");
|
||||
} else {
|
||||
return hleLogError(Log::ME, SCE_ERROR_ATRAC_NO_LOOP_INFORMATION, "no loop information to write to!");
|
||||
}
|
||||
}
|
||||
|
||||
atrac->SetLoopNum(loopNum);
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
int ret = atrac->SetLoopNum(loopNum);
|
||||
if (ret == SCE_ERROR_ATRAC_NO_LOOP_INFORMATION && loopNum == -1) {
|
||||
// Not really an issue
|
||||
return hleLogDebug(Log::ME, ret);
|
||||
}
|
||||
return hleLogDebugOrError(Log::ME, ret);
|
||||
}
|
||||
|
||||
static int sceAtracReinit(int at3Count, int at3plusCount) {
|
||||
|
@ -762,7 +758,7 @@ static int sceAtracSetMOutHalfwayBuffer(int atracID, u32 buffer, u32 readSize, u
|
|||
if (ret < 0) {
|
||||
return hleLogError(Log::ME, ret);
|
||||
}
|
||||
if (atrac->GetTrack().channels != 1) {
|
||||
if (atrac->Channels() != 1) {
|
||||
// It seems it still sets the data.
|
||||
atrac->SetData(buffer, readSize, bufferSize, 2);
|
||||
return hleReportError(Log::ME, SCE_ERROR_ATRAC_NOT_MONO, "not mono data");
|
||||
|
@ -784,7 +780,7 @@ static u32 sceAtracSetMOutData(int atracID, u32 buffer, u32 bufferSize) {
|
|||
if (ret < 0) {
|
||||
return hleLogError(Log::ME, ret);
|
||||
}
|
||||
if (atrac->GetTrack().channels != 1) {
|
||||
if (atrac->Channels() != 1) {
|
||||
// It seems it still sets the data.
|
||||
atrac->SetData(buffer, bufferSize, bufferSize, 2);
|
||||
return hleReportError(Log::ME, SCE_ERROR_ATRAC_NOT_MONO, "not mono data");
|
||||
|
@ -802,7 +798,7 @@ static int sceAtracSetMOutDataAndGetID(u32 buffer, u32 bufferSize) {
|
|||
delete atrac;
|
||||
return hleLogError(Log::ME, ret);
|
||||
}
|
||||
if (atrac->GetTrack().channels != 1) {
|
||||
if (atrac->Channels() != 1) {
|
||||
delete atrac;
|
||||
return hleReportError(Log::ME, SCE_ERROR_ATRAC_NOT_MONO, "not mono data");
|
||||
}
|
||||
|
@ -826,7 +822,7 @@ static int sceAtracSetMOutHalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 bu
|
|||
delete atrac;
|
||||
return hleLogError(Log::ME, ret);
|
||||
}
|
||||
if (atrac->GetTrack().channels != 1) {
|
||||
if (atrac->Channels() != 1) {
|
||||
delete atrac;
|
||||
return hleReportError(Log::ME, SCE_ERROR_ATRAC_NOT_MONO, "not mono data");
|
||||
}
|
||||
|
@ -885,7 +881,7 @@ struct At3HeaderMap {
|
|||
u8 jointStereo;
|
||||
|
||||
bool Matches(const AtracBase *at) const {
|
||||
return bytes == at->GetTrack().BytesPerFrame() && channels == at->GetTrack().channels;
|
||||
return bytes == at->BytesPerFrame() && channels == at->Channels();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -921,7 +917,7 @@ static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) {
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
WARN_LOG_REPORT_ONCE(at3headermap, Log::ME, "AT3 header map lacks entry for bpf: %i channels: %i", atrac->GetTrack().BytesPerFrame(), atrac->GetTrack().channels);
|
||||
WARN_LOG_REPORT_ONCE(at3headermap, Log::ME, "AT3 header map lacks entry for bpf: %i channels: %i", atrac->BytesPerFrame(), atrac->Channels());
|
||||
// TODO: Should we return an error code for these values?
|
||||
}
|
||||
}
|
||||
|
@ -929,7 +925,7 @@ static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) {
|
|||
atrac->InitLowLevel(paramsAddr, jointStereo);
|
||||
|
||||
const char *codecName = atrac->CodecType() == PSP_MODE_AT_3 ? "atrac3" : "atrac3+";
|
||||
const char *channelName = atrac->GetTrack().channels == 1 ? "mono" : "stereo";
|
||||
const char *channelName = atrac->Channels() == 1 ? "mono" : "stereo";
|
||||
return hleLogInfo(Log::ME, 0, "%s %s audio", codecName, channelName);
|
||||
}
|
||||
|
||||
|
|
|
@ -1018,9 +1018,11 @@ void DrawAudioDecodersView(ImConfig &cfg, ImControl &control) {
|
|||
if (ctx && ImGui::CollapsingHeader(header, ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
int pos;
|
||||
ctx->GetNextDecodePosition(&pos);
|
||||
ImGui::ProgressBar((float)pos / (float)ctx->GetTrack().endSample, ImVec2(200.0f, 0.0f));
|
||||
int endSample, loopStart, loopEnd;
|
||||
ctx->GetSoundSample(&endSample, &loopStart, &loopEnd);
|
||||
ImGui::ProgressBar((float)pos / (float)endSample, ImVec2(200.0f, 0.0f));
|
||||
ImGui::Text("Status: %s", AtracStatusToString(ctx->BufferState()));
|
||||
ImGui::Text("cur/end sample: %d/%d", pos, ctx->GetTrack().endSample);
|
||||
ImGui::Text("cur/end sample: %d/%d", pos, endSample);
|
||||
ImGui::Text("ctx addr: "); ImGui::SameLine(); ImClickableValue("addr", ctx->Decoder()->GetCtxPtr(), control, ImCmd::SHOW_IN_MEMORY_VIEWER);
|
||||
ImGui::Text("loop: %d", ctx->LoopNum());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue