Skip to content

Commit

Permalink
rem/aufile: aufile_get_length use aufmt_sample_size (#1011)
Browse files Browse the repository at this point in the history
Use aufmt_sample_size instead of switch.
  • Loading branch information
larsimmisch authored Nov 22, 2023
1 parent cfe4df8 commit e097b7f
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;
}
size_t 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 e097b7f

Please sign in to comment.