Skip to content

Commit

Permalink
ALSA: sb: remove needless evaluation in implementation for copy callback
Browse files Browse the repository at this point in the history
In design of ALSA pcm core, 'struct snd_pcm_ops.copy' is expected to
copy PCM frames, according to frame alignment on intermediate buffer for
userspace and dedicated buffer for data transmission. In this callback,
value of 'channel' argument depends on the frame alignment, which drivers
registers to runtime of PCM substream. When target devices can handle
non-interleaved buffer, this value has positive value, otherwise negative.

ALSA driver for PCM component of EMU8000 chip is programmed with local
macro to switch the frame alignment. The 'copy' operation in
non-interleaved side has evaluation of the 'channel' argument (actually
it's 'voice' argument). This is useless.

This commit remove the evaluation.

[tiwai: the negative channel argument was the inheritance from the old
 code where -1 was meant for interleaved mode.  The mix-up was dropped
 meanwhile, thus it's correct to assume that we receive no longer -1
 there, and it's safe to cleanup the relevant code.

 Also, voice=0 for channel==1 is trivial, and it can be dropped, too.]

Signed-off-by: Takashi Sakamoto <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
takaswie authored and tiwai committed May 24, 2017
1 parent 097a7fe commit 6dbaf8b
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions sound/isa/sb/emu8000_pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,20 +450,8 @@ static int emu8k_pcm_copy(struct snd_pcm_substream *subs,
struct snd_emu8000 *emu = rec->emu;

snd_emu8000_write_wait(emu, 1);
if (voice == -1) {
unsigned short *buf = src;
int i, err;
count /= rec->voices;
for (i = 0; i < rec->voices; i++) {
err = emu8k_transfer_block(emu, pos + rec->loop_start[i], buf, count);
if (err < 0)
return err;
buf += count;
}
return 0;
} else {
return emu8k_transfer_block(emu, pos + rec->loop_start[voice], src, count);
}
return emu8k_transfer_block(emu, pos + rec->loop_start[voice], src,
count);
}

/* make a channel block silence */
Expand All @@ -487,17 +475,7 @@ static int emu8k_pcm_silence(struct snd_pcm_substream *subs,
struct snd_emu8000 *emu = rec->emu;

snd_emu8000_write_wait(emu, 1);
if (voice == -1 && rec->voices == 1)
voice = 0;
if (voice == -1) {
int err;
err = emu8k_silence_block(emu, pos + rec->loop_start[0], count / 2);
if (err < 0)
return err;
return emu8k_silence_block(emu, pos + rec->loop_start[1], count / 2);
} else {
return emu8k_silence_block(emu, pos + rec->loop_start[voice], count);
}
return emu8k_silence_block(emu, pos + rec->loop_start[voice], count);
}

#else /* interleave */
Expand Down

0 comments on commit 6dbaf8b

Please sign in to comment.