30 #include "../SDL_audiomem.h"
31 #include "../SDL_audio_c.h"
32 #include "../SDL_audiodev_c.h"
33 #include "../SDL_sysaudio.h"
37 #include <pspthreadman.h>
40 #define PSPAUD_DRIVER_NAME "psp"
48 if (this->hidden ==
NULL) {
51 SDL_memset(this->hidden, 0,
sizeof(*this->hidden));
52 switch (this->spec.format & 0xff) {
62 this->spec.samples = PSP_AUDIO_SAMPLE_ALIGN(this->spec.samples);
63 this->spec.freq = 44100;
67 switch (this->spec.format) {
69 this->spec.silence = 0x80;
72 this->spec.silence = 0x00;
76 this->spec.size *= this->spec.channels;
77 this->spec.size *= this->spec.samples;
85 this->hidden->rawbuf = (
Uint8 *) memalign(64, mixlen);
86 if (this->hidden->rawbuf ==
NULL) {
91 if (this->spec.channels == 1) {
92 format = PSP_AUDIO_FORMAT_MONO;
94 format = PSP_AUDIO_FORMAT_STEREO;
96 this->hidden->channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, this->spec.samples, format);
97 if (this->hidden->channel < 0) {
98 free(this->hidden->rawbuf);
99 this->hidden->rawbuf =
NULL;
100 return SDL_SetError(
"Couldn't reserve hardware channel");
103 memset(this->hidden->rawbuf, 0, mixlen);
105 this->hidden->mixbufs[
i] = &this->hidden->rawbuf[i * this->spec.size];
108 this->hidden->next_buffer = 0;
114 Uint8 *
mixbuf = this->hidden->mixbufs[this->hidden->next_buffer];
116 if (this->spec.channels == 1) {
117 sceAudioOutputBlocking(this->hidden->channel, PSP_AUDIO_VOLUME_MAX, mixbuf);
119 sceAudioOutputPannedBlocking(this->hidden->channel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, mixbuf);
122 this->hidden->next_buffer = (this->hidden->next_buffer + 1) %
NUM_BUFFERS;
132 return this->hidden->mixbufs[this->hidden->next_buffer];
137 if (this->hidden->channel >= 0) {
138 sceAudioChRelease(this->hidden->channel);
139 this->hidden->channel = -1;
142 if (this->hidden->rawbuf !=
NULL) {
143 free(this->hidden->rawbuf);
144 this->hidden->rawbuf =
NULL;
152 SceKernelThreadInfo status;
153 thid = sceKernelGetThreadId();
154 status.size =
sizeof(SceKernelThreadInfo);
155 if (sceKernelReferThreadStatus(thid, &status) == 0) {
156 sceKernelChangeThreadPriority(thid, status.currentPriority - 1);
static void PSPAUD_PlayDevice(_THIS)
void(* CloseDevice)(_THIS)
AudioBootStrap PSPAUD_bootstrap
void(* WaitDevice)(_THIS)
static void PSPAUD_ThreadInit(_THIS)
Uint8 *(* GetDeviceBuf)(_THIS)
int(* OpenDevice)(_THIS, const char *devname, int iscapture)
static void PSPAUD_CloseDevice(_THIS)
static int PSPAUD_OpenDevice(_THIS, const char *devname, int iscapture)
void(* PlayDevice)(_THIS)
static int PSPAUD_Init(SDL_AudioDriverImpl *impl)
int OnlyHasDefaultOutputDevice
#define SDL_AUDIO_BITSIZE(x)
DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
static void PSPAUD_WaitDevice(_THIS)
#define SDL_OutOfMemory()
void(* ThreadInit)(_THIS)
uint8_t Uint8
An unsigned 8-bit integer type.
static Uint8 * PSPAUD_GetDeviceBuf(_THIS)