pspaudio: Patched to compile.

This commit is contained in:
Ryan C. Gordon
2023-07-22 11:13:13 -04:00
parent 86ca412436
commit 4836c2db07

View File

@@ -41,8 +41,6 @@ static inline SDL_bool isBasicAudioConfig(const SDL_AudioSpec *spec)
static int PSPAUDIO_OpenDevice(SDL_AudioDevice *device) static int PSPAUDIO_OpenDevice(SDL_AudioDevice *device)
{ {
int format, mixlen, i;
device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden)); device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
if (device->hidden == NULL) { if (device->hidden == NULL) {
return SDL_OutOfMemory(); return SDL_OutOfMemory();
@@ -59,8 +57,8 @@ static int PSPAUDIO_OpenDevice(SDL_AudioDevice *device)
device->sample_frames = PSP_AUDIO_SAMPLE_ALIGN(device->sample_frames); device->sample_frames = PSP_AUDIO_SAMPLE_ALIGN(device->sample_frames);
// The number of channels (1 or 2). // The number of channels (1 or 2).
device->spec.channels = device->spec.channels == 1 ? 1 : 2; device->spec.channels = device->spec.channels == 1 ? 1 : 2;
format = (device->spec.channels == 1) ? PSP_AUDIO_FORMAT_MONO : PSP_AUDIO_FORMAT_STEREO; const int format = (device->spec.channels == 1) ? PSP_AUDIO_FORMAT_MONO : PSP_AUDIO_FORMAT_STEREO;
device->hidden->channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, device->spec.samples, format); device->hidden->channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, device->samples_frames, format);
} else { } else {
// 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11050, 8000 // 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11050, 8000
switch (device->spec.freq) { switch (device->spec.freq) {
@@ -94,14 +92,14 @@ static int PSPAUDIO_OpenDevice(SDL_AudioDevice *device)
/* Allocate the mixing buffer. Its size and starting address must /* Allocate the mixing buffer. Its size and starting address must
be a multiple of 64 bytes. Our sample count is already a multiple of be a multiple of 64 bytes. Our sample count is already a multiple of
64, so spec->size should be a multiple of 64 as well. */ 64, so spec->size should be a multiple of 64 as well. */
mixlen = device->buffer_size * NUM_BUFFERS; const int mixlen = device->buffer_size * NUM_BUFFERS;
device->hidden->rawbuf = (Uint8 *)SDL_aligned_alloc(64, mixlen); device->hidden->rawbuf = (Uint8 *)SDL_aligned_alloc(64, mixlen);
if (device->hidden->rawbuf == NULL) { if (device->hidden->rawbuf == NULL) {
return SDL_SetError("Couldn't allocate mixing buffer"); return SDL_SetError("Couldn't allocate mixing buffer");
} }
SDL_memset(device->hidden->rawbuf, device->silence_value, mixlen); SDL_memset(device->hidden->rawbuf, device->silence_value, mixlen);
for (i = 0; i < NUM_BUFFERS; i++) { for (int i = 0; i < NUM_BUFFERS; i++) {
device->hidden->mixbufs[i] = &device->hidden->rawbuf[i * device->buffer_size]; device->hidden->mixbufs[i] = &device->hidden->rawbuf[i * device->buffer_size];
} }
@@ -112,9 +110,9 @@ static void PSPAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, in
{ {
if (!isBasicAudioConfig(&device->spec)) { if (!isBasicAudioConfig(&device->spec)) {
SDL_assert(device->spec.channels == 2); SDL_assert(device->spec.channels == 2);
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, buffer); sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, (void *) buffer);
} else { } else {
sceAudioOutputPannedBlocking(device->hidden->channel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, buffer); sceAudioOutputPannedBlocking(device->hidden->channel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, (void *) buffer);
} }
} }
@@ -143,7 +141,7 @@ static void PSPAUDIO_CloseDevice(SDL_AudioDevice *device)
} }
if (device->hidden->rawbuf != NULL) { if (device->hidden->rawbuf != NULL) {
SDL_aligned_free(_this->hidden->rawbuf); SDL_aligned_free(device->hidden->rawbuf);
device->hidden->rawbuf = NULL; device->hidden->rawbuf = NULL;
} }
SDL_free(device->hidden); SDL_free(device->hidden);
@@ -155,7 +153,7 @@ static void PSPAUDIO_ThreadInit(SDL_AudioDevice *device)
{ {
/* Increase the priority of this audio thread by 1 to put it /* Increase the priority of this audio thread by 1 to put it
ahead of other SDL threads. */ ahead of other SDL threads. */
const SceUID thid = sceKernelGetThreadId() const SceUID thid = sceKernelGetThreadId();
SceKernelThreadInfo status; SceKernelThreadInfo status;
status.size = sizeof(SceKernelThreadInfo); status.size = sizeof(SceKernelThreadInfo);
if (sceKernelReferThreadStatus(thid, &status) == 0) { if (sceKernelReferThreadStatus(thid, &status) == 0) {