ASoC: msm: Fix issue with Pause/resume
The driver is sending the next buffer everytime after coming
out of PAUSE. This shouldnt happen as the previous driver might
still be with DSP.
Fix by putting appropriate check to the pending_buffer flag.
The pending_buffer flag should also be atomic to handle
intermediate close of session.
Change-Id: Ieb102b968b6d18736bab0cf4298cc51b7ed3affe
CRs-Fixed: 326259
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
diff --git a/sound/soc/msm/msm-compr-q6.c b/sound/soc/msm/msm-compr-q6.c
index cf6f1e7..590d4af 100644
--- a/sound/soc/msm/msm-compr-q6.c
+++ b/sound/soc/msm/msm-compr-q6.c
@@ -88,10 +88,10 @@
atomic_inc(&prtd->out_count);
wake_up(&the_locks.write_wait);
if (!atomic_read(&prtd->start)) {
- prtd->pending_buffer = 1;
+ atomic_set(&prtd->pending_buffer, 1);
break;
} else
- prtd->pending_buffer = 0;
+ atomic_set(&prtd->pending_buffer, 0);
if (runtime->status->hw_ptr >= runtime->control->appl_ptr)
break;
@@ -131,8 +131,7 @@
case APR_BASIC_RSP_RESULT: {
switch (payload[0]) {
case ASM_SESSION_CMD_RUN: {
- if (!prtd->pending_buffer &&
- !atomic_read(&prtd->start))
+ if (!atomic_read(&prtd->pending_buffer))
break;
pr_debug("%s:writing %d bytes"
" of buffer[%d] to dsp\n",
@@ -156,6 +155,7 @@
prtd->out_head =
(prtd->out_head + 1)
& (runtime->periods - 1);
+ atomic_set(&prtd->pending_buffer, 0);
}
break;
case ASM_STREAM_CMD_FLUSH:
@@ -302,7 +302,7 @@
pr_info("snd_pcm_hw_constraint_integer failed\n");
prtd->dsp_cnt = 0;
- prtd->pending_buffer = 1;
+ atomic_set(&prtd->pending_buffer, 1);
compr->codec = FORMAT_MP3;
populate_codec_list(compr, runtime);
runtime->private_data = compr;
@@ -321,7 +321,7 @@
pr_debug("%s\n", __func__);
dir = IN;
-
+ atomic_set(&prtd->pending_buffer, 0);
q6asm_cmd(prtd->audio_client, CMD_CLOSE);
q6asm_audio_client_buf_free_contiguous(dir,
prtd->audio_client);