This commit is contained in:
twinaphex 2020-12-20 16:41:44 +01:00
parent f4c4df039d
commit 51f0d04569
4 changed files with 137 additions and 173 deletions

View File

@ -39,36 +39,41 @@ typedef struct
volatile bool quit_thread;
} ps3_audio_t;
#ifdef __PSL1GHT__
static void event_loop(void *data)
#else
static void event_loop(uint64_t data)
#endif
{
float out_tmp[CELL_AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS]
float out_tmp[AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS]
__attribute__((aligned(16)));
sys_event_queue_t id;
sys_ipc_key_t key;
sys_event_t event;
ps3_audio_t *aud = (ps3_audio_t*)(uintptr_t)data;
cellAudioCreateNotifyEventQueue(&id, &key);
cellAudioSetNotifyEventQueue(key);
audioCreateNotifyEventQueue(&id, &key);
audioSetNotifyEventQueue(key);
while (!aud->quit_thread)
{
sys_event_queue_receive(id, &event, SYS_NO_TIMEOUT);
sysEventQueueReceive(id, &event, PS3_SYS_NO_TIMEOUT);
sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT);
sysLwMutexLock(&aud->lock, PS3_SYS_NO_TIMEOUT);
if (FIFO_READ_AVAIL(aud->buffer) >= sizeof(out_tmp))
fifo_read(aud->buffer, out_tmp, sizeof(out_tmp));
else
memset(out_tmp, 0, sizeof(out_tmp));
sys_lwmutex_unlock(&aud->lock);
sys_lwcond_signal(&aud->cond);
sysLwMutexUnlock(&aud->lock);
sysLwCondSignal(&aud->cond);
cellAudioAddData(aud->audio_port, out_tmp,
CELL_AUDIO_BLOCK_SAMPLES, 1.0);
audioAddData(aud->audio_port, out_tmp,
AUDIO_BLOCK_SAMPLES, 1.0);
}
cellAudioRemoveNotifyEventQueue(key);
sys_ppu_thread_exit(0);
audioRemoveNotifyEventQueue(key);
sysThreadExit(0);
}
static void *ps3_audio_init(const char *device,
@ -76,53 +81,63 @@ static void *ps3_audio_init(const char *device,
unsigned block_frames,
unsigned *new_rate)
{
CellAudioPortParam params;
ps3_audio_t *data = calloc(1, sizeof(*data));
audioPortParam params;
ps3_audio_t *data = NULL;
#ifdef __PSL1GHT__
sys_lwmutex_attr_t lock_attr =
{SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"};
sys_lwmutex_attr_t cond_lock_attr =
{SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"};
sys_lwcond_attr_t cond_attr = {"\0"};
#else
sys_lwmutex_attr_t lock_attr;
sys_lwmutex_attr_t cond_lock_attr;
sys_lwcond_attr_t cond_attr;
sys_lwmutex_attribute_initialize(lock_attr);
sys_lwmutex_attribute_initialize(cond_lock_attr);
sys_lwcond_attribute_initialize(cond_attr);
#endif
data = calloc(1, sizeof(*data));
if (!data)
return NULL;
(void)latency;
(void)device;
(void)rate;
audioInit();
cellAudioInit();
params.numChannels = AUDIO_CHANNELS;
params.numBlocks = AUDIO_BLOCKS;
params.numChannels = AUDIO_CHANNELS;
params.numBlocks = AUDIO_BLOCKS;
params.param_attrib = 0;
#if 0
#ifdef HAVE_HEADSET
if(global->console.sound.mode == SOUND_MODE_HEADSET)
params.param_attrib = CELL_AUDIO_PORTATTR_OUT_SECONDARY;
else
params.param_attrib = CELL_AUDIO_PORTATTR_OUT_SECONDARY;
#endif
#endif
params.param_attrib = 0;
if (cellAudioPortOpen(&params, &data->audio_port) != CELL_OK)
if (audioPortOpen(&params, &data->audio_port) != CELL_OK)
{
cellAudioQuit();
audioQuit();
free(data);
return NULL;
}
data->buffer = fifo_new(CELL_AUDIO_BLOCK_SAMPLES *
data->buffer = fifo_new(AUDIO_BLOCK_SAMPLES *
AUDIO_CHANNELS * AUDIO_BLOCKS * sizeof(float));
sys_lwmutex_attr_t lock_attr =
{SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"};
sys_lwmutex_attr_t cond_lock_attr =
{SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"};
sys_lwcond_attribute_t cond_attr = {"\0"};
sysLwMutexCreate(&data->lock, &lock_attr);
sysLwMutexCreate(&data->cond_lock, &cond_lock_attr);
sysLwCondCreate(&data->cond, &data->cond_lock, &cond_attr);
sys_lwmutex_create(&data->lock, &lock_attr);
sys_lwmutex_create(&data->cond_lock, &cond_lock_attr);
sys_lwcond_create(&data->cond, &data->cond_lock, &cond_attr);
cellAudioPortStart(data->audio_port);
audioPortStart(data->audio_port);
data->started = true;
sys_ppu_thread_create(&data->thread, event_loop,
sysThreadCreate(&data->thread, event_loop,
#ifdef __PSL1GHT__
data,
1500, 0x1000, SYS_PPU_THREAD_CREATE_JOINABLE, (char*)"sound");
#else
(uint64_t)data,
#endif
1500, 0x1000, SYS_THREAD_CREATE_JOINABLE, (char*)"sound");
return data;
}
@ -138,11 +153,11 @@ static ssize_t ps3_audio_write(void *data, const void *buf, size_t size)
}
while (FIFO_WRITE_AVAIL(aud->buffer) < size)
sys_lwcond_wait(&aud->cond, 0);
sysLwCondWait(&aud->cond, 0);
sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT);
sysLwMutexLock(&aud->lock, PS3_SYS_NO_TIMEOUT);
fifo_write(aud->buffer, buf, size);
sys_lwmutex_unlock(&aud->lock);
sysLwMutexUnlock(&aud->lock);
return size;
}
@ -152,7 +167,7 @@ static bool ps3_audio_stop(void *data)
ps3_audio_t *aud = data;
if (aud->started)
{
cellAudioPortStop(aud->audio_port);
audioPortStop(aud->audio_port);
aud->started = false;
}
return true;
@ -163,7 +178,7 @@ static bool ps3_audio_start(void *data, bool is_shutdown)
ps3_audio_t *aud = data;
if (!aud->started)
{
cellAudioPortStart(aud->audio_port);
audioPortStart(aud->audio_port);
aud->started = true;
}
return true;
@ -191,29 +206,28 @@ static void ps3_audio_free(void *data)
aud->quit_thread = true;
ps3_audio_start(aud, false);
sys_ppu_thread_join(aud->thread, &val);
sysThreadJoin(aud->thread, &val);
ps3_audio_stop(aud);
cellAudioPortClose(aud->audio_port);
cellAudioQuit();
audioPortClose(aud->audio_port);
audioQuit();
fifo_free(aud->buffer);
sys_lwmutex_destroy(&aud->lock);
sys_lwmutex_destroy(&aud->cond_lock);
sys_lwcond_destroy(&aud->cond);
sysLwMutexDestroy(&aud->lock);
sysLwMutexDestroy(&aud->cond_lock);
sysLwCondDestroy(&aud->cond);
free(data);
}
static bool ps3_audio_use_float(void *data)
{
(void)data;
return true;
}
static size_t ps3_audio_write_avail(void *data)
{
(void)data;
/* TODO/FIXME - implement? */
return 0;
}

View File

@ -29,44 +29,12 @@
#include <lv2/mutex.h>
#include <lv2/cond.h>
/* define all the audio/audio port functions */
#define cellAudioQuit audioQuit
#define cellAudioInit audioInit
#define cellAudioPortStart audioPortStart
#define cellAudioPortOpen audioPortOpen
#define cellAudioPortClose audioPortClose
#define cellAudioPortStop audioPortStop
#define CellAudioPortParam audioPortParam
#define cellAudioPortOpen audioPortOpen
#define cellAudioAddData audioAddData
/*forward decl. for audioAddData */
extern int audioAddData(uint32_t portNum, float *data,
uint32_t frames, float volume);
/* define all the event queue functions */
#define sys_event_queue_receive sysEventQueueReceive
#define cellAudioSetNotifyEventQueue audioSetNotifyEventQueue
#define cellAudioRemoveNotifyEventQueue audioRemoveNotifyEventQueue
#define cellAudioCreateNotifyEventQueue audioCreateNotifyEventQueue
/* define all the lightweight mutex functions */
#define sys_lwmutex_destroy sysLwMutexDestroy
#define sys_lwmutex_lock sysLwMutexLock
#define sys_lwmutex_unlock sysLwMutexUnlock
#define sys_lwmutex_create sysLwMutexCreate
//forward decl. for audioAddData
extern int audioAddData(uint32_t portNum, float *data, uint32_t frames, float volume);
/* define all the lightweight condition functions */
#define sys_lwcond_create sysLwCondCreate
#define sys_lwcond_destroy sysLwCondDestroy
#define sys_lwcond_wait sysLwCondWait
#define sys_lwcond_signal sysLwCondSignal
#define CELL_AUDIO_BLOCK_SAMPLES AUDIO_BLOCK_SAMPLES
#define SYS_NO_TIMEOUT 0
#define PS3_SYS_NO_TIMEOUT 0
#define param_attrib attrib
#define sys_lwmutex_attribute_t sys_lwmutex_attr_t
#define sys_lwcond_attribute_t sys_lwcond_attr_t
#define sys_semaphore_t sys_sem_t
#else
#include <sdk_version.h>
@ -78,6 +46,40 @@ extern int audioAddData(uint32_t portNum, float *data, uint32_t frames, float vo
#define numBlocks nBlock
#define param_attrib attr
#define audioQuit cellAudioQuit
#define audioInit cellAudioInit
#define audioPortStart cellAudioPortStart
#define audioPortOpen cellAudioPortOpen
#define audioPortClose cellAudioPortClose
#define audioPortStop cellAudioPortStop
#define audioPortParam CellAudioPortParam
#define audioPortOpen cellAudioPortOpen
#define audioAddData cellAudioAddData
/* event queue functions */
#define sysEventQueueReceive sys_event_queue_receive
#define audioSetNotifyEventQueue cellAudioSetNotifyEventQueue
#define audioRemoveNotifyEventQueue cellAudioRemoveNotifyEventQueue
#define audioCreateNotifyEventQueue cellAudioCreateNotifyEventQueue
#define sysLwCondCreate sys_lwcond_create
#define sysLwCondDestroy sys_lwcond_destroy
#define sysLwCondWait sys_lwcond_wait
#define sysLwCondSignal sys_lwcond_signal
#define sysLwMutexDestroy sys_lwmutex_destroy
#define sysLwMutexLock sys_lwmutex_lock
#define sysLwMutexUnlock sys_lwmutex_unlock
#define sysLwMutexCreate sys_lwmutex_create
#define AUDIO_BLOCK_SAMPLES CELL_AUDIO_BLOCK_SAMPLES
#define PS3_SYS_NO_TIMEOUT SYS_NO_TIMEOUT
#define sys_lwmutex_attr_t sys_lwmutex_attribute_t
#define sys_lwcond_attr_t sys_lwcond_attribute_t
#define sys_sem_t sys_semaphore_t
#endif
/*============================================================
@ -86,19 +88,18 @@ extern int audioAddData(uint32_t portNum, float *data, uint32_t frames, float vo
#ifdef __PSL1GHT__
#include <io/pad.h>
/* define all the ps3 pad structs */
#define CellPadInfo2 padInfo2
#define CellPadData padData
/* define all the ps3 pad functions */
#define cellPadGetInfo2 ioPadGetInfo2
#define cellPadGetData ioPadGetData
#define cellPadInit ioPadInit
#define cellPadEnd ioPadEnd
#define now_connect connected
#else
#include <cell/pad.h>
#define padInfo2 CellPadInfo2
#define padData CellPadData
#define ioPadGetInfo2 cellPadGetInfo2
#define ioPadGetData cellPadGetData
#define ioPadInit cellPadInit
#define ioPadEnd cellPadEnd
#endif
/*============================================================
@ -209,29 +210,6 @@ extern int audioAddData(uint32_t portNum, float *data, uint32_t frames, float vo
============================================================ */
#ifdef __PSL1GHT__
/* define all of the JPEG/PNG structs */
#define CellJpgDecMainHandle int
#define CellPngDecMainHandle int
#define CellJpgDecSubHandle int
#define CellPngDecSubHandle int
#define CellJpgDecThreadInParam jpgDecThreadInParam
#define CellPngDecThreadInParam pngDecThreadInParam
#define CellJpgDecThreadOutParam jpgDecThreadOutParam
#define CellPngDecThreadOutParam pngDecThreadOutParam
#define CellJpgDecSrc jpgDecSource
#define CellPngDecSrc pngDecSource
#define CellJpgDecOpnInfo uint32_t
#define CellPngDecOpnInfo uint32_t
#define CellJpgDecInfo jpgDecInfo
#define CellPngDecInfo pngDecInfo
#define CellJpgDecInParam jpgDecInParam
#define CellPngDecInParam pngDecInParam
#define CellJpgDecOutParam jpgDecOutParam
#define CellPngDecOutParam pngDecOutParam
#define CellJpgDecDataOutInfo jpgDecDataInfo
#define CellPngDecDataOutInfo pngDecDataInfo
#define CellJpgDecDataCtrlParam uint64_t
#define CellPngDecDataCtrlParam uint64_t
#define spu_enable enable
#define stream_select stream
@ -242,38 +220,6 @@ extern int audioAddData(uint32_t portNum, float *data, uint32_t frames, float vo
#define output_width width
#define output_height height
/* define all of the JPEG/PNG functions */
#define cellJpgDecCreate jpgDecCreate
#define cellJpgDecOpen jpgDecOpen
#define cellJpgDecReadHeader jpgDecReadHeader
#define cellJpgDecSetParameter jpgDecSetParameter
#define cellJpgDecDecodeData jpgDecDecodeData
#define cellJpgDecClose jpgDecClose
#define cellJpgDecDestroy jpgDecDestroy
#define cellPngDecCreate pngDecCreate
#define cellPngDecOpen pngDecOpen
#define cellPngDecReadHeader pngDecReadHeader
#define cellPngDecSetParameter pngDecSetParameter
#define cellPngDecDecodeData pngDecDecodeData
#define cellPngDecClose pngDecClose
#define cellPngDecDestroy pngDecDestroy
/* define all of the JPEG/PNG defines */
#define CELL_PNGDEC_SPU_THREAD_ENABLE 1
#define CELL_JPGDEC_SPU_THREAD_ENABLE 1
#define CELL_JPGDEC_FILE JPGDEC_FILE
#define CELL_PNGDEC_FILE PNGDEC_FILE
#define CELL_JPGDEC_SPU_THREAD_ENABLE 1
#define CELL_JPGDEC_FAST JPGDEC_LOW_QUALITY
#define CELL_JPGDEC_TOP_TO_BOTTOM JPGDEC_TOP_TO_BOTTOM
#define CELL_PNGDEC_TOP_TO_BOTTOM PNGDEC_TOP_TO_BOTTOM
#define CELL_JPG_ARGB JPGDEC_ARGB
#define CELL_PNGDEC_ARGB PNGDEC_ARGB
#define CELL_JPGDEC_DEC_STATUS_FINISH 0
#define CELL_PNGDEC_DEC_STATUS_FINISH 0
#define CELL_PNGDEC_1BYTE_PER_1PIXEL 1
#define CELL_PNGDEC_STREAM_ALPHA 1
#define CELL_OK 0
#define PTR_NULL 0
@ -324,26 +270,30 @@ extern int audioAddData(uint32_t portNum, float *data, uint32_t frames, float vo
#ifdef __PSL1GHT__
#include <sys/thread.h>
/* define all the thread functions */
#define sys_ppu_thread_create sysThreadCreate
#define sys_ppu_thread_join sysThreadJoin
#define sys_ppu_thread_exit sysThreadExit
/* FIXME - not sure if this is correct */
#define SYS_THREAD_CREATE_JOINABLE 0
#define sys_process_exit sysProcessExit
#define sys_game_process_exitspawn sysProcessExitSpawn2
#else
#define SYS_PROCESS_PRIMARY_STACK_SIZE_1M SYS_PROCESS_SPAWN_STACK_SIZE_1M
#define SYS_PROCESS_SPAWN_STACK_SIZE_1M SYS_PROCESS_PRIMARY_STACK_SIZE_1M
#define SYS_THREAD_CREATE_JOINABLE SYS_PPU_THREAD_CREATE_JOINABLE
#define sysThreadCreate sys_ppu_thread_create
#define sysThreadJoin sys_ppu_thread_join
#define sysThreadExit sys_ppu_thread_exit
#define sysProcessExit sys_process_exit
#define sysProcessExitSpawn2 sys_game_process_exitspawn
#define SYS_PPU_THREAD_CREATE_JOINABLE 0 /* FIXME - not sure if this is correct */
#endif
/*============================================================
MEMORY PROTOTYPES
============================================================ */
#ifdef __PSL1GHT__
#define sys_memory_container_create sysMemContainerCreate
#define sys_memory_container_destroy sysMemContainerDestroy
#ifndef __PSL1GHT__
#define sysMemContainerCreate sys_memory_container_create
#define sysMemContainerDestroy sys_memory_container_destroy
#endif
/*============================================================

View File

@ -78,7 +78,7 @@ static enum frontend_fork ps3_fork_mode = FRONTEND_FORK_NONE;
static void frontend_ps3_shutdown(bool unused)
{
sys_process_exit(0);
sysProcessExit(0);
}
#endif
@ -467,7 +467,7 @@ static int frontend_ps3_exec_exitspawn(const char *path,
#ifndef __PSL1GHT__
ret = sceNpDrmProcessExitSpawn(license_data, path,
(const char** const)argv, envp, (sys_addr_t)spawn_data,
256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
256, 1000, SYS_PROCESS_SPAWN_STACK_SIZE_1M);
#else
ret = -1;
#endif
@ -475,8 +475,8 @@ static int frontend_ps3_exec_exitspawn(const char *path,
if (ret < 0)
{
RARCH_WARN("SELF file is not of NPDRM type, trying another approach to boot it...\n");
sys_game_process_exitspawn(path, (const char** const)argv,
envp, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
sysProcessExitSpawn2(path, (const char** const)argv,
envp, NULL, 0, 1000, SYS_PROCESS_SPAWN_STACK_SIZE_1M);
}
return ret;

View File

@ -55,7 +55,7 @@ static void ps3_joypad_autodetect_add(unsigned autoconf_pad)
static void *ps3_joypad_init(void *data)
{
cellPadInit(DEFAULT_MAX_PADS);
ioPadInit(DEFAULT_MAX_PADS);
return (void*)-1;
}
@ -159,13 +159,13 @@ static int16_t ps3_joypad_state(
static void ps3_joypad_poll(void)
{
unsigned port;
CellPadInfo2 pad_info;
padInfo2 pad_info;
cellPadGetInfo2(&pad_info);
ioPadGetInfo2(&pad_info);
for (port = 0; port < DEFAULT_MAX_PADS; port++)
{
CellPadData state_tmp;
padData state_tmp;
if (pad_info.port_status[port] & CELL_PAD_STATUS_ASSIGN_CHANGES)
{
@ -184,7 +184,7 @@ static void ps3_joypad_poll(void)
if (pads_connected[port] == 0)
continue;
cellPadGetData(port, &state_tmp);
ioPadGetData(port, &state_tmp);
if (state_tmp.len != 0)
{
@ -276,7 +276,7 @@ static bool ps3_joypad_rumble(unsigned pad,
static void ps3_joypad_destroy(void)
{
cellPadEnd();
ioPadEnd();
}
input_device_driver_t ps3_joypad = {