321 int offset, last_read;
343 nsectors =
sizeof(cd_ringbuf) / SECTOR_SIZE;
344 printf(
"filling buffer with nsectors %d..\n", nsectors);
347 printf(
"failed to read %d sectors..\n", nsectors);
353 printf(
"sectors read.. now setting callbacks\n");
357 sceSdBlockTrans(SD_CORE_0, SD_TRANS_LOOP, core0_buf,
sizeof(core0_buf), 0);
359 printf(
"callbacks kicked, starting loop\n");
362 memset(cd_rendered_left, 0,
sizeof(cd_rendered_left));
363 memset(cd_rendered_right, 0,
sizeof(cd_rendered_right));
376 block = 1 - (sceSdBlockTransStatus(SD_CORE_0, 0) >> 24);
377 bufptr = core0_buf + (block << 11);
381 up.left = (
short *)cd_rendered_left;
382 up.right = (
short *)cd_rendered_right;
384 if ((
unsigned int)(offset + 1880) <
sizeof(cd_ringbuf))
387 up.src = cd_ringbuf + offset;
388 offset = offset + up44k1(&up);
393 sz =
sizeof(cd_ringbuf) - offset;
394 wmemcpy(cd_sparebuf, cd_ringbuf + offset, sz);
395 wmemcpy(cd_sparebuf + sz, cd_ringbuf + 0, 1880 - sz);
397 up.src = cd_sparebuf;
402 wmemcpy(bufptr + 0, cd_rendered_left + 0, 512);
403 wmemcpy(bufptr + 512, cd_rendered_right + 0, 512);
404 wmemcpy(bufptr + 1024, cd_rendered_left + 256, 512);
405 wmemcpy(bufptr + 1536, cd_rendered_right + 256, 512);
410 memset(bufptr,
'\0', 2048);
415 if ((offset / SECTOR_SIZE) != last_read)
420 printf(
"failed to read 1 sector\n");
424 last_read = (offset / SECTOR_SIZE);
432 call_client_callback(AUDSRV_CDDA_CALLBACK);
514 printf(
"request to play track %d\n", track);
516 if (initialize_cdda() < 0)
518 DPRINTF(
"initialized cdda failed\n");
519 return AUDSRV_ERR_NOT_INITIALIZED;
522 if (track < 1 || track >
toc.num_tracks)
525 return AUDSRV_ERR_ARGS;
529 if (track == 1 && (type == 11 || type == 0x13))
532 DPRINTF(
"request to play data track\n");
533 return AUDSRV_ERR_ARGS;
539 if (start < 0 || end < 0 || end < start)
541 DPRINTF(
"invalid track offsets %d, %d\n", start, end);
542 return AUDSRV_ERR_ARGS;
548 sceSdSetParam(SD_CORE_0 | SD_PARAM_BVOLL, 0x7fff);
549 sceSdSetParam(SD_CORE_0 | SD_PARAM_BVOLR, 0x7fff);
552 sceSdSetParam(SD_CORE_0 | SD_PARAM_MVOLL,
MAX_VOLUME);
553 sceSdSetParam(SD_CORE_0 | SD_PARAM_MVOLR,
MAX_VOLUME);