Skip to content

Commit 0a00777

Browse files
Psmf: Only write current type/channel if valid.
And improve error handling in general.
1 parent 7ad07ca commit 0a00777

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

Core/HLE/scePsmf.cpp

+11-12
Original file line numberDiff line numberDiff line change
@@ -795,20 +795,19 @@ static u32 scePsmfGetAudioInfo(u32 psmfStruct, u32 audioInfoAddr) {
795795
static u32 scePsmfGetCurrentStreamType(u32 psmfStruct, u32 typeAddr, u32 channelAddr) {
796796
Psmf *psmf = getPsmf(psmfStruct);
797797
if (!psmf) {
798-
ERROR_LOG(ME, "scePsmfGetCurrentStreamType(%08x, %08x, %08x): invalid psmf", psmfStruct, typeAddr, channelAddr);
799-
return ERROR_PSMF_NOT_FOUND;
798+
return hleLogError(ME, ERROR_PSMF_NOT_INITIALIZED, "invalid psmf");
800799
}
801-
INFO_LOG(ME, "scePsmfGetCurrentStreamType(%08x, %08x, %08x)", psmfStruct, typeAddr, channelAddr);
802-
if (Memory::IsValidAddress(typeAddr)) {
803-
u32 type = 0, channel = 0;
804-
if (psmf->streamMap.find(psmf->currentStreamNum) != psmf->streamMap.end())
805-
type = psmf->streamMap[psmf->currentStreamNum]->type;
806-
if (psmf->streamMap.find(psmf->currentStreamNum) != psmf->streamMap.end())
807-
channel = psmf->streamMap[psmf->currentStreamNum]->channel;
808-
Memory::Write_U32(type, typeAddr);
809-
Memory::Write_U32(channel, channelAddr);
800+
if (psmf->currentStreamNum == ERROR_PSMF_NOT_INITIALIZED) {
801+
return hleLogError(ME, ERROR_PSMF_NOT_INITIALIZED, "no stream set");
810802
}
811-
return 0;
803+
if (!Memory::IsValidAddress(typeAddr) || !Memory::IsValidAddress(channelAddr)) {
804+
return hleLogError(ME, SCE_KERNEL_ERROR_ILLEGAL_ADDRESS, "bad pointers");
805+
}
806+
if (psmf->currentStreamType != -1) {
807+
Memory::Write_U32(psmf->currentStreamType, typeAddr);
808+
Memory::Write_U32(psmf->currentStreamChannel, channelAddr);
809+
}
810+
return hleLogSuccessI(ME, 0);
812811
}
813812

814813
static u32 scePsmfGetStreamSize(u32 psmfStruct, u32 sizeAddr)

0 commit comments

Comments
 (0)