summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandeep Shinde <sashinde@nvidia.com>2010-05-06 11:24:26 +0530
committerGary King <gking@nvidia.com>2010-05-07 16:42:36 -0700
commite305d3434e6015c6b9276cfdbc6a736736edcf01 (patch)
tree520d8dc3b368f873b6bf365eec069e57f2b37178
parent17369eee42bba5c1aaaf3a2e9dc79ea55d543e5d (diff)
tegra ALSA: Replacing completion object with wait_queue_head_t
Following are the changes done: - Removed completion object appl_ptr_comp used for waiting for app buffers when buffer_in_quque=0. - If a completion object wakes-up after every 120 seconds if not signalled during that time. - Now using wait_queue_head_t which suits the purpose better. - Removed play_thread running dependency on shutdown_thrd as it is no more required. - Removed label EXIT from play_thread All these changes were done based on comments from Google. Refer to below issues for the complete discussion. http://codereview.chromium.org/1705013/show Change-Id: Id902a73f704ddf38ec8b9071bc36ee0f6db89f30 Reviewed-on: http://git-master/r/1305 Reviewed-by: Manjula Gupta <magupta@nvidia.com> Tested-by: Manjula Gupta <magupta@nvidia.com> Reviewed-by: Gary King <gking@nvidia.com>
-rw-r--r--sound/soc/tegra/tegra_pcm_rpc.c26
-rw-r--r--sound/soc/tegra/tegra_transport.h3
2 files changed, 10 insertions, 19 deletions
diff --git a/sound/soc/tegra/tegra_pcm_rpc.c b/sound/soc/tegra/tegra_pcm_rpc.c
index 0b799730f795..69b74d17b681 100644
--- a/sound/soc/tegra/tegra_pcm_rpc.c
+++ b/sound/soc/tegra/tegra_pcm_rpc.c
@@ -78,7 +78,7 @@ static int play_thread( void *arg)
rtbuffersize = frames_to_bytes(runtime, runtime->buffer_size);
buffer_to_prime = (rtbuffersize / TEGRA_DEFAULT_BUFFER_SIZE);
- while (!prtd->shutdown_thrd) {
+ for(;;) {
switch (prtd->state) {
case SNDRV_PCM_TRIGGER_START:
state = NvAudioFxState_Run;
@@ -134,16 +134,15 @@ static int play_thread( void *arg)
}
if (buffer_in_queue == 0) {
- prtd->play_thread_waiting = true;
- wait_for_completion(&prtd->appl_ptr_comp);
- prtd->play_thread_waiting = false;
- init_completion(&prtd->appl_ptr_comp);
+ DEFINE_WAIT(wq);
+ prepare_to_wait(&prtd->buf_wait, &wq, TASK_INTERRUPTIBLE);
+ schedule();
+ finish_wait(&prtd->buf_wait, &wq);
continue;
}
if ((buffer_to_prime == buffer_in_queue) ||
- (prtd->audiofx_frames >=
- runtime->control->appl_ptr)) {
+ (prtd->audiofx_frames >= runtime->control->appl_ptr)) {
down(&prtd->buf_done_sem);
buffer_in_queue--;
@@ -177,12 +176,10 @@ static int play_thread( void *arg)
}
}
}
-EXIT:
while (buffer_in_queue > 0) {
down(&prtd->buf_done_sem);
buffer_in_queue--;
}
-
return 0;
}
@@ -474,8 +471,7 @@ static int pcm_common_close(struct snd_pcm_substream *substream)
if (completion_done(&prtd->thread_comp) == 0)
complete(&prtd->thread_comp);
- if (completion_done(&prtd->appl_ptr_comp) == 0)
- complete(&prtd->appl_ptr_comp);
+ wake_up_all(&prtd->buf_wait);
if (prtd->play_thread)
kthread_stop(prtd->play_thread);
@@ -548,8 +544,7 @@ static int tegra_pcm_open(struct snd_pcm_substream *substream)
goto fail;
init_completion(&prtd->thread_comp);
- init_completion(&prtd->appl_ptr_comp);
- prtd->play_thread_waiting = false;
+ init_waitqueue_head(&prtd->buf_wait);
sema_init(&prtd->buf_done_sem, 0);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
@@ -691,10 +686,7 @@ static int tegra_pcm_ack(struct snd_pcm_substream *substream)
{
struct pcm_runtime_data *prtd = substream->runtime->private_data;
- if (prtd->play_thread_waiting) {
- complete(&prtd->appl_ptr_comp);
- }
-
+ wake_up(&prtd->buf_wait);
return 0;
}
diff --git a/sound/soc/tegra/tegra_transport.h b/sound/soc/tegra/tegra_transport.h
index 74ff22004ce8..0093fef6383b 100644
--- a/sound/soc/tegra/tegra_transport.h
+++ b/sound/soc/tegra/tegra_transport.h
@@ -391,10 +391,9 @@ struct pcm_runtime_data {
int state;
int stream;
int shutdown_thrd;
- bool play_thread_waiting;
unsigned int audiofx_frames;
struct completion thread_comp;
- struct completion appl_ptr_comp;
+ wait_queue_head_t buf_wait;
struct semaphore buf_done_sem;
StandardPath* stdoutpath;
StandardPath* stdinpath;