33 #include "debug_printf.h"
35 #define MODNAME "audsrv"
36 #define VERSION "0.93"
37 IRX_ID(MODNAME, 1, 4);
83 static short rendered_left [ 512 ];
84 static 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;
406 int 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);
531 #ifndef NO_RPC_THREAD
533 deinitialize_rpc_client();
571 for (i = 1; i < argc; i++)
573 if (strncmp(argv[i],
"thpri=", 6) == 0)
576 long prio = strtol(argv[i] + 6, &end, 10);
578 if (end != argv[i] + 6 && *end ==
'\0' && prio >= 9 && prio <= 123)
584 printf(
"audsrv: ignoring invalid argument '%s'\n", argv[i]);
592 printf(
"greetings from version " VERSION
" !\n");
597 DPRINTF(
"couldn't register library entries. Error %d\n", err);
598 return MODULE_NO_RESIDENT_END;
604 initialize_rpc_thread(rpc_thpri);
606 return MODULE_RESIDENT_END;