33#include "debug_printf.h"
35#define MODNAME "audsrv"
83static short rendered_left [ 512 ];
84static short rendered_right[ 512 ];
113 sceSdSetParam(SD_CORE_1 | SD_PARAM_AVOLL, 0x7fff);
114 sceSdSetParam(SD_CORE_1 | SD_PARAM_AVOLR, 0x7fff);
117 sceSdSetParam(SD_CORE_0 | SD_PARAM_BVOLL, 0);
118 sceSdSetParam(SD_CORE_0 | SD_PARAM_BVOLR, 0);
122 sceSdSetParam(SD_CORE_1 | SD_PARAM_BVOLL, vol);
123 sceSdSetParam(SD_CORE_1 | SD_PARAM_BVOLR, vol);
126 sceSdSetParam(SD_CORE_0 | SD_PARAM_MVOLL, 0);
127 sceSdSetParam(SD_CORE_0 | SD_PARAM_MVOLR, 0);
130 sceSdSetParam(SD_CORE_1 | SD_PARAM_MVOLL,
MAX_VOLUME);
131 sceSdSetParam(SD_CORE_1 | SD_PARAM_MVOLR,
MAX_VOLUME);
184 return -AUDSRV_ERR_FORMAT_NOT_SUPPORTED;
208 readpos = (feed_size * 5) & ~3;
227 if (sceSdInit(SD_INIT_COLD) < 0)
229 DPRINTF(
"failed to initialize libsd\n");
240 return AUDSRV_ERR_OUT_OF_MEMORY;
247 return AUDSRV_ERR_OUT_OF_MEMORY;
257 sceSdBlockTrans(AUDSRV_BLOCK_DMA_CH, SD_TRANS_LOOP, core1_buf,
sizeof(core1_buf), 0);
263 DPRINTF(
"playing thread 0x%x started\n",
play_tid);
265 DPRINTF(
"kickstarted\n");
319 return AUDSRV_ERR_ARGS;
350 return -AUDSRV_ERR_NOT_INITIALIZED;
375 buflen = buflen - copy;
398 return AUDSRV_ERR_ARGS;
406int audsrv_set_threshold(
int amount)
411 return AUDSRV_ERR_ARGS;
414 DPRINTF(
"callback threshold: %d\n", amount);
434 upsampler_t upsampler = NULL;
438 DPRINTF(
"starting play thread\n");
451 if (
playing && upsampler != NULL)
454 up.left = rendered_left;
455 up.right = rendered_right;
456 step = upsampler(&up);
468 memset(rendered_left,
'\0',
sizeof(rendered_left));
469 memset(rendered_right,
'\0',
sizeof(rendered_right));
479 block = 1 - (sceSdBlockTransStatus(AUDSRV_BLOCK_DMA_CH, 0) >> 24);
482 bufptr = core1_buf + (block << 11);
483 wmemcpy(bufptr + 0, rendered_left + 0, 512);
484 wmemcpy(bufptr + 512, rendered_right + 0, 512);
485 wmemcpy(bufptr + 1024, rendered_left + 256, 512);
486 wmemcpy(bufptr + 1536, rendered_right + 256, 512);
502 call_client_callback(AUDSRV_FILLBUF_CALLBACK);
520 sceSdSetTransCallback(AUDSRV_BLOCK_DMA_CH, NULL);
521 sceSdBlockTrans(AUDSRV_BLOCK_DMA_CH, SD_TRANS_STOP, 0, 0, 0);
533 deinitialize_rpc_client();
566 printf(
"greetings from version " VERSION
" !\n");
571 DPRINTF(
"couldn't register library entries. Error %d\n", err);
572 return MODULE_NO_RESIDENT_END;
578 initialize_rpc_thread();
580 return MODULE_RESIDENT_END;
int audsrv_set_volume(int vol)
int audsrv_wait_audio(int buflen)
static int core1_channels
static int fillbuf_threshold
static char ringbuf[20480]
static int core1_sample_shift
int _start(int argc, char *argv[])
static int transfer_complete(void *arg)
int audsrv_set_format(int freq, int bits, int channels)
int audsrv_format_ok(int freq, int bits, int channels)
static void update_volume()
static int format_changed
struct irx_export_table _exp_audsrv
int audsrv_play_audio(const char *buf, int buflen)
static void play_thread(void *arg)
#define AUDSRV_ERR_NOERROR
int CpuResumeIntr(int state)
int CpuSuspendIntr(int *state)
int create_thread(void *func, int priority, void *param)
upsampler_t find_upsampler(int freq, int bits, int channels)