Skip to content

Commit

Permalink
Use aufmt_sample_size instead of switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsimmisch committed Nov 21, 2023
1 parent 8c626be commit eb36aa6
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions rem/aufile/aufile.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,26 +257,13 @@ size_t aufile_get_length(struct aufile *af, const struct aufile_prm *prm)
if (!af || !prm)
return 0;

switch (prm->fmt) {
case AUFMT_PCMA:
case AUFMT_PCMU:
return af->datasize * 1000 /
(prm->channels * prm->srate);
case AUFMT_S16LE:
return af->datasize * 1000 /
(prm->channels * prm->srate * 2);
case AUFMT_S24_3LE:
return af->datasize * 1000 /
(prm->channels * prm->srate * 3);
case AUFMT_S32LE:
case AUFMT_FLOAT:
return af->datasize * 1000 /
(prm->channels * prm->srate * 4);
default:
return 0;
}
int sample_size = aufmt_sample_size(prm->fmt);

return 0;
if (sample_size == 0)
return 0;

return af->datasize * 1000 / (sample_size *
prm->channels * prm->srate);
}

/**
Expand Down

0 comments on commit eb36aa6

Please sign in to comment.