2012-12-06 17:44:33 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2013-05-19 22:45:34 +00:00
|
|
|
#include "Common/ChunkFile.h"
|
2013-05-20 00:54:14 +00:00
|
|
|
#include "Core/Reporting.h"
|
2013-05-19 22:45:34 +00:00
|
|
|
#include "Core/HLE/HLE.h"
|
|
|
|
#include "Core/HLE/sceVaudio.h"
|
|
|
|
#include "Core/HLE/sceAudio.h"
|
|
|
|
#include "Core/HLE/__sceAudio.h"
|
2012-12-06 17:44:33 +00:00
|
|
|
|
2013-01-22 19:27:42 +00:00
|
|
|
// Ultra hacky Vaudio implementation. Not sure what the point of this API is.
|
2012-12-07 04:45:16 +00:00
|
|
|
|
2013-05-19 22:45:34 +00:00
|
|
|
bool vaudioReserved = false;
|
|
|
|
|
|
|
|
void __VaudioInit() {
|
|
|
|
vaudioReserved = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __VaudioDoState(PointerWrap &p) {
|
|
|
|
p.Do(vaudioReserved);
|
|
|
|
p.DoMarker("sceVaudio");
|
|
|
|
}
|
|
|
|
|
2012-12-23 16:42:28 +00:00
|
|
|
u32 sceVaudioChReserve(int sampleCount, int freq, int format) {
|
2013-05-19 22:45:34 +00:00
|
|
|
if (vaudioReserved) {
|
|
|
|
ERROR_LOG(HLE, "sceVaudioChReserve(%i, %i, %i) - already reserved", sampleCount, freq, format);
|
|
|
|
return SCE_KERNEL_ERROR_BUSY;
|
|
|
|
}
|
|
|
|
// We still have to check the channel also, which gives a different error.
|
|
|
|
if (chans[PSP_AUDIO_CHANNEL_VAUDIO].reserved) {
|
|
|
|
ERROR_LOG(HLE, "sceVaudioChReserve(%i, %i, %i) - channel already reserved", sampleCount, freq, format);
|
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_ALREADY_RESERVED;
|
|
|
|
}
|
|
|
|
DEBUG_LOG(HLE, "sceVaudioChReserve(%i, %i, %i)", sampleCount, freq, format);
|
2013-05-19 22:31:03 +00:00
|
|
|
chans[PSP_AUDIO_CHANNEL_VAUDIO].reserved = true;
|
|
|
|
chans[PSP_AUDIO_CHANNEL_VAUDIO].sampleCount = sampleCount;
|
|
|
|
chans[PSP_AUDIO_CHANNEL_VAUDIO].format = format;
|
2013-05-19 22:45:34 +00:00
|
|
|
chans[PSP_AUDIO_CHANNEL_VAUDIO].leftVolume = 0;
|
|
|
|
chans[PSP_AUDIO_CHANNEL_VAUDIO].rightVolume = 0;
|
|
|
|
vaudioReserved = true;
|
2013-01-22 19:27:42 +00:00
|
|
|
__AudioSetOutputFrequency(freq);
|
2012-12-09 12:41:19 +00:00
|
|
|
return 0;
|
2012-12-07 04:45:16 +00:00
|
|
|
}
|
|
|
|
|
2012-12-09 12:41:19 +00:00
|
|
|
u32 sceVaudioChRelease() {
|
2013-05-19 22:45:34 +00:00
|
|
|
DEBUG_LOG(HLE, "sceVaudioChRelease(...)");
|
2013-05-19 22:31:03 +00:00
|
|
|
if (!chans[PSP_AUDIO_CHANNEL_VAUDIO].reserved) {
|
2013-01-22 19:27:42 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
|
|
|
} else {
|
2013-05-21 07:58:47 +00:00
|
|
|
chans[PSP_AUDIO_CHANNEL_VAUDIO].reset();
|
2013-05-19 22:31:03 +00:00
|
|
|
chans[PSP_AUDIO_CHANNEL_VAUDIO].reserved = false;
|
2013-05-19 22:45:34 +00:00
|
|
|
vaudioReserved = false;
|
2013-01-22 19:27:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 sceVaudioOutputBlocking(int vol, u32 buffer) {
|
2013-05-19 22:45:34 +00:00
|
|
|
DEBUG_LOG(HLE, "sceVaudioOutputBlocking(%i, %08x)", vol, buffer);
|
|
|
|
chans[PSP_AUDIO_CHANNEL_OUTPUT2].leftVolume = vol;
|
|
|
|
chans[PSP_AUDIO_CHANNEL_OUTPUT2].rightVolume = vol;
|
|
|
|
// TODO: This may be wrong, not sure if's in a different format?
|
|
|
|
chans[PSP_AUDIO_CHANNEL_OUTPUT2].sampleAddress = buffer;
|
2013-05-20 07:08:43 +00:00
|
|
|
return __AudioEnqueue(chans[PSP_AUDIO_CHANNEL_VAUDIO], PSP_AUDIO_CHANNEL_VAUDIO, true);
|
2012-12-07 04:45:16 +00:00
|
|
|
}
|
|
|
|
|
2012-12-23 16:42:28 +00:00
|
|
|
u32 sceVaudioSetEffectType(int effectType, int vol) {
|
2013-05-20 00:54:14 +00:00
|
|
|
ERROR_LOG_REPORT(HLE, "UNIMPL sceVaudioSetEffectType(%i, %i)", effectType, vol);
|
2012-12-23 16:42:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 sceVaudioSetAlcMode(int alcMode) {
|
2013-05-20 00:54:14 +00:00
|
|
|
ERROR_LOG_REPORT(HLE, "UNIMPL sceVaudioSetAlcMode(%i)", alcMode);
|
2012-12-23 16:42:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-09 12:41:19 +00:00
|
|
|
const HLEFunction sceVaudio[] = {
|
2013-05-19 22:26:23 +00:00
|
|
|
{0x8986295e, WrapU_IU<sceVaudioOutputBlocking>, "sceVaudioOutputBlocking"},
|
|
|
|
{0x03b6807d, WrapU_III<sceVaudioChReserve>, "sceVaudioChReserve"},
|
|
|
|
{0x67585dfd, WrapU_V<sceVaudioChRelease>, "sceVaudioChRelease"},
|
2012-12-23 16:42:28 +00:00
|
|
|
{0x346FBE94, WrapU_II<sceVaudioSetEffectType>, "sceVaudioSetEffectType"},
|
|
|
|
{0xCBD4AC51, WrapU_I<sceVaudioSetAlcMode>, "sceVaudioSetAlcMode"},
|
2012-12-06 17:44:33 +00:00
|
|
|
};
|
|
|
|
|
2012-12-09 12:41:19 +00:00
|
|
|
void Register_sceVaudio() {
|
2012-12-06 17:44:33 +00:00
|
|
|
RegisterModule("sceVaudio",ARRAY_SIZE(sceVaudio), sceVaudio );
|
|
|
|
}
|