mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 16:44:01 +00:00
(Vita) Attempt to reuse PSP1 audio driver for Vita
This commit is contained in:
parent
b892f8252b
commit
273788cdf9
@ -117,8 +117,8 @@ static const audio_driver_t *audio_drivers[] = {
|
|||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
&audio_rwebaudio,
|
&audio_rwebaudio,
|
||||||
#endif
|
#endif
|
||||||
#ifdef PSP
|
#if defined(PSP) || defined(VITA)
|
||||||
&audio_psp1,
|
&audio_psp,
|
||||||
#endif
|
#endif
|
||||||
#ifdef _3DS
|
#ifdef _3DS
|
||||||
&audio_ctr,
|
&audio_ctr,
|
||||||
|
@ -88,7 +88,7 @@ extern audio_driver_t audio_coreaudio;
|
|||||||
extern audio_driver_t audio_xenon360;
|
extern audio_driver_t audio_xenon360;
|
||||||
extern audio_driver_t audio_ps3;
|
extern audio_driver_t audio_ps3;
|
||||||
extern audio_driver_t audio_gx;
|
extern audio_driver_t audio_gx;
|
||||||
extern audio_driver_t audio_psp1;
|
extern audio_driver_t audio_psp;
|
||||||
extern audio_driver_t audio_ctr;
|
extern audio_driver_t audio_ctr;
|
||||||
extern audio_driver_t audio_rwebaudio;
|
extern audio_driver_t audio_rwebaudio;
|
||||||
extern audio_driver_t audio_null;
|
extern audio_driver_t audio_null;
|
||||||
|
@ -18,11 +18,18 @@
|
|||||||
#include "../../general.h"
|
#include "../../general.h"
|
||||||
#include "../../driver.h"
|
#include "../../driver.h"
|
||||||
|
|
||||||
|
#ifdef VITA
|
||||||
|
#include <psp2/kernel/processmgr.h>
|
||||||
|
#include <psp2/kernel/threadmgr.h>
|
||||||
|
#include <psp2/kernel/sysmem.h>
|
||||||
|
#include <psp2/audioout.h>
|
||||||
|
#else
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspaudio.h>
|
#include <pspaudio.h>
|
||||||
|
#endif
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct psp1_audio
|
typedef struct psp_audio
|
||||||
{
|
{
|
||||||
bool nonblocking;
|
bool nonblocking;
|
||||||
uint32_t* buffer;
|
uint32_t* buffer;
|
||||||
@ -33,7 +40,7 @@ typedef struct psp1_audio
|
|||||||
volatile bool running;
|
volatile bool running;
|
||||||
volatile uint16_t readPos;
|
volatile uint16_t readPos;
|
||||||
volatile uint16_t writePos;
|
volatile uint16_t writePos;
|
||||||
} psp1_audio_t;
|
} psp_audio_t;
|
||||||
|
|
||||||
#define AUDIO_OUT_COUNT 512u
|
#define AUDIO_OUT_COUNT 512u
|
||||||
#define AUDIO_BUFFER_SIZE (1u<<13u)
|
#define AUDIO_BUFFER_SIZE (1u<<13u)
|
||||||
@ -41,9 +48,13 @@ typedef struct psp1_audio
|
|||||||
|
|
||||||
static int audioMainLoop(SceSize args, void* argp)
|
static int audioMainLoop(SceSize args, void* argp)
|
||||||
{
|
{
|
||||||
psp1_audio_t* psp = *((psp1_audio_t**)argp);
|
psp_audio_t* psp = *((psp_audio_t**)argp);
|
||||||
|
|
||||||
|
#ifdef VITA
|
||||||
|
sceAudioOutOpenPort(0, AUDIO_OUT_COUNT, psp->rate, 2);
|
||||||
|
#else
|
||||||
sceAudioSRCChReserve(AUDIO_OUT_COUNT, psp->rate, 2);
|
sceAudioSRCChReserve(AUDIO_OUT_COUNT, psp->rate, 2);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (psp->running)
|
while (psp->running)
|
||||||
{
|
{
|
||||||
@ -52,8 +63,13 @@ static int audioMainLoop(SceSize args, void* argp)
|
|||||||
bool cond = ((uint16_t)(psp->writePos - readPos) & AUDIO_BUFFER_SIZE_MASK)
|
bool cond = ((uint16_t)(psp->writePos - readPos) & AUDIO_BUFFER_SIZE_MASK)
|
||||||
< (AUDIO_OUT_COUNT * 2);
|
< (AUDIO_OUT_COUNT * 2);
|
||||||
|
|
||||||
|
#ifdef VITA
|
||||||
|
sceAudioOutOutput(0,
|
||||||
|
cond ? psp->zeroBuffer : (psp->buffer + readPos));
|
||||||
|
#else
|
||||||
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer)
|
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer)
|
||||||
: (psp->buffer + readPos));
|
: (psp->buffer + readPos));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!cond)
|
if (!cond)
|
||||||
{
|
{
|
||||||
@ -63,7 +79,9 @@ static int audioMainLoop(SceSize args, void* argp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef VITA
|
||||||
sceAudioSRCChRelease();
|
sceAudioSRCChRelease();
|
||||||
|
#endif
|
||||||
sceKernelExitThread(0);
|
sceKernelExitThread(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -71,7 +89,7 @@ static int audioMainLoop(SceSize args, void* argp)
|
|||||||
static void *psp_audio_init(const char *device,
|
static void *psp_audio_init(const char *device,
|
||||||
unsigned rate, unsigned latency)
|
unsigned rate, unsigned latency)
|
||||||
{
|
{
|
||||||
psp1_audio_t *psp = (psp1_audio_t*)calloc(1, sizeof(psp1_audio_t));
|
psp_audio_t *psp = (psp_audio_t*)calloc(1, sizeof(psp_audio_t));
|
||||||
|
|
||||||
if (!psp)
|
if (!psp)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -96,7 +114,7 @@ static void *psp_audio_init(const char *device,
|
|||||||
psp->nonblocking = false;
|
psp->nonblocking = false;
|
||||||
|
|
||||||
psp->running = true;
|
psp->running = true;
|
||||||
sceKernelStartThread(psp->thread, sizeof(psp1_audio_t*), &psp);
|
sceKernelStartThread(psp->thread, sizeof(psp_audio_t*), &psp);
|
||||||
|
|
||||||
return psp;
|
return psp;
|
||||||
}
|
}
|
||||||
@ -104,7 +122,7 @@ static void *psp_audio_init(const char *device,
|
|||||||
static void psp_audio_free(void *data)
|
static void psp_audio_free(void *data)
|
||||||
{
|
{
|
||||||
SceUInt timeout = 100000;
|
SceUInt timeout = 100000;
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp_audio_t* psp = (psp_audio_t*)data;
|
||||||
if(!psp)
|
if(!psp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -121,7 +139,7 @@ static void psp_audio_free(void *data)
|
|||||||
static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
|
static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
|
||||||
{
|
{
|
||||||
uint16_t sampleCount;
|
uint16_t sampleCount;
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp_audio_t* psp = (psp_audio_t*)data;
|
||||||
uint16_t writePos = psp->writePos;
|
uint16_t writePos = psp->writePos;
|
||||||
|
|
||||||
sampleCount= size / sizeof(uint32_t);
|
sampleCount= size / sizeof(uint32_t);
|
||||||
@ -153,7 +171,7 @@ static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
|
|||||||
|
|
||||||
static bool psp_audio_alive(void *data)
|
static bool psp_audio_alive(void *data)
|
||||||
{
|
{
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp_audio_t* psp = (psp_audio_t*)data;
|
||||||
if (!psp)
|
if (!psp)
|
||||||
return false;
|
return false;
|
||||||
return psp->running;
|
return psp->running;
|
||||||
@ -163,7 +181,7 @@ static bool psp_audio_stop(void *data)
|
|||||||
{
|
{
|
||||||
SceKernelThreadRunStatus runStatus;
|
SceKernelThreadRunStatus runStatus;
|
||||||
SceUInt timeout = 100000;
|
SceUInt timeout = 100000;
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp_audio_t* psp = (psp_audio_t*)data;
|
||||||
|
|
||||||
runStatus.size = sizeof(SceKernelThreadRunStatus);
|
runStatus.size = sizeof(SceKernelThreadRunStatus);
|
||||||
|
|
||||||
@ -182,7 +200,7 @@ static bool psp_audio_stop(void *data)
|
|||||||
static bool psp_audio_start(void *data)
|
static bool psp_audio_start(void *data)
|
||||||
{
|
{
|
||||||
SceKernelThreadRunStatus runStatus;
|
SceKernelThreadRunStatus runStatus;
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp_audio_t* psp = (psp_audio_t*)data;
|
||||||
|
|
||||||
runStatus.size = sizeof(SceKernelThreadRunStatus);
|
runStatus.size = sizeof(SceKernelThreadRunStatus);
|
||||||
|
|
||||||
@ -194,14 +212,14 @@ static bool psp_audio_start(void *data)
|
|||||||
|
|
||||||
psp->running = true;
|
psp->running = true;
|
||||||
|
|
||||||
sceKernelStartThread(psp->thread, sizeof(psp1_audio_t*), &psp);
|
sceKernelStartThread(psp->thread, sizeof(psp_audio_t*), &psp);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void psp_audio_set_nonblock_state(void *data, bool toggle)
|
static void psp_audio_set_nonblock_state(void *data, bool toggle)
|
||||||
{
|
{
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp_audio_t* psp = (psp_audio_t*)data;
|
||||||
if (psp)
|
if (psp)
|
||||||
psp->nonblocking = toggle;
|
psp->nonblocking = toggle;
|
||||||
}
|
}
|
||||||
@ -215,7 +233,7 @@ static bool psp_audio_use_float(void *data)
|
|||||||
static size_t psp_write_avail(void *data)
|
static size_t psp_write_avail(void *data)
|
||||||
{
|
{
|
||||||
/* TODO */
|
/* TODO */
|
||||||
psp1_audio_t* psp = (psp1_audio_t*)data;
|
psp_audio_t* psp = (psp_audio_t*)data;
|
||||||
return AUDIO_BUFFER_SIZE - ((uint16_t)
|
return AUDIO_BUFFER_SIZE - ((uint16_t)
|
||||||
(psp->writePos - psp->readPos) & AUDIO_BUFFER_SIZE_MASK);
|
(psp->writePos - psp->readPos) & AUDIO_BUFFER_SIZE_MASK);
|
||||||
}
|
}
|
||||||
@ -227,7 +245,7 @@ static size_t psp_buffer_size(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
audio_driver_t audio_psp1 = {
|
audio_driver_t audio_psp = {
|
||||||
psp_audio_init,
|
psp_audio_init,
|
||||||
psp_audio_write,
|
psp_audio_write,
|
||||||
psp_audio_stop,
|
psp_audio_stop,
|
||||||
@ -236,7 +254,7 @@ audio_driver_t audio_psp1 = {
|
|||||||
psp_audio_set_nonblock_state,
|
psp_audio_set_nonblock_state,
|
||||||
psp_audio_free,
|
psp_audio_free,
|
||||||
psp_audio_use_float,
|
psp_audio_use_float,
|
||||||
"psp1",
|
"psp",
|
||||||
psp_write_avail,
|
psp_write_avail,
|
||||||
psp_buffer_size,
|
psp_buffer_size,
|
||||||
};
|
};
|
@ -66,7 +66,7 @@ enum
|
|||||||
AUDIO_XENON360,
|
AUDIO_XENON360,
|
||||||
AUDIO_WII,
|
AUDIO_WII,
|
||||||
AUDIO_RWEBAUDIO,
|
AUDIO_RWEBAUDIO,
|
||||||
AUDIO_PSP1,
|
AUDIO_PSP,
|
||||||
AUDIO_CTR,
|
AUDIO_CTR,
|
||||||
AUDIO_NULL,
|
AUDIO_NULL,
|
||||||
|
|
||||||
@ -167,8 +167,8 @@ enum
|
|||||||
#define AUDIO_DEFAULT_DRIVER AUDIO_XENON360
|
#define AUDIO_DEFAULT_DRIVER AUDIO_XENON360
|
||||||
#elif defined(GEKKO)
|
#elif defined(GEKKO)
|
||||||
#define AUDIO_DEFAULT_DRIVER AUDIO_WII
|
#define AUDIO_DEFAULT_DRIVER AUDIO_WII
|
||||||
#elif defined(PSP)
|
#elif defined(PSP) || defined(VITA)
|
||||||
#define AUDIO_DEFAULT_DRIVER AUDIO_PSP1
|
#define AUDIO_DEFAULT_DRIVER AUDIO_PSP
|
||||||
#elif defined(_3DS)
|
#elif defined(_3DS)
|
||||||
#define AUDIO_DEFAULT_DRIVER AUDIO_CTR
|
#define AUDIO_DEFAULT_DRIVER AUDIO_CTR
|
||||||
#elif defined(HAVE_ALSA) && defined(HAVE_VIDEOCORE)
|
#elif defined(HAVE_ALSA) && defined(HAVE_VIDEOCORE)
|
||||||
|
@ -114,8 +114,8 @@ const char *config_get_default_audio(void)
|
|||||||
return "ps3";
|
return "ps3";
|
||||||
case AUDIO_WII:
|
case AUDIO_WII:
|
||||||
return "gx";
|
return "gx";
|
||||||
case AUDIO_PSP1:
|
case AUDIO_PSP:
|
||||||
return "psp1";
|
return "psp";
|
||||||
case AUDIO_CTR:
|
case AUDIO_CTR:
|
||||||
return "ctr";
|
return "ctr";
|
||||||
case AUDIO_RWEBAUDIO:
|
case AUDIO_RWEBAUDIO:
|
||||||
|
@ -472,8 +472,8 @@ AUDIO
|
|||||||
#include "../audio/drivers/gx_audio.c"
|
#include "../audio/drivers/gx_audio.c"
|
||||||
#elif defined(EMSCRIPTEN)
|
#elif defined(EMSCRIPTEN)
|
||||||
#include "../audio/drivers/rwebaudio.c"
|
#include "../audio/drivers/rwebaudio.c"
|
||||||
#elif defined(PSP)
|
#elif defined(PSP) || defined(VITA)
|
||||||
#include "../audio/drivers/psp1_audio.c"
|
#include "../audio/drivers/psp_audio.c"
|
||||||
#elif defined(_3DS)
|
#elif defined(_3DS)
|
||||||
#include "../audio/drivers/ctr_audio.c"
|
#include "../audio/drivers/ctr_audio.c"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user