diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index a2ee30502e..5ca2f2119a 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -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; diff --git a/Core/HLE/sceMp3.cpp b/Core/HLE/sceMp3.cpp index ae91738197..5614ce2d1e 100644 --- a/Core/HLE/sceMp3.cpp +++ b/Core/HLE/sceMp3.cpp @@ -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[] = { diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 17caa60c7d..90040a6654 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -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. diff --git a/Core/HLE/scePsmf.h b/Core/HLE/scePsmf.h index a45c8be9f7..660d1af90d 100644 --- a/Core/HLE/scePsmf.h +++ b/Core/HLE/scePsmf.h @@ -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 diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp index 330c1e7116..105b902a7f 100644 --- a/Core/HW/SimpleAudioDec.cpp +++ b/Core/HW/SimpleAudioDec.cpp @@ -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); diff --git a/Core/System.cpp b/Core/System.cpp index 3d142aa9b9..6a8f3ab1f0 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -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); } }