ALSA: emu10k1: fix wavetable offset recalculation
authorOswald Buddenhagen <oswald.buddenhagen@gmx.de>
Sat, 6 Apr 2024 06:48:25 +0000 (08:48 +0200)
committerTakashi Iwai <tiwai@suse.de>
Sun, 7 Apr 2024 06:35:50 +0000 (08:35 +0200)
The offsets are counted in samples, not in bytes.

While the code block is being rewritten, also move it up a bit, to avoid
churn in a subsequent patch.

Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Message-ID: <20240406064830.1029573-13-oswald.buddenhagen@gmx.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/emu10k1/emu10k1_patch.c

index 281881f7d0a44dcf5fcbdcae0bfd0e8dafe5c62c..ad16de99b8001c671f5f47d3af1ca63e3b0fe906 100644 (file)
@@ -30,7 +30,6 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
        u32 xor;
        int offset;
        int truesize, size, blocksize;
-       unsigned int start_addr;
        struct snd_emu10k1 *emu;
 
        emu = rec->hw;
@@ -62,6 +61,12 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
                }
        }
 
+       /* recalculate offset */
+       sp->v.start += BLANK_HEAD_SIZE;
+       sp->v.end += BLANK_HEAD_SIZE;
+       sp->v.loopstart += BLANK_HEAD_SIZE;
+       sp->v.loopend += BLANK_HEAD_SIZE;
+
        /* try to allocate a memory block */
        blocksize = truesize;
        if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
@@ -99,15 +104,6 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
        if (offset < blocksize)
                snd_emu10k1_synth_memset(emu, sp->block, offset, blocksize - offset, fill);
 
-       /* recalculate offset */
-       start_addr = BLANK_HEAD_SIZE * 2;
-       if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
-               start_addr >>= 1;
-       sp->v.start += start_addr;
-       sp->v.end += start_addr;
-       sp->v.loopstart += start_addr;
-       sp->v.loopend += start_addr;
-
        return 0;
 }