dsdfile: support DSD128/256/512 as well

We need to scale the number of samples to read from the file depending
on the bitrate.

Fixes #2508
This commit is contained in:
Wim Taymans 2022-07-06 09:27:38 +02:00
parent 76350cebef
commit a4f6598f47

View file

@ -216,13 +216,15 @@ dsf_file_read(struct dsf_file *f, void *data, size_t samples, const struct dsf_l
uint8_t *d = data; uint8_t *d = data;
int step = SPA_ABS(layout->interleave); int step = SPA_ABS(layout->interleave);
bool rev = layout->lsb != f->info.lsb; bool rev = layout->lsb != f->info.lsb;
size_t total, block, offset, pos; size_t total, block, offset, pos, scale;
block = f->offset / f->info.blocksize; block = f->offset / f->info.blocksize;
offset = block * f->info.blocksize * f->info.channels; offset = block * f->info.blocksize * f->info.channels;
pos = f->offset % f->info.blocksize; pos = f->offset % f->info.blocksize;
scale = SPA_CLAMP(f->info.rate / (44100u * 64u), 1u, 4u);
samples *= step; samples *= step;
samples *= scale;
for (total = 0; total < samples && offset + pos < f->info.length; total++) { for (total = 0; total < samples && offset + pos < f->info.length; total++) {
const uint8_t *s = f->p + offset + pos; const uint8_t *s = f->p + offset + pos;