pw-cat: fix DSD file reading

Now that the server asks for the right amount of samples for DSD, just
give it the right amount of samples without doing some weird scaling.

Make a method to calculate the size (stride) of one sample, which
depends on the interleave and channels of the stream.

See !2540
This commit is contained in:
Wim Taymans 2025-09-25 13:56:51 +02:00
parent f8389cbdb7
commit 19198d2982
5 changed files with 17 additions and 11 deletions

View file

@ -263,6 +263,11 @@ exit_free:
return NULL;
}
uint32_t dff_layout_stride(const struct dff_layout *layout)
{
return layout->channels * SPA_ABS(layout->interleave);
}
static const uint8_t bitrev[256] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
@ -289,14 +294,10 @@ dff_file_read(struct dff_file *f, void *data, size_t samples, const struct dff_l
int32_t step = SPA_ABS(layout->interleave);
uint32_t channels = f->info.channels;
bool rev = layout->lsb != f->info.lsb;
size_t total, offset, scale, pos;
size_t total, offset, pos;
offset = f->offset;
pos = offset % f->blocksize;
scale = SPA_CLAMP(f->info.rate / (44100u * 64u), 1u, 4u);
samples *= step;
samples *= scale;
for (total = 0; total < samples; total++) {
uint32_t i;