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"
|
2014-03-15 18:22:19 +00:00
|
|
|
#include "Core/HLE/FunctionWrappers.h"
|
2013-05-19 22:45:34 +00:00
|
|
|
#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) {
|
2013-09-15 03:23:03 +00:00
|
|
|
auto s = p.Section("sceVaudio", 1);
|
|
|
|
if (!s)
|
|
|
|
return;
|
|
|
|
|
2013-05-19 22:45:34 +00:00
|
|
|
p.Do(vaudioReserved);
|
|
|
|
}
|
|
|
|
|
2014-12-08 09:40:08 +00:00
|
|
|
static u32 sceVaudioChReserve(int sampleCount, int freq, int format) {
|
2013-05-19 22:45:34 +00:00
|
|
|
if (vaudioReserved) {
|
2013-09-07 20:02:55 +00:00
|
|
|
ERROR_LOG(SCEAUDIO, "sceVaudioChReserve(%i, %i, %i) - already reserved", sampleCount, freq, format);
|
2013-05-19 22:45:34 +00:00
|
|
|
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) {
|
2013-09-07 20:02:55 +00:00
|
|
|
ERROR_LOG(SCEAUDIO, "sceVaudioChReserve(%i, %i, %i) - channel already reserved", sampleCount, freq, format);
|
2013-05-19 22:45:34 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_ALREADY_RESERVED;
|
|
|
|
}
|
2013-09-07 20:02:55 +00:00
|
|
|
DEBUG_LOG(SCEAUDIO, "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;
|
2013-05-21 14:38:37 +00:00
|
|
|
chans[PSP_AUDIO_CHANNEL_VAUDIO].format = format == 2 ? PSP_AUDIO_FORMAT_STEREO : PSP_AUDIO_FORMAT_MONO;
|
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
|
|
|
}
|
|
|
|
|
2014-12-08 09:40:08 +00:00
|
|
|
static u32 sceVaudioChRelease() {
|
2013-09-07 20:02:55 +00:00
|
|
|
DEBUG_LOG(SCEAUDIO, "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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-08 09:40:08 +00:00
|
|
|
static u32 sceVaudioOutputBlocking(int vol, u32 buffer) {
|
2013-09-07 20:02:55 +00:00
|
|
|
DEBUG_LOG(SCEAUDIO, "sceVaudioOutputBlocking(%i, %08x)", vol, buffer);
|
2013-05-19 22:45:34 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-12-08 09:40:08 +00:00
|
|
|
static u32 sceVaudioSetEffectType(int effectType, int vol) {
|
2013-09-07 20:02:55 +00:00
|
|
|
ERROR_LOG_REPORT(SCEAUDIO, "UNIMPL sceVaudioSetEffectType(%i, %i)", effectType, vol);
|
2012-12-23 16:42:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-08 09:40:08 +00:00
|
|
|
static u32 sceVaudioSetAlcMode(int alcMode) {
|
2013-09-07 20:02:55 +00:00
|
|
|
ERROR_LOG_REPORT(SCEAUDIO, "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[] = {
|
2015-03-22 23:57:56 +00:00
|
|
|
{0X8986295E, &WrapU_IU<sceVaudioOutputBlocking>, "sceVaudioOutputBlocking", 'x', "ix" },
|
|
|
|
{0X03B6807D, &WrapU_III<sceVaudioChReserve>, "sceVaudioChReserve", 'x', "iii"},
|
|
|
|
{0X67585DFD, &WrapU_V<sceVaudioChRelease>, "sceVaudioChRelease", 'x', "" },
|
|
|
|
{0X346FBE94, &WrapU_II<sceVaudioSetEffectType>, "sceVaudioSetEffectType", 'x', "ii" },
|
|
|
|
{0XCBD4AC51, &WrapU_I<sceVaudioSetAlcMode>, "sceVaudioSetAlcMode", 'x', "i" },
|
|
|
|
{0X504E4745, nullptr, "sceVaudio_504E4745", '?', "" },
|
|
|
|
{0X27ACC20B, nullptr, "sceVaudioChReserveBuffering", '?', "" },
|
|
|
|
{0XE8E78DC8, nullptr, "sceVaudio_E8E78DC8", '?', "" },
|
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 );
|
|
|
|
}
|