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
|
|
|
|
// 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/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
#include "CommonTypes.h"
|
2012-11-17 13:20:04 +00:00
|
|
|
#include "sceKernel.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
#include "FixedSizeQueue.h"
|
|
|
|
|
2013-02-04 04:31:46 +00:00
|
|
|
class PointerWrap;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
enum PspAudioFormats { PSP_AUDIO_FORMAT_STEREO = 0, PSP_AUDIO_FORMAT_MONO = 0x10 };
|
|
|
|
enum PspAudioFrequencies { PSP_AUDIO_FREQ_44K = 44100, PSP_AUDIO_FREQ_48K = 48000 };
|
|
|
|
|
|
|
|
#define SCE_ERROR_AUDIO_CHANNEL_NOT_INIT 0x80260001
|
|
|
|
#define SCE_ERROR_AUDIO_CHANNEL_BUSY 0x80260002
|
|
|
|
#define SCE_ERROR_AUDIO_INVALID_CHANNEL 0x80260003
|
|
|
|
#define SCE_ERROR_AUDIO_PRIV_REQUIRED 0x80260004
|
|
|
|
#define SCE_ERROR_AUDIO_NO_CHANNELS_AVAILABLE 0x80260005
|
|
|
|
#define SCE_ERROR_AUDIO_OUTPUT_SAMPLE_DATA_SIZE_NOT_ALIGNED 0x80260006
|
|
|
|
#define SCE_ERROR_AUDIO_INVALID_FORMAT 0x80260007
|
|
|
|
#define SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED 0x80260008
|
|
|
|
#define SCE_ERROR_AUDIO_NOT_OUTPUT 0x80260009
|
2013-04-16 07:48:17 +00:00
|
|
|
#define SCE_ERROR_AUDIO_INVALID_FREQUENCY 0x8026000A
|
|
|
|
#define SCE_ERROR_AUDIO_INVALID_VOLUME 0x8026000B
|
|
|
|
#define SCE_ERROR_AUDIO_CHANNEL_ALREADY_RESERVED 0x80268002
|
2013-03-30 15:55:49 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-06-01 05:40:50 +00:00
|
|
|
const u32 PSP_AUDIO_CHANNEL_MAX = 8;
|
2013-05-16 06:18:57 +00:00
|
|
|
|
|
|
|
const int PSP_AUDIO_CHANNEL_SRC = 8;
|
|
|
|
const int PSP_AUDIO_CHANNEL_OUTPUT2 = 8;
|
2013-05-19 22:31:03 +00:00
|
|
|
const int PSP_AUDIO_CHANNEL_VAUDIO = 8;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-05-19 19:31:47 +00:00
|
|
|
struct AudioChannelWaitInfo
|
|
|
|
{
|
|
|
|
SceUID threadID;
|
|
|
|
int numSamples;
|
|
|
|
};
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
struct AudioChannel
|
|
|
|
{
|
2012-12-28 08:05:54 +00:00
|
|
|
AudioChannel() {
|
2012-11-17 13:20:04 +00:00
|
|
|
clear();
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2012-12-28 08:05:54 +00:00
|
|
|
// PSP side
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2012-12-28 08:05:54 +00:00
|
|
|
bool reserved;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2012-12-28 08:05:54 +00:00
|
|
|
// last sample address
|
|
|
|
u32 sampleAddress;
|
|
|
|
u32 sampleCount; // Number of samples written in each OutputBlocking
|
2013-01-24 15:31:30 +00:00
|
|
|
u32 leftVolume;
|
|
|
|
u32 rightVolume;
|
|
|
|
u32 format;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-05-19 19:31:47 +00:00
|
|
|
std::vector<AudioChannelWaitInfo> waitingThreads;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2012-12-28 08:05:54 +00:00
|
|
|
// PC side - should probably split out
|
|
|
|
|
|
|
|
// We copy samples as they are written into this simple ring buffer.
|
|
|
|
// Might try something more efficient later.
|
2013-01-26 23:15:39 +00:00
|
|
|
FixedSizeQueue<s16, 32768 * 8> sampleQueue;
|
2012-12-28 08:05:54 +00:00
|
|
|
|
2013-02-04 04:31:46 +00:00
|
|
|
void DoState(PointerWrap &p);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-05-21 07:58:47 +00:00
|
|
|
void reset();
|
2013-05-19 19:31:47 +00:00
|
|
|
void clear();
|
2012-11-01 15:19:01 +00:00
|
|
|
};
|
|
|
|
|
2013-05-19 22:31:03 +00:00
|
|
|
// The extra channel is for SRC/Output2/Vaudio (who all share, apparently.)
|
2013-05-16 06:18:57 +00:00
|
|
|
extern AudioChannel chans[PSP_AUDIO_CHANNEL_MAX + 1];
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
void Register_sceAudio();
|