Merge branch 'master' into plugindownload

This commit is contained in:
Henrik Rydgard 2013-06-04 23:54:50 +02:00
commit 394a6a0f5c
7 changed files with 164 additions and 33 deletions

View file

@ -18,7 +18,6 @@
#pragma once
#include "../../Globals.h"
// For easy parameter parsing and return value processing.
// 64bit wrappers
@ -92,6 +91,16 @@ template<u32 func(int, void *, int)> void WrapU_IVI() {
RETURN(retval);
}
template<int func(int, const char *, u32, void *, void *, u32, int)> void WrapI_ICUVVUI() {
u32 retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)), PARAM(2), Memory::GetPointer(PARAM(3)),Memory::GetPointer(PARAM(4)), PARAM(5), PARAM(6) );
RETURN(retval);
}
template<u32 func(int, void *)> void WrapU_IV() {
u32 retval = func(PARAM(0), Memory::GetPointer(PARAM(1)));
RETURN(retval);
}
template<float func()> void WrapF_V() {
RETURNF(func());
}

View file

@ -992,17 +992,12 @@ int _AtracSetData(Atrac *atrac, u32 buffer, u32 bufferSize)
} else if (atrac->codeType == PSP_MODE_AT_3_PLUS) {
if (atrac->atracChannels == 1) {
WARN_LOG(HLE, "This is an atrac3+ mono audio");
#ifndef ANDROID
atrac->data_buf = new u8[atrac->first.filesize];
Memory::Memcpy(atrac->data_buf, buffer, std::min(bufferSize, atrac->first.filesize));
return __AtracSetContext(atrac);
#endif
} else {
WARN_LOG(HLE, "This is an atrac3+ stereo audio");
atrac->data_buf = new u8[atrac->first.filesize];
Memory::Memcpy(atrac->data_buf, buffer, std::min(bufferSize, atrac->first.filesize));
return __AtracSetContext(atrac);
}
atrac->data_buf = new u8[atrac->first.filesize];
Memory::Memcpy(atrac->data_buf, buffer, std::min(bufferSize, atrac->first.filesize));
return __AtracSetContext(atrac);
}

View file

