Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return an error when out of SPU memory #405

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions iop/sound/audsrv/src/adpcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,34 @@ void *audsrv_load_adpcm(u32 *buffer, int size, int id)
adpcm = adpcm_loaded(id);
if (adpcm == NULL)
{
if (adpcm_list_head == NULL)
int spu2_addr = 0x5010; /* Need to change this so it considers to PCM streaming space usage :) */
if (adpcm_list_tail != NULL)
{
/* first entry ever! yay! */
adpcm = alloc_new_sample();
adpcm->id = id;
adpcm->spu2_addr = 0x5010; /* Need to change this so it considers to PCM streaming space usage :) */
adpcm->size = size - 16; /* header is 16 bytes */
adpcm->next = NULL;
spu2_addr = adpcm_list_tail->spu2_addr + adpcm_list_tail->size;
}
if (spu2_addr + size - 16 > 2097152)
{
sbuffer[0] = -AUDSRV_ERR_OUT_OF_MEMORY;
return sbuffer;
}

adpcm = alloc_new_sample();
adpcm->id = id;
adpcm->spu2_addr = spu2_addr;
adpcm->size = size - 16; /* header is 16 bytes */
adpcm->next = NULL;

audsrv_read_adpcm_header(adpcm, buffer);
audsrv_read_adpcm_header(adpcm, buffer);

if (adpcm_list_head == NULL)
{
/* first entry ever! yay! */
adpcm_list_head = adpcm;
adpcm_list_tail = adpcm_list_head;
}
else
{
/* add at the end of the list */
adpcm = alloc_new_sample();
adpcm->id = id;
adpcm->spu2_addr = adpcm_list_tail->spu2_addr + adpcm_list_tail->size;
adpcm->size = size - 16; /* header is 16 bytes */
adpcm->next = NULL;

audsrv_read_adpcm_header(adpcm, buffer);

adpcm_list_tail->next = adpcm;
adpcm_list_tail = adpcm;
}
Expand Down