mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-10 21:16:24 +02:00
Log cleanup. Fix very minor memory leak
This commit is contained in:
1 parent
41b77bf1ae
commit
52a7709fb5
6 files changed
+24
-19
No files matched your search
+1
-1
@@ -1534,7 +1534,7 @@ static FileNode *__IoOpen(int &error, const char *filename, int flags, int mode)
|
||||
|
||||
isTTY = true;
|
||||
} else {
|
||||
h = pspFileSystem.OpenFile(filename, (FileAccess)access);
|
||||
h = pspFileSystem.OpenFile(filename, (FileAccess)(access | (int)FileAccess::FILEACCESS_PPSSPP_QUIET));
|
||||
if (h < 0) {
|
||||
error = h;
|
||||
return nullptr;
|
||||
|
||||
+7
-8
@@ -711,23 +711,20 @@ static u32 sceMp3LowLevelInit(u32 mp3, u32 unk) {
|
||||
return hleDelayResult(hleLogInfo(Log::ME, 0), "mp3 low level", 600);
|
||||
}
|
||||
|
||||
// Used by SD Gundam Overworld for custom BGM, and Heroes VS.
|
||||
static u32 sceMp3LowLevelDecode(u32 mp3, u32 sourceAddr, u32 sourceBytesConsumedAddr, u32 samplesAddr, u32 sampleBytesAddr) {
|
||||
// sourceAddr: input mp3 stream buffer
|
||||
// sourceBytesConsumedAddr: consumed bytes decoded in source
|
||||
// samplesAddr: output pcm buffer
|
||||
// sampleBytesAddr: output pcm size
|
||||
DEBUG_LOG(Log::ME, "sceMp3LowLevelDecode(%08x, %08x, %08x, %08x, %08x)", mp3, sourceAddr, sourceBytesConsumedAddr, samplesAddr, sampleBytesAddr);
|
||||
|
||||
AuCtx *ctx = getMp3Ctx(mp3);
|
||||
if (!ctx) {
|
||||
ERROR_LOG(Log::ME, "%s: bad mp3 handle %08x", __FUNCTION__, mp3);
|
||||
return -1;
|
||||
return hleLogError(Log::ME, SCE_MP3_ERROR_INVALID_HANDLE, "invalid handle");
|
||||
}
|
||||
|
||||
if (!Memory::IsValidAddress(sourceAddr) || !Memory::IsValidAddress(sourceBytesConsumedAddr) ||
|
||||
!Memory::IsValidAddress(samplesAddr) || !Memory::IsValidAddress(sampleBytesAddr)) {
|
||||
ERROR_LOG(Log::ME, "sceMp3LowLevelDecode(%08x, %08x, %08x, %08x, %08x) : invalid address in args", mp3, sourceAddr, sourceBytesConsumedAddr, samplesAddr, sampleBytesAddr);
|
||||
return -1;
|
||||
return hleLogError(Log::ME, -1, "invalid address in args");
|
||||
}
|
||||
|
||||
const u8 *inbuff = Memory::GetPointerWriteUnchecked(sourceAddr);
|
||||
@@ -735,13 +732,15 @@ static u32 sceMp3LowLevelDecode(u32 mp3, u32 sourceAddr, u32 sourceBytesConsumed
|
||||
|
||||
int outSamples = 0;
|
||||
int inbytesConsumed = 0;
|
||||
ctx->decoder->Decode(inbuff, 4096, &inbytesConsumed, 2, outbuf, &outSamples);
|
||||
if (!ctx->decoder->Decode(inbuff, 4096, &inbytesConsumed, 2, outbuf, &outSamples)) {
|
||||
WARN_LOG(Log::ME, "sceMp3LowLevelDecode: Decode failed");
|
||||
}
|
||||
int outBytes = outSamples * sizeof(int16_t) * 2;
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, samplesAddr, outBytes, "Mp3LowLevelDecode");
|
||||
|
||||
Memory::Write_U32(inbytesConsumed, sourceBytesConsumedAddr);
|
||||
Memory::Write_U32(outBytes, sampleBytesAddr);
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
const HLEFunction sceMp3[] = {
|
||||
|
||||
@@ -1630,7 +1630,7 @@ static int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
|
||||
// The audio can end earlier than the video does.
|
||||
if (ringbuffer->packetsAvail == 0) {
|
||||
// TODO: Does this really delay?
|
||||
return hleDelayResult(hleLogError(Log::ME, SCE_MPEG_ERROR_NO_DATA), "mpeg get atrac", mpegDecodeErrorDelayMs);
|
||||
return hleDelayResult(hleLogDebug(Log::ME, SCE_MPEG_ERROR_NO_DATA), "mpeg get atrac", mpegDecodeErrorDelayMs);
|
||||
}
|
||||
|
||||
// esBuffer is the memory where this au data goes. We don't write the data to memory.
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
// NOTE: This is now unmaintained legacy code. scePsmf/scePsmfPlayer is just a wrapper over sceMpeg
|
||||
// which is always shipped by games that use it, so we simply load the libraries now and focus
|
||||
// on emulating sceMpeg as accurately as possible. We might actually go one step deeper if we can
|
||||
// figure out sceVideocodec, as sceMpeg is also often shipped.
|
||||
// figure out sceVideocodec, as sceMpeg is also often shipped (but not always!)
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -338,7 +338,9 @@ bool FFmpegAudioDecoder::Decode(const uint8_t *inbuf, int inbytes, int *inbytesC
|
||||
}
|
||||
|
||||
// get bytes consumed in source
|
||||
*inbytesConsumed = len;
|
||||
if (inbytesConsumed) {
|
||||
*inbytesConsumed = len;
|
||||
}
|
||||
|
||||
if (got_frame) {
|
||||
// Initializing the sample rate convert. We will use it to convert float output into int.
|
||||
@@ -352,15 +354,18 @@ bool FFmpegAudioDecoder::Decode(const uint8_t *inbuf, int inbytes, int *inbytesC
|
||||
#endif
|
||||
|
||||
if (!swrCtx_) {
|
||||
// TODO: Allow these to differ.
|
||||
const int inputSampleRate = codecCtx_->sample_rate;
|
||||
const int outputSampleRate = codecCtx_->sample_rate;
|
||||
#if LIBAVUTIL_VERSION_MAJOR >= 59
|
||||
swr_alloc_set_opts2(
|
||||
&swrCtx_,
|
||||
&wanted_channel_layout,
|
||||
AV_SAMPLE_FMT_S16,
|
||||
codecCtx_->sample_rate,
|
||||
outputSampleRate,
|
||||
&dec_channel_layout,
|
||||
codecCtx_->sample_fmt,
|
||||
codecCtx_->sample_rate,
|
||||
inputSampleRate,
|
||||
0,
|
||||
NULL);
|
||||
#else
|
||||
@@ -368,10 +373,10 @@ bool FFmpegAudioDecoder::Decode(const uint8_t *inbuf, int inbytes, int *inbytesC
|
||||
swrCtx_,
|
||||
wanted_channel_layout,
|
||||
AV_SAMPLE_FMT_S16,
|
||||
codecCtx_->sample_rate,
|
||||
outputSampleRate,
|
||||
dec_channel_layout,
|
||||
codecCtx_->sample_fmt,
|
||||
codecCtx_->sample_rate,
|
||||
inputSampleRate,
|
||||
0,
|
||||
NULL);
|
||||
#endif
|
||||
@@ -394,7 +399,9 @@ bool FFmpegAudioDecoder::Decode(const uint8_t *inbuf, int inbytes, int *inbytesC
|
||||
return false;
|
||||
}
|
||||
// output stereo samples per frame
|
||||
*outSamples = swrRet;
|
||||
if (outSamples) {
|
||||
*outSamples = swrRet;
|
||||
}
|
||||
|
||||
// Save outbuf into pcm audio, you can uncomment this line to save and check the decoded audio into pcm file.
|
||||
// SaveAudio("dump.pcm", outbuf, *outbytes);
|
||||
|
||||
+1
-2
@@ -918,9 +918,8 @@ void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, std::string_view nam
|
||||
char *path = (char *)userdata;
|
||||
if (clicked) {
|
||||
System_ShowFileInFolder(Path(path));
|
||||
} else {
|
||||
delete[] path;
|
||||
}
|
||||
delete[] path;
|
||||
}, path);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user