mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-12-14 00:49:49 +00:00
Bug fix for sceMp3, make sceMp3 work fine. (dunno why this didn't merge before)
Conflicts: Core/HLE/sceMp3.cpp
This commit is contained in:
parent
46d085eef2
commit
ffc3db1429
@ -20,6 +20,7 @@
|
||||
#include "Core/HLE/sceMp3.h"
|
||||
#include "Core/HW/MediaEngine.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "../HW/MediaEngine.h"
|
||||
|
||||
#ifdef USE_FFMPEG
|
||||
#ifndef PRId64
|
||||
@ -129,10 +130,10 @@ int sceMp3Decode(u32 mp3, u32 outPcmPtr) {
|
||||
|
||||
AVFrame frame = {0};
|
||||
AVPacket packet = {0};
|
||||
int got_frame, ret;
|
||||
int got_frame = 0, ret;
|
||||
static int audio_frame_count = 0;
|
||||
|
||||
while (bytesdecoded < ctx->mp3PcmBufSize) {
|
||||
while (!got_frame) {
|
||||
if ((ret = av_read_frame(ctx->avformat_context, &packet)) < 0)
|
||||
break;
|
||||
|
||||
@ -147,7 +148,7 @@ int sceMp3Decode(u32 mp3, u32 outPcmPtr) {
|
||||
if (got_frame) {
|
||||
char buf[1024] = "";
|
||||
av_ts_make_time_string(buf, frame.pts, &ctx->decoder_context->time_base);
|
||||
INFO_LOG(HLE, "audio_frame n:%d nb_samples:%d pts:%s", audio_frame_count++, frame.nb_samples, buf);
|
||||
DEBUG_LOG(HLE, "audio_frame n:%d nb_samples:%d pts:%s", audio_frame_count++, frame.nb_samples, buf);
|
||||
|
||||
/*
|
||||
u8 *audio_dst_data;
|
||||
@ -423,7 +424,7 @@ int sceMp3GetSumDecodedSample(u32 mp3) {
|
||||
}
|
||||
|
||||
int sceMp3SetLoopNum(u32 mp3, int loop) {
|
||||
DEBUG_LOG(HLE, "sceMp3SetLoopNum(%08X, %i)", mp3, loop);
|
||||
INFO_LOG(HLE, "sceMp3SetLoopNum(%08X, %i)", mp3, loop);
|
||||
|
||||
Mp3Context *ctx = getMp3Ctx(mp3);
|
||||
if (!ctx) {
|
||||
@ -470,7 +471,7 @@ int sceMp3GetSamplingRate(u32 mp3) {
|
||||
}
|
||||
|
||||
int sceMp3GetInfoToAddStreamData(u32 mp3, u32 dstPtr, u32 towritePtr, u32 srcposPtr) {
|
||||
DEBUG_LOG(HLE, "HACK: sceMp3GetInfoToAddStreamData(%08X, %08X, %08X, %08X)", mp3, dstPtr, towritePtr, srcposPtr);
|
||||
INFO_LOG(HLE, "sceMp3GetInfoToAddStreamData(%08X, %08X, %08X, %08X)", mp3, dstPtr, towritePtr, srcposPtr);
|
||||
|
||||
Mp3Context *ctx = getMp3Ctx(mp3);
|
||||
if (!ctx) {
|
||||
@ -480,7 +481,7 @@ int sceMp3GetInfoToAddStreamData(u32 mp3, u32 dstPtr, u32 towritePtr, u32 srcpos
|
||||
|
||||
u32 buf, max_write;
|
||||
if (ctx->readPosition < ctx->mp3StreamEnd) {
|
||||
buf = ctx->mp3Buf;
|
||||
buf = ctx->mp3Buf + ctx->bufferWrite;
|
||||
max_write = std::min(ctx->mp3BufSize - ctx->bufferWrite, ctx->mp3BufSize - ctx->bufferAvailable);
|
||||
} else {
|
||||
buf = 0;
|
||||
@ -498,7 +499,7 @@ int sceMp3GetInfoToAddStreamData(u32 mp3, u32 dstPtr, u32 towritePtr, u32 srcpos
|
||||
}
|
||||
|
||||
int sceMp3NotifyAddStreamData(u32 mp3, int size) {
|
||||
DEBUG_LOG(HLE, "sceMp3NotifyAddStreamData(%08X, %i)", mp3, size);
|
||||
INFO_LOG(HLE, "sceMp3NotifyAddStreamData(%08X, %i)", mp3, size);
|
||||
|
||||
Mp3Context *ctx = getMp3Ctx(mp3);
|
||||
if (!ctx) {
|
||||
@ -513,6 +514,11 @@ int sceMp3NotifyAddStreamData(u32 mp3, int size) {
|
||||
if (ctx->bufferWrite == ctx->mp3BufSize)
|
||||
ctx->bufferWrite = 0;
|
||||
|
||||
if (ctx->readPosition >= ctx->mp3StreamEnd && ctx->mp3LoopNum != 0) {
|
||||
ctx->readPosition = ctx->mp3StreamStart;
|
||||
if (ctx->mp3LoopNum > 0)
|
||||
ctx->mp3LoopNum--;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user