Fix overflow in scePsmfPlayerGetCurrent*Stream().

And clean up the returned error codes.
This commit is contained in:
Unknown W. Brackets 2014-04-20 20:21:37 -07:00
parent 818d8cb894
commit 56673d3737

View File

@ -331,10 +331,10 @@ Psmf::~Psmf() {
}
PsmfPlayer::PsmfPlayer(const PsmfPlayerCreateData *data) {
videoCodec = 0;
videoStreamNum = 0;
audioCodec = 0;
audioStreamNum = 0;
videoCodec = -1;
videoStreamNum = -1;
audioCodec = -1;
audioStreamNum = -1;
playMode = 0;
playSpeed = 0;
psmfPlayerLastTimestamp = 0;
@ -1457,21 +1457,19 @@ u32 scePsmfPlayerGetCurrentVideoStream(u32 psmfPlayer, u32 videoCodecAddr, u32 v
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
if (!psmfplayer) {
ERROR_LOG(ME, "scePsmfPlayerGetCurrentVideoStream(%08x, %08x, %08x): invalid psmf player", psmfPlayer, videoCodecAddr, videoStreamNumAddr);
return ERROR_PSMF_NOT_FOUND;
return ERROR_PSMFPLAYER_INVALID_STATUS;
}
bool isInitialized = isInitializedStatus(psmfplayer->status);
if (!isInitialized) {
ERROR_LOG(ME, "scePsmfPlayerGetCurrentVideoStream(%08x): not initialized", psmfPlayer);
if (psmfplayer->status == PSMF_PLAYER_STATUS_INIT) {
ERROR_LOG(ME, "scePsmfPlayerGetCurrentVideoStream(%08x): psmf not yet set", psmfPlayer);
return ERROR_PSMFPLAYER_INVALID_STATUS;
}
WARN_LOG(ME, "scePsmfPlayerGetCurrentVideoStream(%08x, %08x, %08x)", psmfPlayer, videoCodecAddr, videoStreamNumAddr);
DEBUG_LOG(ME, "scePsmfPlayerGetCurrentVideoStream(%08x, %08x, %08x)", psmfPlayer, videoCodecAddr, videoStreamNumAddr);
if (Memory::IsValidAddress(videoCodecAddr)) {
Memory::Write_U64(psmfplayer->videoCodec, videoCodecAddr);
Memory::Write_U32(psmfplayer->videoCodec == 0x0E ? 0 : psmfplayer->videoCodec, videoCodecAddr);
}
if (Memory::IsValidAddress(videoStreamNumAddr)) {
Memory::Write_U64(psmfplayer->videoStreamNum, videoStreamNumAddr);
Memory::Write_U32(psmfplayer->videoStreamNum, videoStreamNumAddr);
}
return 0;
}
@ -1483,19 +1481,17 @@ u32 scePsmfPlayerGetCurrentAudioStream(u32 psmfPlayer, u32 audioCodecAddr, u32 a
ERROR_LOG(ME, "scePsmfPlayerGetCurrentAudioStream(%08x, %08x, %08x): invalid psmf player", psmfPlayer, audioCodecAddr, audioStreamNumAddr);
return ERROR_PSMF_NOT_FOUND;
}
bool isInitialized = isInitializedStatus(psmfplayer->status);
if (!isInitialized) {
ERROR_LOG(ME, "scePsmfPlayerGetCurrentAudioStream(%08x): not initialized", psmfPlayer);
if (psmfplayer->status == PSMF_PLAYER_STATUS_INIT) {
ERROR_LOG(ME, "scePsmfPlayerGetCurrentVideoStream(%08x): psmf not yet set", psmfPlayer);
return ERROR_PSMFPLAYER_INVALID_STATUS;
}
WARN_LOG(ME, "scePsmfPlayerGetCurrentAudioStream(%08x, %08x, %08x)", psmfPlayer, audioCodecAddr, audioStreamNumAddr);
DEBUG_LOG(ME, "scePsmfPlayerGetCurrentAudioStream(%08x, %08x, %08x)", psmfPlayer, audioCodecAddr, audioStreamNumAddr);
if (Memory::IsValidAddress(audioCodecAddr)) {
Memory::Write_U64(psmfplayer->audioCodec, audioCodecAddr);
Memory::Write_U32(psmfplayer->audioCodec == 0x0F ? 1 : psmfplayer->audioCodec, audioCodecAddr);
}
if (Memory::IsValidAddress(audioStreamNumAddr)) {
Memory::Write_U64(psmfplayer->audioStreamNum, audioStreamNumAddr);
Memory::Write_U32(psmfplayer->audioStreamNum, audioStreamNumAddr);
}
return 0;
}