Skip to content

Commit

Permalink
Merge pull request #19663 from hrydgard/more-imdebugger
Browse files Browse the repository at this point in the history
ImDebugger: Add config saving, add new audio channels window
  • Loading branch information
hrydgard authored Nov 27, 2024
2 parents db63bce + 2a05dce commit 5273d99
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 67 deletions.
9 changes: 4 additions & 5 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,11 +1677,10 @@ const Path Config::FindConfigFile(const std::string &baseFilename) {
}

// Make sure at least the directory it's supposed to be in exists.
Path path = filename.NavigateUp();
// This check is just to avoid logging.
if (!File::Exists(path)) {
File::CreateFullPath(path);
}
Path parent = filename.NavigateUp();

// We try to create the path and ignore if it fails (already exists).
File::CreateFullPath(parent);
return filename;
}

Expand Down
30 changes: 15 additions & 15 deletions Core/HLE/sceAudiocodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,36 @@ struct AudioCodecContext {
u32_le inDataSizeAgain; // 10 ??
};

// audioList is to store current playing audios.
static std::map<u32, AudioDecoder *> audioList;
// g_audioDecoderContexts is to store current playing audios.
std::map<u32, AudioDecoder *> g_audioDecoderContexts;

static bool oldStateLoaded = false;

// find the audio decoder for corresponding ctxPtr in audioList
static AudioDecoder *findDecoder(u32 ctxPtr) {
auto it = audioList.find(ctxPtr);
if (it != audioList.end()) {
auto it = g_audioDecoderContexts.find(ctxPtr);
if (it != g_audioDecoderContexts.end()) {
return it->second;
}
return NULL;
}

// remove decoder from audioList
static bool removeDecoder(u32 ctxPtr) {
auto it = audioList.find(ctxPtr);
if (it != audioList.end()) {
auto it = g_audioDecoderContexts.find(ctxPtr);
if (it != g_audioDecoderContexts.end()) {
delete it->second;
audioList.erase(it);
g_audioDecoderContexts.erase(it);
return true;
}
return false;
}

static void clearDecoders() {
for (const auto &[_, decoder] : audioList) {
for (const auto &[_, decoder] : g_audioDecoderContexts) {
delete decoder;
}
audioList.clear();
g_audioDecoderContexts.clear();
}

void __AudioCodecInit() {
Expand All @@ -86,9 +86,9 @@ static int sceAudiocodecInit(u32 ctxPtr, int codec) {
}
AudioDecoder *decoder = CreateAudioDecoder(audioType);
decoder->SetCtxPtr(ctxPtr);
audioList[ctxPtr] = decoder;
g_audioDecoderContexts[ctxPtr] = decoder;
INFO_LOG(Log::ME, "sceAudiocodecInit(%08x, %i (%s))", ctxPtr, codec, GetCodecName(audioType));
DEBUG_LOG(Log::ME, "Number of playing sceAudioCodec audios : %d", (int)audioList.size());
DEBUG_LOG(Log::ME, "Number of playing sceAudioCodec audios : %d", (int)g_audioDecoderContexts.size());
return 0;
}
ERROR_LOG_REPORT(Log::ME, "sceAudiocodecInit(%08x, %i (%s)): Unknown audio codec %i", ctxPtr, codec, GetCodecName(audioType), codec);
Expand All @@ -111,7 +111,7 @@ static int sceAudiocodecDecode(u32 ctxPtr, int codec) {
// Fake it by creating the desired context.
decoder = CreateAudioDecoder(audioType);
decoder->SetCtxPtr(ctxPtr);
audioList[ctxPtr] = decoder;
g_audioDecoderContexts[ctxPtr] = decoder;
}

if (decoder != NULL) {
Expand Down Expand Up @@ -175,7 +175,7 @@ void __sceAudiocodecDoState(PointerWrap &p){
return;
}

int count = (int)audioList.size();
int count = (int)g_audioDecoderContexts.size();
Do(p, count);

if (count > 0) {
Expand All @@ -200,7 +200,7 @@ void __sceAudiocodecDoState(PointerWrap &p){
for (int i = 0; i < count; i++) {
auto decoder = CreateAudioDecoder((PSPAudioType)codec_[i]);
decoder->SetCtxPtr(ctxPtr_[i]);
audioList[ctxPtr_[i]] = decoder;
g_audioDecoderContexts[ctxPtr_[i]] = decoder;
}
#ifdef __clang__
#pragma clang diagnostic pop
Expand All @@ -217,7 +217,7 @@ void __sceAudiocodecDoState(PointerWrap &p){
auto codec_ = new int[count];
auto ctxPtr_ = new u32[count];
int i = 0;
for (auto iter : audioList) {
for (auto iter : g_audioDecoderContexts) {
const AudioDecoder *decoder = iter.second;
codec_[i] = decoder->GetAudioType();
ctxPtr_[i] = decoder->GetCtxPtr();
Expand Down
5 changes: 5 additions & 0 deletions Core/HLE/sceAudiocodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#pragma once

#include <map>

class PointerWrap;

typedef struct {
Expand Down Expand Up @@ -61,3 +63,6 @@ void __AudioCodecInit();
void __AudioCodecShutdown();
void Register_sceAudiocodec();
void __sceAudiocodecDoState(PointerWrap &p);

class AudioDecoder;
extern std::map<u32, AudioDecoder *> g_audioDecoderContexts;
4 changes: 2 additions & 2 deletions Core/HLE/sceMp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

// Games known to support custom music and almost certainly use sceMp3:
// Games known to support custom music and almost certainly use sceMp3, unless they use sceAudiocodec:
//
// * ATV Offroad Fury: Blazin' Trails
// * Beats (/PSP/MUSIC)
Expand Down Expand Up @@ -147,7 +147,7 @@ struct Mp3ContextOld {
};
};

static std::map<u32, AuCtx *> mp3Map;
std::map<u32, AuCtx *> mp3Map;
static const int mp3DecodeDelay = 2400;
static bool resourceInited = false;

Expand Down
6 changes: 6 additions & 0 deletions Core/HLE/sceMp3.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@

#pragma once

#include <map>

class AuCtx;

class PointerWrap;

void Register_sceMp3();

void __Mp3Init();
void __Mp3Shutdown();
void __Mp3DoState(PointerWrap &p);

extern std::map<u32, AuCtx *> mp3Map;
3 changes: 2 additions & 1 deletion Core/HLE/sceMpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,8 @@ void PostPutAction::run(MipsCall &call) {
}
if (invalid) {
// Bail out early - don't accept any of the packets, even the good ones.
ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferPut(): invalid mpeg data");
// This happens during legit playback at the Burnout Legends menu!
ERROR_LOG(Log::ME, "sceMpegRingbufferPut(): invalid mpeg data");
call.setReturnValue(ERROR_MPEG_INVALID_VALUE);

if (mpegLibVersion <= 0x0103) {
Expand Down
1 change: 1 addition & 0 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,7 @@ void EmuScreen::renderImDebugger() {
Draw::DrawContext *draw = screenManager()->getDrawContext();
if (!imguiInited_) {
imguiInited_ = true;
ImGui_ImplPlatform_Init(GetSysDirectory(DIRECTORY_SYSTEM) / "imgui.ini");
imDebugger_ = std::make_unique<ImDebugger>();

// Read the TTF font
Expand Down
Loading

0 comments on commit 5273d99

Please sign in to comment.