Skip to content

Commit

Permalink
Don't allow sceMpegInit() twice.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Jun 8, 2013
1 parent 17907b2 commit 8b25545
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Core/HLE/sceMpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ struct MpegContext {
MediaEngine *mediaengine;
};

static bool isMpegInit;
static u32 streamIdGen;
static bool isCurrentMpegAnalyzed;
static int actionPostPut;
Expand Down Expand Up @@ -299,13 +300,15 @@ void __MpegInit(bool useMediaEngine_) {
lastMpegHandle = 0;
streamIdGen = 1;
isCurrentMpegAnalyzed = false;
isMpegInit = false;
actionPostPut = __KernelRegisterActionType(PostPutAction::Create);
}

void __MpegDoState(PointerWrap &p) {
p.Do(lastMpegHandle);
p.Do(streamIdGen);
p.Do(isCurrentMpegAnalyzed);
p.Do(isMpegInit);
p.Do(actionPostPut);
__KernelRestoreActionType(actionPostPut, PostPutAction::Create);

Expand All @@ -322,15 +325,20 @@ void __MpegShutdown() {
mpegMap.clear();
}

u32 sceMpegInit()
{
if (!g_Config.bUseMediaEngine){
u32 sceMpegInit() {
if (!g_Config.bUseMediaEngine) {
WARN_LOG(HLE, "Media Engine disabled");
return -1;
}

WARN_LOG(HLE, "sceMpegInit()");
return 0;
if (isMpegInit) {
WARN_LOG(HLE, "sceMpegInit(): already initialized");
return ERROR_MPEG_ALREADY_INIT;
}

INFO_LOG(HLE, "sceMpegInit()");
isMpegInit = true;
return hleDelayResult(0, "mpeg init", 750);
}

u32 sceMpegRingbufferQueryMemSize(int packets)
Expand Down Expand Up @@ -997,9 +1005,16 @@ int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)

u32 sceMpegFinish()
{
ERROR_LOG(HLE, "sceMpegFinish(...)");
if (!isMpegInit)
{
WARN_LOG(HLE, "sceMpegFinish(...): not initialized");
return ERROR_MPEG_NOT_YET_INIT;
}

INFO_LOG(HLE, "sceMpegFinish(...)");
isMpegInit = false;
//__MpegFinish();
return 0;
return hleDelayResult(0, "mpeg finish", 250);
}

u32 sceMpegQueryMemSize()
Expand Down
2 changes: 2 additions & 0 deletions Core/HLE/sceMpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ enum {
ERROR_PSMFPLAYER_NO_MORE_DATA = 0x8061600c,

ERROR_MPEG_NO_DATA = 0x80618001,
ERROR_MPEG_ALREADY_INIT = 0x80618005,
ERROR_MPEG_NOT_YET_INIT = 0x80618009,
};

// MPEG statics.
Expand Down

0 comments on commit 8b25545

Please sign in to comment.