@ -975,7 +975,7 @@ int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
int result = 0;
sceAu.pts = ctx->mediaengine->getVideoTimeStamp();
if (sceAu.pts >= ctx->mediaengine->getLastTimeStamp()) {
if (ctx->mediaengine->IsVideoEnd()) {
INFO_LOG(HLE, "video end reach. pts: %i dts: %i", (int)sceAu.pts, (int)ctx->mediaengine->getLastTimeStamp());
mpegRingbuffer.packetsFree = mpegRingbuffer.packets;
Memory::WriteStruct(ctx->mpegRingbufferAddr, &mpegRingbuffer);
@ -1039,7 +1039,7 @@ int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
int result = 0;
sceAu.pts = ctx->mediaengine->getAudioTimeStamp();
if (sceAu.pts >= ctx->mediaengine->getLastTimeStamp()) {
if (ctx->mediaengine->IsVideoEnd()) {
INFO_LOG(HLE, "video end reach. pts: %i dts: %i", (int)sceAu.pts, (int)ctx->mediaengine->getLastTimeStamp());
mpegRingbuffer.packetsFree = mpegRingbuffer.packets;
Memory::WriteStruct(ctx->mpegRingbufferAddr, &mpegRingbuffer);

View file

@ -52,6 +52,21 @@ enum {
ERROR_NET_ADHOCCTL_TOO_MANY_HANDLERS = 0x80410b12,
};
//these might come in handy in the future, if PPSSPP ever supports wifi/ad-hoc
typedef struct SceNetAdhocctlParams
{
int channel; //which ad-hoc channel to connect to
char name[8]; //connection name
u8 bssid[6]; //BSSID of the connection?
char nickname[128]; //PSP's nickname?
};
typedef struct ProductStruct
{
int unknown; //unknown, set to 0
char product[9]; //Product name?
};
void __NetInit() {
netInited = false;
netAdhocInited = false;
@ -114,11 +129,96 @@ u32 sceWlanGetSwitchState() {
return 0;
}
//handler probably shouldn't be an int...
u32 sceNetAdhocctlAddHandler(int handler, void *unknown) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlAddHandler(%x, %x)", handler, unknown);
return 0;
}
u32 sceNetAdhocctlDisconnect() {
DEBUG_LOG(HLE, "UNIMPL sceNetAdhocctlDisconnect()");
return 0;
}
u32 sceNetAdhocctlDelHandler(int handler) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlDelHandler(%x)", handler);
return 0;
}
int sceNetAdhocMatchingTerm() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocMatchingTerm()");
return 0;
}
int sceNetAdhocctlTerm() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlTerm()");
return 0;
}
int sceNetAdhocTerm() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocTerm()");
return 0;
}
//homebrew SDK claims it's a void function, but tests seem to indicate otherwise
int sceNetEtherNtostr(const char *mac, u32 bufferPtr) {
DEBUG_LOG(HLE, "UNTESTED sceNetEtherNtostr(%s, %x)", mac, bufferPtr);
int len = strlen(mac);
for (int i = 0; i < len; i++)
Memory::Write_U8(mac[i], bufferPtr + i);
return 0;
}
//write SCE_KERNEL_ERROR_ERRNO_NOT_CONNECTED to attempt to stop games from spamming wifi syscalls...
int sceNetAdhocctlGetState(u32 ptrToStatus) {
DEBUG_LOG(HLE, "UNTESTED sceNetAdhocctlGetState(%x)", ptrToStatus);
Memory::Write_U32(SCE_KERNEL_ERROR_ERRNO_NOT_CONNECTED, ptrToStatus);
return 0;
}
//always return -1 since we don't have any real networking...
int sceNetAdhocPdpCreate(const char *mac, u32 port, int bufferSize, u32 unknown) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlAddHandler(%s, %x, %x, %x)", mac, port, bufferSize, unknown);
return -1;
}
//SHOULD be int sceNetAdhocctlGetParameter(struct SceNetAdhocctlParams *params), but I don't want
//to mess up the function wrappers..
int sceNetAdhocctlGetParameter() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetParameter()");
return -1;
}
//SHOULD be int sceNetAdhocctlGetAdhocId(struct productStruct * product), but I don't want
//to mess up the function wrappers..
int sceNetAdhocctlGetAdhocId() {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocctlGetAdhocId()");
return -1;
}
//return -1 packets since we don't have networking yet
int sceNetAdhocPdpRecv(int id, const char *mac, u32 port, void *data, void *dataLength, u32 timeout, int nonBlock) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpRecv(%d, %d, %d, %x, %x, %d, %d)", id, mac, port, data, dataLength, timeout, nonBlock);
return -1;
}
//Assuming < 0 for failure, homebrew SDK doesn't have much to say about this one
int sceNetAdhocSetSocketAlert(int id, int flag) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocSetSocketAlert(%d, %d)", id, flag);
return -1;
}
int sceNetAdhocPdpDelete(int id, int unknown) {
ERROR_LOG(HLE, "UNIMPL sceNetAdhocPdpDelete(%d, %d)", id, unknown);
return 0;
}
const HLEFunction sceNet[] =
{
{0x39AF39A6, sceNetInit, "sceNetInit"},
{0x281928A9, WrapU_V<sceNetTerm>, "sceNetTerm"},
{0x89360950, 0, "sceNetEtherNtostr"},
{0x89360950, WrapI_CU<sceNetEtherNtostr>, "sceNetEtherNtostr"},
{0x0bf0a3ae, 0, "sceNetGetLocalEtherAddr"},
{0xd27961c9, 0, "sceNetEtherStrton"},
{0x50647530, 0, "sceNetFreeThreadinfo"},
@ -129,12 +229,12 @@ const HLEFunction sceNet[] =
const HLEFunction sceNetAdhoc[] =
{
{0xE1D621D7, WrapU_V<sceNetAdhocInit>, "sceNetAdhocInit"},
{0xA62C6F57, 0, "sceNetAdhocTerm"},
{0xA62C6F57, WrapI_V<sceNetAdhocTerm>, "sceNetAdhocTerm"},
{0x0AD043ED, 0, "sceNetAdhocctlConnect"},
{0x6f92741b, 0, "sceNetAdhocPdpCreate"},
{0x6f92741b, WrapI_CUIU<sceNetAdhocPdpCreate>, "sceNetAdhocPdpCreate"},
{0xabed3790, 0, "sceNetAdhocPdpSend"},
{0xdfe53e03, 0, "sceNetAdhocPdpRecv"},
{0x7f27bb5e, 0, "sceNetAdhocPdpDelete"},
{0xdfe53e03, WrapI_ICUVVUI<sceNetAdhocPdpRecv>, "sceNetAdhocPdpRecv"},
{0x7f27bb5e, WrapI_II<sceNetAdhocPdpDelete>, "sceNetAdhocPdpDelete"},
{0xc7c1fc57, 0, "sceNetAdhocGetPdpStat"},
{0x157e6225, 0, "sceNetAdhocPtpClose"},
{0x4da4c788, 0, "sceNetAdhocPtpSend"},
@ -151,7 +251,7 @@ const HLEFunction sceNetAdhoc[] =
{0xa0229362, 0, "sceNetAdhocGameModeDeleteMaster"},
{0x0b2228e9, 0, "sceNetAdhocGameModeDeleteReplica"},
{0x7F75C338, 0, "sceNetAdhocGameModeCreateMaster"},
{0x73bfd52d, 0, "sceNetAdhocSetSocketAlert"},
{0x73bfd52d, WrapI_II<sceNetAdhocSetSocketAlert>, "sceNetAdhocSetSocketAlert"},
{0x7a662d6b, 0, "sceNetAdhocPollSocket"},
{0x4d2ce199, 0, "sceNetAdhocGetSocketAlert"},
};
@ -164,7 +264,7 @@ int sceNetAdhocMatchingInit(u32 memsize) {
const HLEFunction sceNetAdhocMatching[] =
{
{0x2a2a1e07, WrapI_U<sceNetAdhocMatchingInit>, "sceNetAdhocMatchingInit"},
{0x7945ecda, 0, "sceNetAdhocMatchingTerm"},
{0x7945ecda, WrapI_V<sceNetAdhocMatchingTerm>, "sceNetAdhocMatchingTerm"},
{0xca5eda6f, 0, "sceNetAdhocMatchingCreate"},
{0x93ef3843, 0, "sceNetAdhocMatchingStart"},
{0x32b156b3, 0, "sceNetAdhocMatchingStop"},
@ -184,15 +284,15 @@ const HLEFunction sceNetAdhocMatching[] =
const HLEFunction sceNetAdhocctl[] =
{
{0xE26F226E, WrapU_IIU<sceNetAdhocctlInit>, "sceNetAdhocctlInit"},
{0x9D689E13, 0, "sceNetAdhocctlTerm"},
{0x20B317A0, 0, "sceNetAdhocctlAddHandler"},
{0x6402490B, 0, "sceNetAdhocctlDelHandler"},
{0x34401D65, 0, "sceNetAdhocctlDisconnect"},
{0x9D689E13, WrapI_V<sceNetAdhocctlTerm>, "sceNetAdhocctlTerm"},
{0x20B317A0, WrapU_IV<sceNetAdhocctlAddHandler>, "sceNetAdhocctlAddHandler"},
{0x6402490B, WrapU_I<sceNetAdhocctlDelHandler>, "sceNetAdhocctlDelHandler"},
{0x34401D65, WrapU_V<sceNetAdhocctlDisconnect>, "sceNetAdhocctlDisconnect"},
{0x0ad043ed, 0, "sceNetAdhocctlConnect"},
{0x08fff7a0, 0, "sceNetAdhocctlScan"},
{0x75ecd386, 0, "sceNetAdhocctlGetState"},
{0x75ecd386, WrapI_U<sceNetAdhocctlGetState>, "sceNetAdhocctlGetState"},
{0x8916c003, 0, "sceNetAdhocctlGetNameByAddr"},
{0xded9d28e, 0, "sceNetAdhocctlGetParameter"},
{0xded9d28e, WrapI_V<sceNetAdhocctlGetParameter>, "sceNetAdhocctlGetParameter"},
{0x81aee1be, 0, "sceNetAdhocctlGetScanInfo"},
{0x5e7f79c9, 0, "sceNetAdhocctlJoin"},
{0x8db83fdc, 0, "sceNetAdhocctlGetPeerInfo"},
@ -201,7 +301,7 @@ const HLEFunction sceNetAdhocctl[] =
{0x1ff89745, 0, "sceNetAdhocctlJoinEnterGameMode"},
{0xcf8e084d, 0, "sceNetAdhocctlExitGameMode"},
{0xe162cb14, 0, "sceNetAdhocctlGetPeerList"},
{0x362cbe8f, 0, "sceNetAdhocctlGetAdhocId"},
{0x362cbe8f, WrapI_V<sceNetAdhocctlGetAdhocId>, "sceNetAdhocctlGetAdhocId"},
{0x5a014ce0, 0, "sceNetAdhocctlGetGameModeInfo"},
{0x99560abe, 0, "sceNetAdhocctlGetAddrByName"},
{0xb0b80e80, 0, "sceNetAdhocctlCreateEnterGameModeMin"},

View file

@ -91,6 +91,7 @@ MediaEngine::MediaEngine(): m_streamSize(0), m_readSize(0), m_pdata(0) {
m_buffer = 0;
m_demux = 0;
m_audioContext = 0;
m_isVideoEnd = false;
}
MediaEngine::~MediaEngine() {
@ -128,6 +129,7 @@ void MediaEngine::closeMedia() {
m_pdata = 0;
m_demux = 0;
Atrac3plus_Decoder::CloseContext(&m_audioContext);
m_isVideoEnd = false;
}
int _MpegReadbuffer(void *opaque, uint8_t *buf, int buf_size)
@ -158,8 +160,22 @@ int64_t _MpegSeekbuffer(void *opaque, int64_t offset, int whence)
return offset;
}
#ifdef _DEBUG
void ffmpeg_logger(void *, int, const char *format, va_list va_args) {
char tmp[1024];
vsprintf(tmp, format, va_args);
INFO_LOG(HLE, tmp);
}
#endif
bool MediaEngine::openContext() {
#ifdef USE_FFMPEG
#ifdef _DEBUG
av_log_set_level(AV_LOG_VERBOSE);
av_log_set_callback(&ffmpeg_logger);
#endif
u8* tempbuf = (u8*)av_malloc(m_bufSize);
AVFormatContext *pFormatCtx = avformat_alloc_context();
@ -174,9 +190,6 @@ bool MediaEngine::openContext() {
if(avformat_find_stream_info(pFormatCtx, NULL) < 0)
return false;
// Dump information about file onto standard error
av_dump_format(pFormatCtx, 0, NULL, 0);
// Find the first video stream
for(int i = 0; i < (int)pFormatCtx->nb_streams; i++) {
if(pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
@ -208,6 +221,7 @@ bool MediaEngine::openContext() {
m_demux->demux();
m_audioPos = 0;
m_audioContext = Atrac3plus_Decoder::OpenContext();
m_isVideoEnd = false;
#endif // USE_FFMPEG
return true;
}
@ -362,13 +376,15 @@ bool MediaEngine::stepVideo(int videoPixelMode) {
if(frameFinished) {
int firstTimeStamp = bswap32(*(int*)(m_pdata + 86));
m_videopts = packet.pts + packet.duration - firstTimeStamp;
m_videopts = pFrame->pkt_dts + pFrame->pkt_duration - firstTimeStamp;
bGetFrame = true;
}
}
av_free_packet(&packet);
if (bGetFrame) break;
}
if (!bGetFrame && m_readSize >= m_streamSize)
m_isVideoEnd = true;
return bGetFrame;
#else
return true;
@ -552,7 +568,7 @@ s64 MediaEngine::getVideoTimeStamp() {
s64 MediaEngine::getAudioTimeStamp() {
if (m_demux)
return m_audiopts;
return std::max(m_audiopts - 4180, (s64)0);
return m_videopts;
}
@ -563,4 +579,3 @@ s64 MediaEngine::getLastTimeStamp() {
int lastTimeStamp = bswap32(*(int*)(m_pdata + 92));
return lastTimeStamp - firstTimeStamp;
}

View file

@ -58,6 +58,8 @@ public:
s64 getAudioTimeStamp();
s64 getLastTimeStamp();
bool IsVideoEnd() { return m_isVideoEnd;}
void DoState(PointerWrap &p) {
p.Do(m_streamSize);
p.Do(m_readSize);
@ -93,4 +95,6 @@ public:
int m_audioPos;
void* m_audioContext;
s64 m_audiopts;
bool m_isVideoEnd;
};

View file

@ -231,12 +231,20 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam)
if (align==4)
{
u32 value = Memory::ReadUnchecked_U32(address);
sprintf(temp, "%08x [%s]", value, symbolMap.GetSymbolName(symbolMap.GetSymbolNum(value)));
int num = symbolMap.GetSymbolNum(value);
if (num != -1)
sprintf(temp, "%08x [%s]", value, symbolMap.GetSymbolName(num));
else
sprintf(temp, "%08x", value);
}
else if (align==2)
{
u16 value = Memory::ReadUnchecked_U16(address);
sprintf(temp, "%04x [%s]", value, symbolMap.GetSymbolName(symbolMap.GetSymbolNum(value)));
int num = symbolMap.GetSymbolNum(value);
if (num != -1)
sprintf(temp, "%04x [%s]", value, symbolMap.GetSymbolName(num));
else
sprintf(temp, "%04x", value);
}
TextOut(hdc,70,rowY1,temp,(int)strlen(temp));