2012-11-01 15:19:01 +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
|
2012-11-04 22:01:49 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-12-09 12:41:19 +00:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-11-01 15:19:01 +00:00
|
|
|
// 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/.
|
|
|
|
|
|
|
|
#include "../MIPS/MIPS.h"
|
|
|
|
#include "../Host.h"
|
2013-02-04 04:31:46 +00:00
|
|
|
#include "Core/CoreTiming.h"
|
|
|
|
#include "ChunkFile.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
#include "sceAudio.h"
|
|
|
|
#include "__sceAudio.h"
|
|
|
|
#include "HLE.h"
|
|
|
|
|
2013-02-04 04:31:46 +00:00
|
|
|
void AudioChannel::DoState(PointerWrap &p)
|
|
|
|
{
|
|
|
|
p.Do(reserved);
|
|
|
|
p.Do(sampleAddress);
|
|
|
|
p.Do(sampleCount);
|
|
|
|
p.Do(leftVolume);
|
|
|
|
p.Do(rightVolume);
|
|
|
|
p.Do(format);
|
|
|
|
p.Do(waitingThread);
|
|
|
|
sampleQueue.DoState(p);
|
|
|
|
p.DoMarker("AudioChannel");
|
|
|
|
}
|
2012-11-07 18:10:52 +00:00
|
|
|
|
|
|
|
// There's a second Audio api called Audio2 that only has one channel, I guess the 8 channel api was overkill.
|
|
|
|
// We simply map it to the first of the 8 channels.
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
AudioChannel chans[8];
|
2013-01-24 15:43:26 +00:00
|
|
|
int src; //not initialized and default 0
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// Enqueues the buffer pointer on the channel. If channel buffer queue is full (2 items?) will block until it isn't.
|
|
|
|
// For solid audio output we'll need a queue length of 2 buffers at least, we'll try that first.
|
|
|
|
|
|
|
|
// Not sure about the range of volume, I often see 0x800 so that might be either
|
|
|
|
// max or 50%?
|
2012-11-17 13:20:04 +00:00
|
|
|
|
2012-12-09 12:41:19 +00:00
|
|
|
u32 sceAudioOutputBlocking(u32 chan, u32 vol, u32 samplePtr) {
|
2013-04-16 07:46:39 +00:00
|
|
|
if (vol > 0xFFFF) {
|
|
|
|
ERROR_LOG(HLE, "sceAudioOutputBlocking() - invalid volume");
|
|
|
|
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
|
|
|
} else if (samplePtr == 0) {
|
2013-01-24 15:29:49 +00:00
|
|
|
ERROR_LOG(HLE, "sceAudioOutputBlocking() - Sample pointer null");
|
2012-12-09 12:41:19 +00:00
|
|
|
return 0;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioOutputBlocking() - bad channel");
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
|
|
|
} else if (!chans[chan].reserved) {
|
2012-11-17 13:20:04 +00:00
|
|
|
ERROR_LOG(HLE,"sceAudioOutputBlocking() - channel not reserved");
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
|
|
|
} else {
|
2013-01-24 15:29:49 +00:00
|
|
|
DEBUG_LOG(HLE, "sceAudioOutputBlocking(%08x, %08x, %08x)", chan, vol, samplePtr);
|
2012-11-17 13:20:04 +00:00
|
|
|
chans[chan].leftVolume = vol;
|
|
|
|
chans[chan].rightVolume = vol;
|
|
|
|
chans[chan].sampleAddress = samplePtr;
|
2012-12-09 12:41:19 +00:00
|
|
|
return __AudioEnqueue(chans[chan], chan, true);
|
2012-11-17 13:20:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioOutputPannedBlocking(u32 chan, u32 leftvol, u32 rightvol, u32 samplePtr) {
|
2013-04-16 09:15:16 +00:00
|
|
|
if (leftvol > 0xFFFF || rightvol > 0xFFFF) {
|
2013-04-16 07:46:39 +00:00
|
|
|
ERROR_LOG(HLE, "sceAudioOutputPannedBlocking() - invalid volume");
|
|
|
|
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
|
|
|
} else if (samplePtr == 0) {
|
2013-01-24 15:29:49 +00:00
|
|
|
ERROR_LOG(HLE, "sceAudioOutputPannedBlocking() - Sample pointer null");
|
2012-12-09 12:41:19 +00:00
|
|
|
return 0;
|
2012-12-23 16:55:54 +00:00
|
|
|
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
2013-01-24 15:29:49 +00:00
|
|
|
ERROR_LOG(HLE,"sceAudioOutputPannedBlocking() - bad channel");
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
|
|
|
} else if (!chans[chan].reserved) {
|
2013-01-24 15:29:49 +00:00
|
|
|
ERROR_LOG(HLE,"sceAudioOutputPannedBlocking() - channel not reserved");
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
|
|
|
} else {
|
2013-01-24 15:29:49 +00:00
|
|
|
DEBUG_LOG(HLE, "sceAudioOutputPannedBlocking(%08x, %08x, %08x, %08x)", chan, leftvol, rightvol, samplePtr);
|
|
|
|
chans[chan].leftVolume = leftvol;
|
|
|
|
chans[chan].rightVolume = rightvol;
|
2012-11-01 15:19:01 +00:00
|
|
|
chans[chan].sampleAddress = samplePtr;
|
2012-12-09 12:41:19 +00:00
|
|
|
return __AudioEnqueue(chans[chan], chan, true);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioOutput(u32 chan, u32 vol, u32 samplePtr) {
|
2013-04-16 07:46:39 +00:00
|
|
|
if (vol > 0xFFFF) {
|
|
|
|
ERROR_LOG(HLE, "sceAudioOutput() - invalid volume");
|
|
|
|
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
|
|
|
} else if (samplePtr == 0) {
|
2013-01-24 15:29:49 +00:00
|
|
|
ERROR_LOG(HLE, "sceAudioOutput() - Sample pointer null");
|
|
|
|
return 0;
|
|
|
|
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioOutput() - bad channel");
|
2012-11-17 13:20:04 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else if (!chans[chan].reserved) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioOutput(%08x, %08x, %08x) - channel not reserved", chan, vol, samplePtr);
|
2012-11-17 13:20:04 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else {
|
|
|
|
DEBUG_LOG(HLE, "sceAudioOutputPanned(%08x, %08x, %08x)", chan, vol, samplePtr);
|
2012-11-17 13:20:04 +00:00
|
|
|
chans[chan].leftVolume = vol;
|
|
|
|
chans[chan].rightVolume = vol;
|
2012-11-01 15:19:01 +00:00
|
|
|
chans[chan].sampleAddress = samplePtr;
|
2013-01-24 15:29:49 +00:00
|
|
|
return __AudioEnqueue(chans[chan], chan, false);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-16 11:34:52 +00:00
|
|
|
u32 sceAudioOutputPanned(u32 chan, u32 leftvol, u32 rightvol, u32 samplePtr) {
|
2013-04-16 09:15:16 +00:00
|
|
|
if (leftvol > 0xFFFF || rightvol > 0xFFFF) {
|
2013-04-16 07:46:39 +00:00
|
|
|
ERROR_LOG(HLE, "sceAudioOutputPannedBlocking() - invalid volume");
|
|
|
|
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
|
|
|
} else if (samplePtr == 0) {
|
2013-01-24 15:29:49 +00:00
|
|
|
ERROR_LOG(HLE, "sceAudioOutputPannedBlocking() - Sample pointer null");
|
|
|
|
return 0;
|
|
|
|
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioOutputPanned() - bad channel");
|
2012-11-17 13:20:04 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else if (!chans[chan].reserved) {
|
2013-04-16 11:34:52 +00:00
|
|
|
ERROR_LOG(HLE,"sceAudioOutputPanned(%08x, %08x, %08x, %08x) - channel not reserved", chan, leftvol, rightvol, samplePtr);
|
2012-11-17 13:20:04 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else {
|
2013-04-16 11:34:52 +00:00
|
|
|
DEBUG_LOG(HLE,"sceAudioOutputPanned(%08x, %08x, %08x, %08x)", chan, leftvol, rightvol, samplePtr);
|
|
|
|
chans[chan].leftVolume = leftvol;
|
|
|
|
chans[chan].rightVolume = rightvol;
|
2012-11-01 15:19:01 +00:00
|
|
|
chans[chan].sampleAddress = samplePtr;
|
2013-01-24 15:29:49 +00:00
|
|
|
return __AudioEnqueue(chans[chan], chan, false);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
int sceAudioGetChannelRestLen(u32 chan) {
|
|
|
|
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
|
|
|
ERROR_LOG(HLE, "sceAudioGetChannelRestLen(%08x) - bad channel", chan);
|
2012-11-24 00:25:26 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
|
|
|
}
|
2013-01-24 15:29:49 +00:00
|
|
|
DEBUG_LOG(HLE,"sceAudioGetChannelRestLen(%08x)", chan);
|
|
|
|
return (int)chans[chan].sampleQueue.size() / 2;
|
2012-11-17 13:20:04 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
int sceAudioGetChannelRestLength(u32 chan) {
|
|
|
|
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
|
|
|
ERROR_LOG(HLE, "sceAudioGetChannelRestLength(%08x) - bad channel", chan);
|
2012-11-24 00:25:26 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
|
|
|
}
|
2013-01-24 15:29:49 +00:00
|
|
|
DEBUG_LOG(HLE,"sceAudioGetChannelRestLength(%08x)", chan);
|
|
|
|
return (int)chans[chan].sampleQueue.size() / 2;
|
2012-11-17 13:20:04 +00:00
|
|
|
}
|
|
|
|
|
2013-02-01 16:16:01 +00:00
|
|
|
static u32 GetFreeChannel() {
|
|
|
|
for (u32 i = 0; i < PSP_AUDIO_CHANNEL_MAX ; i++)
|
2012-11-01 15:19:01 +00:00
|
|
|
if (!chans[i].reserved)
|
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioChReserve(u32 chan, u32 sampleCount, u32 format) {
|
2013-05-16 05:49:54 +00:00
|
|
|
if ((int)chan < 0) {
|
2013-01-24 15:29:49 +00:00
|
|
|
chan = GetFreeChannel();
|
2013-05-16 05:49:54 +00:00
|
|
|
if ((int)chan < 0) {
|
|
|
|
ERROR_LOG(HLE, "sceAudioChReserve - no channels remaining");
|
|
|
|
return SCE_ERROR_AUDIO_NO_CHANNELS_AVAILABLE;
|
|
|
|
}
|
2013-01-24 15:29:49 +00:00
|
|
|
}
|
|
|
|
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
2013-05-16 05:49:54 +00:00
|
|
|
ERROR_LOG(HLE, "sceAudioChReserve(%08x, %08x, %08x) - bad channel", chan, sampleCount, format);
|
2012-11-24 00:25:26 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
|
|
|
}
|
2013-01-24 15:29:49 +00:00
|
|
|
if (format != PSP_AUDIO_FORMAT_MONO && format != PSP_AUDIO_FORMAT_STEREO) {
|
|
|
|
ERROR_LOG(HLE, "sceAudioChReserve(%08x, %08x, %08x) - invalid format", chan, sampleCount, format);
|
2012-11-24 00:25:26 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_FORMAT;
|
|
|
|
}
|
2013-02-01 16:16:01 +00:00
|
|
|
if (chans[chan].reserved) {
|
2013-05-16 05:49:54 +00:00
|
|
|
ERROR_LOG(HLE, "sceAudioChReserve - reserve channel failed");
|
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
DEBUG_LOG(HLE, "sceAudioChReserve(%08x, %08x, %08x)", chan, sampleCount, format);
|
|
|
|
chans[chan].sampleCount = sampleCount;
|
2013-04-13 09:57:09 +00:00
|
|
|
chans[chan].format = format;
|
2013-01-24 15:29:49 +00:00
|
|
|
chans[chan].reserved = true;
|
|
|
|
return chan;
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioChRelease(u32 chan) {
|
|
|
|
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
|
|
|
ERROR_LOG(HLE, "sceAudioChRelease(%i) - bad channel", chan);
|
2012-11-24 00:25:26 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
if (!chans[chan].reserved) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioChRelease(%i) - channel not reserved", chan);
|
2012-11-24 00:25:26 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
|
|
|
}
|
2012-11-17 13:20:04 +00:00
|
|
|
DEBUG_LOG(HLE, "sceAudioChRelease(%i)", chan);
|
2013-03-02 16:25:41 +00:00
|
|
|
chans[chan].clear();
|
2013-01-24 15:29:49 +00:00
|
|
|
chans[chan].reserved = false;
|
2012-11-01 15:19:01 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioSetChannelDataLen(u32 chan, u32 len) {
|
|
|
|
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioSetChannelDataLen(%08x, %08x) - bad channel", chan, len);
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else if (!chans[chan].reserved) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioSetChannelDataLen(%08x, %08x) - channel not reserved", chan, len);
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else {
|
|
|
|
DEBUG_LOG(HLE, "sceAudioSetChannelDataLen(%08x, %08x)", chan, len);
|
2012-11-17 18:56:28 +00:00
|
|
|
chans[chan].sampleCount = len;
|
2012-12-09 12:41:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioChangeChannelConfig(u32 chan, u32 format) {
|
|
|
|
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioChangeChannelConfig(%08x, %08x) - invalid channel number", chan, format);
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else if (!chans[chan].reserved) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioChangeChannelConfig(%08x, %08x) - channel not reserved", chan, format);
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else {
|
|
|
|
DEBUG_LOG(HLE, "sceAudioChangeChannelConfig(%08x, %08x)", chan, format);
|
2012-12-09 12:41:19 +00:00
|
|
|
chans[chan].format = format;
|
|
|
|
return 0;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioChangeChannelVolume(u32 chan, u32 leftvol, u32 rightvol) {
|
2013-04-16 09:15:16 +00:00
|
|
|
if (leftvol > 0xFFFF || rightvol > 0xFFFF) {
|
2013-04-16 07:46:39 +00:00
|
|
|
ERROR_LOG(HLE,"sceAudioChangeChannelVolume(%08x, %08x, %08x) - invalid volume", chan, leftvol, rightvol);
|
|
|
|
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
|
|
|
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
2013-01-24 15:29:49 +00:00
|
|
|
ERROR_LOG(HLE,"sceAudioChangeChannelVolume(%08x, %08x, %08x) - invalid channel number", chan, leftvol, rightvol);
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else if (!chans[chan].reserved) {
|
|
|
|
ERROR_LOG(HLE,"sceAudioChangeChannelVolume(%08x, %08x, %08x) - channel not reserved", chan, leftvol, rightvol);
|
2012-12-09 12:41:19 +00:00
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
2013-01-24 15:29:49 +00:00
|
|
|
} else {
|
|
|
|
DEBUG_LOG(HLE, "sceAudioChangeChannelVolume(%08x, %08x, %08x)", chan, leftvol, rightvol);
|
|
|
|
chans[chan].leftVolume = leftvol;
|
|
|
|
chans[chan].rightVolume = rightvol;
|
2012-12-09 12:41:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
2012-12-23 08:44:43 +00:00
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioInit(){
|
2012-11-27 11:18:58 +00:00
|
|
|
DEBUG_LOG(HLE,"sceAudioInit()");
|
2012-11-17 18:56:28 +00:00
|
|
|
// Don't need to do anything
|
2012-11-27 11:18:58 +00:00
|
|
|
return 0;
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
2013-01-24 15:29:49 +00:00
|
|
|
|
|
|
|
u32 sceAudioEnd(){
|
2012-11-17 18:56:28 +00:00
|
|
|
DEBUG_LOG(HLE,"sceAudioEnd()");
|
|
|
|
// Don't need to do anything
|
2012-11-27 11:18:58 +00:00
|
|
|
return 0;
|
2012-11-17 18:56:28 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioOutput2Reserve(u32 sampleCount){
|
|
|
|
DEBUG_LOG(HLE,"sceAudioOutput2Reserve(%08x)", sampleCount);
|
2013-01-25 00:48:28 +00:00
|
|
|
chans[0].sampleCount = sampleCount;
|
|
|
|
chans[0].reserved = true;
|
2012-11-27 11:18:58 +00:00
|
|
|
return 0;
|
2012-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioOutput2OutputBlocking(u32 vol, u32 dataPtr){
|
2013-05-13 20:06:49 +00:00
|
|
|
// Note: 0xFFFFF, not 0xFFFF!
|
2013-05-14 00:32:51 +00:00
|
|
|
if (vol < 0 || vol > 0xFFFFF) {
|
2013-04-16 07:46:39 +00:00
|
|
|
ERROR_LOG(HLE,"sceAudioOutput2OutputBlocking(%08x, %08x) - invalid volume", vol, dataPtr);
|
|
|
|
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
|
|
|
}
|
2013-01-24 15:29:49 +00:00
|
|
|
DEBUG_LOG(HLE,"sceAudioOutput2OutputBlocking(%08x, %08x)", vol, dataPtr);
|
2012-11-07 18:10:52 +00:00
|
|
|
chans[0].leftVolume = vol;
|
|
|
|
chans[0].rightVolume = vol;
|
|
|
|
chans[0].sampleAddress = dataPtr;
|
2012-12-09 12:41:19 +00:00
|
|
|
return __AudioEnqueue(chans[0], 0, true);
|
2012-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioOutput2ChangeLength(u32 sampleCount){
|
|
|
|
DEBUG_LOG(HLE,"sceAudioOutput2ChangeLength(%08x)", sampleCount);
|
2013-03-30 15:58:13 +00:00
|
|
|
if (!chans[0].reserved) {
|
|
|
|
DEBUG_LOG(HLE,"sceAudioOutput2ChangeLength(%08x) - channel not reserved ", sampleCount);
|
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
|
|
|
}
|
2012-11-23 09:33:19 +00:00
|
|
|
chans[0].sampleCount = sampleCount;
|
|
|
|
return 0;
|
2012-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioOutput2GetRestSample(){
|
|
|
|
DEBUG_LOG(HLE,"sceAudioOutput2GetRestSample()");
|
2013-03-30 15:58:13 +00:00
|
|
|
if (!chans[0].reserved) {
|
|
|
|
DEBUG_LOG(HLE,"sceAudioOutput2GetRestSample() - channel not reserved ");
|
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
|
|
|
}
|
2013-01-19 21:48:20 +00:00
|
|
|
return (u32) chans[0].sampleQueue.size() * 2;
|
2012-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioOutput2Release(){
|
2012-12-20 14:06:38 +00:00
|
|
|
DEBUG_LOG(HLE,"sceAudioOutput2Release()");
|
2013-03-02 16:25:41 +00:00
|
|
|
chans[0].clear();
|
2013-01-25 00:48:28 +00:00
|
|
|
chans[0].reserved = false;
|
2012-11-27 11:18:58 +00:00
|
|
|
return 0;
|
2012-11-07 18:10:52 +00:00
|
|
|
}
|
|
|
|
|
2012-11-17 13:20:04 +00:00
|
|
|
u32 sceAudioSetFrequency(u32 freq) {
|
|
|
|
if (freq == 44100 || freq == 48000) {
|
2013-01-24 15:29:49 +00:00
|
|
|
INFO_LOG(HLE, "sceAudioSetFrequency(%08x)", freq);
|
2012-11-17 13:20:04 +00:00
|
|
|
__AudioSetOutputFrequency(freq);
|
|
|
|
return 0;
|
|
|
|
} else {
|
2013-01-24 15:29:49 +00:00
|
|
|
ERROR_LOG(HLE, "sceAudioSetFrequency(%08x) - invalid frequency (must be 44.1 or 48 khz)", freq);
|
2013-03-30 15:58:13 +00:00
|
|
|
return SCE_ERROR_AUDIO_INVALID_FREQUENCY;
|
2012-11-17 13:20:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioSetVolumeOffset() {
|
|
|
|
ERROR_LOG(HLE, "UNIMPL sceAudioSetVolumeOffset()");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 sceAudioSRCChReserve(u32 sampleCount, u32 freq, u32 format) {
|
2013-03-30 15:58:13 +00:00
|
|
|
if (chans[src].reserved) {
|
|
|
|
DEBUG_LOG(HLE, "sceAudioSRCChReserve(%08x, %08x, %08x) - channel already reserved ", sampleCount, freq, format);
|
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_ALREADY_RESERVED;
|
|
|
|
} else {
|
|
|
|
DEBUG_LOG(HLE, "sceAudioSRCChReserve(%08x, %08x, %08x)", sampleCount, freq, format);
|
|
|
|
chans[src].reserved = true;
|
|
|
|
chans[src].sampleCount = sampleCount;
|
|
|
|
chans[src].format = format;
|
|
|
|
__AudioSetOutputFrequency(freq);
|
|
|
|
}
|
2013-01-24 15:29:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 sceAudioSRCChRelease() {
|
|
|
|
DEBUG_LOG(HLE, "sceAudioSRCChRelease()");
|
2013-03-30 15:58:13 +00:00
|
|
|
if (!chans[src].reserved) {
|
|
|
|
DEBUG_LOG(HLE, "sceAudioSRCChRelease() - channel already reserved ");
|
|
|
|
return SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED;
|
|
|
|
}
|
2013-03-02 16:25:41 +00:00
|
|
|
chans[src].clear();
|
2013-01-25 00:48:28 +00:00
|
|
|
chans[src].reserved = false;
|
2012-12-17 19:15:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-01-24 15:29:49 +00:00
|
|
|
u32 sceAudioSRCOutputBlocking(u32 vol, u32 buf) {
|
2013-05-14 00:32:51 +00:00
|
|
|
if (vol < 0 || vol > 0xFFFFF) {
|
2013-04-16 07:46:39 +00:00
|
|
|
ERROR_LOG(HLE,"sceAudioSRCOutputBlocking(%08x, %08x) - invalid volume", vol, buf);
|
|
|
|
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
|
|
|
}
|
2013-01-24 15:29:49 +00:00
|
|
|
DEBUG_LOG(HLE, "sceAudioSRCOutputBlocking(%08x, %08x)", vol, buf);
|
|
|
|
chans[src].leftVolume = vol;
|
|
|
|
chans[src].rightVolume = vol;
|
|
|
|
chans[src].sampleAddress = buf;
|
|
|
|
return __AudioEnqueue(chans[src], src, true);
|
|
|
|
}
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
const HLEFunction sceAudio[] =
|
|
|
|
{
|
2012-11-23 09:33:19 +00:00
|
|
|
// Newer simplified single channel audio output. Presumably for games that use Atrac3
|
|
|
|
// directly from Sas instead of playing it on a separate audio channel.
|
2012-12-09 12:41:19 +00:00
|
|
|
{0x01562ba3, WrapU_U<sceAudioOutput2Reserve>, "sceAudioOutput2Reserve"},
|
|
|
|
{0x2d53f36e, WrapU_UU<sceAudioOutput2OutputBlocking>, "sceAudioOutput2OutputBlocking"},
|
|
|
|
{0x63f2889c, WrapU_U<sceAudioOutput2ChangeLength>, "sceAudioOutput2ChangeLength"},
|
|
|
|
{0x647cef33, WrapU_V<sceAudioOutput2GetRestSample>, "sceAudioOutput2GetRestSample"},
|
|
|
|
{0x43196845, WrapU_V<sceAudioOutput2Release>, "sceAudioOutput2Release"},
|
2012-11-27 11:18:58 +00:00
|
|
|
{0x80F1F7E0, WrapU_V<sceAudioInit>, "sceAudioInit"},
|
|
|
|
{0x210567F7, WrapU_V<sceAudioEnd>, "sceAudioEnd"},
|
2012-12-09 12:41:19 +00:00
|
|
|
{0xA2BEAA6C, WrapU_U<sceAudioSetFrequency>, "sceAudioSetFrequency"},
|
2013-01-24 15:29:49 +00:00
|
|
|
{0x927AC32B, WrapU_V<sceAudioSetVolumeOffset>, "sceAudioSetVolumeOffset"},
|
2012-12-09 12:41:19 +00:00
|
|
|
{0x8c1009b2, WrapU_UUU<sceAudioOutput>, "sceAudioOutput"},
|
|
|
|
{0x136CAF51, WrapU_UUU<sceAudioOutputBlocking>, "sceAudioOutputBlocking"},
|
|
|
|
{0xE2D56B2D, WrapU_UUUU<sceAudioOutputPanned>, "sceAudioOutputPanned"},
|
2013-01-24 15:29:49 +00:00
|
|
|
{0x13F592BC, WrapU_UUUU<sceAudioOutputPannedBlocking>, "sceAudioOutputPannedBlocking"},
|
|
|
|
{0x5EC81C55, WrapU_UUU<sceAudioChReserve>, "sceAudioChReserve"},
|
|
|
|
{0x6FC46853, WrapU_U<sceAudioChRelease>, "sceAudioChRelease"},
|
2012-12-09 12:41:19 +00:00
|
|
|
{0xE9D97901, WrapI_U<sceAudioGetChannelRestLen>, "sceAudioGetChannelRestLen"},
|
2013-01-24 15:29:49 +00:00
|
|
|
{0xB011922F, WrapI_U<sceAudioGetChannelRestLen>, "sceAudioGetChannelRestLength"},
|
|
|
|
{0xCB2E439E, WrapU_UU<sceAudioSetChannelDataLen>, "sceAudioSetChannelDataLen"},
|
2012-12-09 12:41:19 +00:00
|
|
|
{0x95FD0C2D, WrapU_UU<sceAudioChangeChannelConfig>, "sceAudioChangeChannelConfig"},
|
|
|
|
{0xB7E1D8E7, WrapU_UUU<sceAudioChangeChannelVolume>, "sceAudioChangeChannelVolume"},
|
2013-01-24 15:29:49 +00:00
|
|
|
{0x38553111, WrapU_UUU<sceAudioSRCChReserve>, "sceAudioSRCChReserve"},
|
|
|
|
{0x5C37C0AE, WrapU_V<sceAudioSRCChRelease>, "sceAudioSRCChRelease"},
|
|
|
|
{0xE0727056, WrapU_UU<sceAudioSRCOutputBlocking>, "sceAudioSRCOutputBlocking"},
|
2012-11-23 09:33:19 +00:00
|
|
|
|
|
|
|
// Never seen these used
|
2012-11-17 13:20:04 +00:00
|
|
|
{0x41efade7, 0, "sceAudioOneshotOutput"},
|
|
|
|
{0xB61595C0, 0, "sceAudioLoopbackTest"},
|
2012-11-23 09:33:19 +00:00
|
|
|
|
|
|
|
// Microphone interface
|
2012-11-17 13:20:04 +00:00
|
|
|
{0x7de61688, 0, "sceAudioInputInit"},
|
|
|
|
{0xE926D3FB, 0, "sceAudioInputInitEx"},
|
2012-12-09 12:41:19 +00:00
|
|
|
{0x6d4bec68, 0, "sceAudioInput"},
|
|
|
|
{0x086e5895, 0, "sceAudioInputBlocking"},
|
|
|
|
{0xa708c6a6, 0, "sceAudioGetInputLength"},
|
2012-11-17 13:20:04 +00:00
|
|
|
{0xA633048E, 0, "sceAudioPollInputEnd"},
|
|
|
|
{0x87b2e651, 0, "sceAudioWaitInputEnd"},
|
2012-11-01 15:19:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void Register_sceAudio()
|
|
|
|
{
|
2012-12-09 12:41:19 +00:00
|
|
|
RegisterModule("sceAudio", ARRAY_SIZE(sceAudio), sceAudio);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|