Skip to content

Commit

Permalink
ASoC: compr: timestamp fix for non-gapless mode
Browse files Browse the repository at this point in the history
Cache last known playback timestamp before resetting the
in use session in preparation for possible re-use of the
same session.

Change-Id: Id422f5654960818c159f9f07d5af3c497192bae2
Signed-off-by: Haynes Mathew George <hgeorge@codeaurora.org>
Signed-off-by: Dhananjay Kumar <dhakumar@codeaurora.org>
  • Loading branch information
Haynes Mathew George authored and hurtsky committed Nov 28, 2015
1 parent 9d82259 commit d78ced3
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions sound/soc/msm/qdsp6v2/msm-compress-q6-v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ struct msm_compr_audio {
uint32_t stream_available;
uint32_t next_stream;

uint64_t marker_timestamp;

struct msm_compr_gapless_state gapless_state;

atomic_t start;
Expand Down Expand Up @@ -1010,6 +1012,7 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
prtd->app_pointer = 0;
prtd->bytes_received = 0;
prtd->bytes_sent = 0;
prtd->marker_timestamp = 0;

atomic_set(&prtd->xrun, 0);
spin_unlock_irqrestore(&prtd->lock, flags);
Expand Down Expand Up @@ -1142,6 +1145,8 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
prtd->first_buffer = 1;
prtd->last_buffer = 0;
prtd->gapless_state.gapless_transition = 1;
prtd->marker_timestamp = 0;

/*
Don't reset these as these vars map to
total_bytes_transferred and total_bytes_available
Expand Down Expand Up @@ -1197,32 +1202,39 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
q6asm_stream_cmd_nowait(ac, CMD_PAUSE, ac->stream_id);
prtd->cmd_ack = 0;
spin_unlock_irqrestore(&prtd->lock, flags);
pr_debug("%s:issue CMD_FLUSH ac->stream_id %d",
__func__, ac->stream_id);
q6asm_stream_cmd(ac, CMD_FLUSH, ac->stream_id);
wait_event_timeout(prtd->flush_wait,
prtd->cmd_ack, 1 * HZ / 4);

/*
* Cache this time as last known time
*/
q6asm_get_session_time(prtd->audio_client,
&prtd->marker_timestamp);
spin_lock_irqsave(&prtd->lock, flags);
/*
Don't reset these as these vars map to
total_bytes_transferred and total_bytes_available
directly, only total_bytes_transferred will be updated
in the next avail() ioctl
prtd->copied_total = 0;
prtd->bytes_received = 0;
do not reset prtd->bytes_sent as well as the same
session is used for gapless playback
*/
* Don't reset these as these vars map to
* total_bytes_transferred and total_bytes_available.
* Just total_bytes_transferred will be updated
* in the next avail() ioctl.
* prtd->copied_total = 0;
* prtd->bytes_received = 0;
* do not reset prtd->bytes_sent as well as the same
* session is used for gapless playback
*/
prtd->byte_offset = 0;

prtd->app_pointer = 0;
prtd->first_buffer = 1;
prtd->last_buffer = 0;
atomic_set(&prtd->drain, 0);
atomic_set(&prtd->xrun, 1);
q6asm_run_nowait(prtd->audio_client, 0, 0, 0);
spin_unlock_irqrestore(&prtd->lock, flags);

pr_debug("%s:issue CMD_FLUSH ac->stream_id %d",
__func__, ac->stream_id);
q6asm_stream_cmd(ac, CMD_FLUSH, ac->stream_id);
wait_event_timeout(prtd->flush_wait,
prtd->cmd_ack, 1 * HZ / 4);

q6asm_run_nowait(prtd->audio_client, 0, 0, 0);
}
prtd->cmd_interrupt = 0;
break;
Expand Down Expand Up @@ -1350,6 +1362,8 @@ static int msm_compr_pointer(struct snd_compr_stream *cstream,
__func__, timestamp);
return -EAGAIN;
}
} else {
timestamp = prtd->marker_timestamp;
}

/* DSP returns timestamp in usec */
Expand Down

0 comments on commit d78ced3

Please sign in to comment.