diff options
author | Ivan Orlov <ivan.orlov0322@gmail.com> | 2023-07-13 11:59:53 +0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2023-07-14 08:07:45 +0200 |
commit | f9d1b819307c242f2e648f16a05c0f908c525616 (patch) | |
tree | 36047e2638f31f7cbebe7820c774e6be1981df37 | |
parent | 678a0bbe158076805843f6a58aa09b365fc43871 (diff) |
ALSA: pcmtest: minor optimizations
Decrease the buffer filling overhead with conditional remainder
calculation in the 'inc_buf_pos' inline function.
Fix the driver to use already defined variables where it is possible
in 'check_buf_block_ni' and 'fill_block_pattern_n' functions.
Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com>
Link: https://lore.kernel.org/r/20230713075953.13692-2-ivan.orlov0322@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/drivers/pcmtest.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sound/drivers/pcmtest.c b/sound/drivers/pcmtest.c index e74c523e49eb..08e14b5eb772 100644 --- a/sound/drivers/pcmtest.c +++ b/sound/drivers/pcmtest.c @@ -144,7 +144,8 @@ static inline void inc_buf_pos(struct pcmtst_buf_iter *v_iter, size_t by, size_t { v_iter->total_bytes += by; v_iter->buf_pos += by; - v_iter->buf_pos %= bytes; + if (v_iter->buf_pos >= bytes) + v_iter->buf_pos %= bytes; } /* @@ -200,10 +201,10 @@ static void check_buf_block_ni(struct pcmtst_buf_iter *v_iter, struct snd_pcm_ru u8 current_byte; for (i = 0; i < v_iter->b_rw; i++) { - current_byte = runtime->dma_area[buf_pos_n(v_iter, channels, i % channels)]; + ch_num = i % channels; + current_byte = runtime->dma_area[buf_pos_n(v_iter, channels, ch_num)]; if (!current_byte) break; - ch_num = i % channels; if (current_byte != patt_bufs[ch_num].buf[(v_iter->total_bytes / channels) % patt_bufs[ch_num].len]) { v_iter->is_buf_corrupted = true; @@ -243,7 +244,7 @@ static void fill_block_pattern_n(struct pcmtst_buf_iter *v_iter, struct snd_pcm_ for (i = 0; i < v_iter->b_rw; i++) { ch_num = i % channels; - runtime->dma_area[buf_pos_n(v_iter, channels, i % channels)] = + runtime->dma_area[buf_pos_n(v_iter, channels, ch_num)] = patt_bufs[ch_num].buf[(v_iter->total_bytes / channels) % patt_bufs[ch_num].len]; inc_buf_pos(v_iter, 1, runtime->dma_bytes); |