Negative volume means unchanged, not error.

This commit is contained in:
Unknown W. Brackets 2013-05-17 21:51:08 -07:00
parent a1060ffabd
commit 4c36f12889
2 changed files with 43 additions and 24 deletions

View File

@ -276,6 +276,11 @@ template<u32 func(u32, int, int)> void WrapU_UII() {
RETURN(retval);
}
template<u32 func(u32, int, int, u32)> void WrapU_UIIU() {
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3));
RETURN(retval);
}
template<int func(u32, int, int, u32, u32)> void WrapI_UIIUU() {
u32 retval = func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
RETURN(retval);

View File

@ -52,7 +52,7 @@ AudioChannel chans[PSP_AUDIO_CHANNEL_MAX + 1];
// Not sure about the range of volume, I often see 0x800 so that might be either
// max or 50%?
u32 sceAudioOutputBlocking(u32 chan, u32 vol, u32 samplePtr) {
u32 sceAudioOutputBlocking(u32 chan, int vol, u32 samplePtr) {
if (vol > 0xFFFF) {
ERROR_LOG(HLE, "sceAudioOutputBlocking() - invalid volume");
return SCE_ERROR_AUDIO_INVALID_VOLUME;
@ -67,14 +67,16 @@ u32 sceAudioOutputBlocking(u32 chan, u32 vol, u32 samplePtr) {
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
} else {
DEBUG_LOG(HLE, "sceAudioOutputBlocking(%08x, %08x, %08x)", chan, vol, samplePtr);
chans[chan].leftVolume = vol;
chans[chan].rightVolume = vol;
if (vol >= 0) {
chans[chan].leftVolume = vol;
chans[chan].rightVolume = vol;
}
chans[chan].sampleAddress = samplePtr;
return __AudioEnqueue(chans[chan], chan, true);
}
}
u32 sceAudioOutputPannedBlocking(u32 chan, u32 leftvol, u32 rightvol, u32 samplePtr) {
u32 sceAudioOutputPannedBlocking(u32 chan, int leftvol, int rightvol, u32 samplePtr) {
if (leftvol > 0xFFFF || rightvol > 0xFFFF) {
ERROR_LOG(HLE, "sceAudioOutputPannedBlocking() - invalid volume");
return SCE_ERROR_AUDIO_INVALID_VOLUME;
@ -89,14 +91,18 @@ u32 sceAudioOutputPannedBlocking(u32 chan, u32 leftvol, u32 rightvol, u32 sample
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
} else {
DEBUG_LOG(HLE, "sceAudioOutputPannedBlocking(%08x, %08x, %08x, %08x)", chan, leftvol, rightvol, samplePtr);
chans[chan].leftVolume = leftvol;
chans[chan].rightVolume = rightvol;
if (leftvol >= 0) {
chans[chan].leftVolume = leftvol;
}
if (rightvol >= 0) {
chans[chan].rightVolume = rightvol;
}
chans[chan].sampleAddress = samplePtr;
return __AudioEnqueue(chans[chan], chan, true);
}
}
u32 sceAudioOutput(u32 chan, u32 vol, u32 samplePtr) {
u32 sceAudioOutput(u32 chan, int vol, u32 samplePtr) {
if (vol > 0xFFFF) {
ERROR_LOG(HLE, "sceAudioOutput() - invalid volume");
return SCE_ERROR_AUDIO_INVALID_VOLUME;
@ -111,14 +117,16 @@ u32 sceAudioOutput(u32 chan, u32 vol, u32 samplePtr) {
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
} else {
DEBUG_LOG(HLE, "sceAudioOutputPanned(%08x, %08x, %08x)", chan, vol, samplePtr);
chans[chan].leftVolume = vol;
chans[chan].rightVolume = vol;
if (vol >= 0) {
chans[chan].leftVolume = vol;
chans[chan].rightVolume = vol;
}
chans[chan].sampleAddress = samplePtr;
return __AudioEnqueue(chans[chan], chan, false);
}
}
u32 sceAudioOutputPanned(u32 chan, u32 leftvol, u32 rightvol, u32 samplePtr) {
u32 sceAudioOutputPanned(u32 chan, int leftvol, int rightvol, u32 samplePtr) {
if (leftvol > 0xFFFF || rightvol > 0xFFFF) {
ERROR_LOG(HLE, "sceAudioOutputPannedBlocking() - invalid volume");
return SCE_ERROR_AUDIO_INVALID_VOLUME;
@ -133,8 +141,12 @@ u32 sceAudioOutputPanned(u32 chan, u32 leftvol, u32 rightvol, u32 samplePtr) {
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
} else {
DEBUG_LOG(HLE,"sceAudioOutputPanned(%08x, %08x, %08x, %08x)", chan, leftvol, rightvol, samplePtr);
chans[chan].leftVolume = leftvol;
chans[chan].rightVolume = rightvol;
if (leftvol >= 0) {
chans[chan].leftVolume = leftvol;
}
if (rightvol >= 0) {
chans[chan].rightVolume = rightvol;
}
chans[chan].sampleAddress = samplePtr;
return __AudioEnqueue(chans[chan], chan, false);
}
@ -166,10 +178,10 @@ static u32 GetFreeChannel() {
return -1;
}
u32 sceAudioChReserve(u32 chan, u32 sampleCount, u32 format) {
if ((int)chan < 0) {
u32 sceAudioChReserve(int chan, u32 sampleCount, u32 format) {
if (chan < 0) {
chan = GetFreeChannel();
if ((int)chan < 0) {
if (chan < 0) {
ERROR_LOG(HLE, "sceAudioChReserve - no channels remaining");
return SCE_ERROR_AUDIO_NO_CHANNELS_AVAILABLE;
}
@ -195,6 +207,8 @@ u32 sceAudioChReserve(u32 chan, u32 sampleCount, u32 format) {
chans[chan].sampleCount = sampleCount;
chans[chan].format = format;
chans[chan].reserved = true;
chans[chan].leftVolume = 0;
chans[chan].rightVolume = 0;
return chan;
}
@ -396,21 +410,21 @@ const HLEFunction sceAudio[] =
{0x01562ba3, WrapU_U<sceAudioOutput2Reserve>, "sceAudioOutput2Reserve"},
{0x2d53f36e, WrapU_UU<sceAudioOutput2OutputBlocking>, "sceAudioOutput2OutputBlocking"},
{0x63f2889c, WrapU_U<sceAudioOutput2ChangeLength>, "sceAudioOutput2ChangeLength"},
{0x647cef33, WrapU_V<sceAudioOutput2GetRestSample>, "sceAudioOutput2GetRestSample"},
{0x647cef33, WrapU_V<sceAudioOutput2GetRestSample>, "sceAudioOutput2GetRestSample"},
{0x43196845, WrapU_V<sceAudioOutput2Release>, "sceAudioOutput2Release"},
{0x80F1F7E0, WrapU_V<sceAudioInit>, "sceAudioInit"},
{0x210567F7, WrapU_V<sceAudioEnd>, "sceAudioEnd"},
{0xA2BEAA6C, WrapU_U<sceAudioSetFrequency>, "sceAudioSetFrequency"},
{0x927AC32B, WrapU_V<sceAudioSetVolumeOffset>, "sceAudioSetVolumeOffset"},
{0x8c1009b2, WrapU_UUU<sceAudioOutput>, "sceAudioOutput"},
{0x136CAF51, WrapU_UUU<sceAudioOutputBlocking>, "sceAudioOutputBlocking"},
{0xE2D56B2D, WrapU_UUUU<sceAudioOutputPanned>, "sceAudioOutputPanned"},
{0x13F592BC, WrapU_UUUU<sceAudioOutputPannedBlocking>, "sceAudioOutputPannedBlocking"},
{0x5EC81C55, WrapU_UUU<sceAudioChReserve>, "sceAudioChReserve"},
{0x6FC46853, WrapU_U<sceAudioChRelease>, "sceAudioChRelease"},
{0x8c1009b2, WrapU_UIU<sceAudioOutput>, "sceAudioOutput"},
{0x136CAF51, WrapU_UIU<sceAudioOutputBlocking>, "sceAudioOutputBlocking"},
{0xE2D56B2D, WrapU_UIIU<sceAudioOutputPanned>, "sceAudioOutputPanned"},
{0x13F592BC, WrapU_UIIU<sceAudioOutputPannedBlocking>, "sceAudioOutputPannedBlocking"},
{0x5EC81C55, WrapU_IUU<sceAudioChReserve>, "sceAudioChReserve"},
{0x6FC46853, WrapU_U<sceAudioChRelease>, "sceAudioChRelease"},
{0xE9D97901, WrapI_U<sceAudioGetChannelRestLen>, "sceAudioGetChannelRestLen"},
{0xB011922F, WrapI_U<sceAudioGetChannelRestLen>, "sceAudioGetChannelRestLength"},
{0xCB2E439E, WrapU_UU<sceAudioSetChannelDataLen>, "sceAudioSetChannelDataLen"},
{0xB011922F, WrapI_U<sceAudioGetChannelRestLen>, "sceAudioGetChannelRestLength"},
{0xCB2E439E, WrapU_UU<sceAudioSetChannelDataLen>, "sceAudioSetChannelDataLen"},
{0x95FD0C2D, WrapU_UU<sceAudioChangeChannelConfig>, "sceAudioChangeChannelConfig"},
{0xB7E1D8E7, WrapU_UUU<sceAudioChangeChannelVolume>, "sceAudioChangeChannelVolume"},
{0x38553111, WrapU_UUU<sceAudioSRCChReserve>, "sceAudioSRCChReserve"},