Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7aa6d776 authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Dhananjay Kumar
Browse files

ASoC: compr: timestamp fix for non-gapless mode



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: default avatarHaynes Mathew George <hgeorge@codeaurora.org>
Signed-off-by: default avatarDhananjay Kumar <dhakumar@codeaurora.org>
parent 15e3d7d4
Loading
Loading
Loading
Loading
+29 −15
Original line number Original line Diff line number Diff line
@@ -129,6 +129,8 @@ struct msm_compr_audio {
	uint32_t stream_available;
	uint32_t stream_available;
	uint32_t next_stream;
	uint32_t next_stream;


	uint64_t marker_timestamp;

	struct msm_compr_gapless_state gapless_state;
	struct msm_compr_gapless_state gapless_state;


	atomic_t start;
	atomic_t start;
@@ -1232,6 +1234,7 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
		prtd->app_pointer  = 0;
		prtd->app_pointer  = 0;
		prtd->bytes_received = 0;
		prtd->bytes_received = 0;
		prtd->bytes_sent = 0;
		prtd->bytes_sent = 0;
		prtd->marker_timestamp = 0;


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

			/*
			/*
			Don't reset these as these vars map to
			Don't reset these as these vars map to
			total_bytes_transferred and total_bytes_available
			total_bytes_transferred and total_bytes_available
@@ -1421,22 +1426,22 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
			q6asm_stream_cmd_nowait(ac, CMD_PAUSE, ac->stream_id);
			q6asm_stream_cmd_nowait(ac, CMD_PAUSE, ac->stream_id);
			prtd->cmd_ack = 0;
			prtd->cmd_ack = 0;
			spin_unlock_irqrestore(&prtd->lock, flags);
			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);
			spin_lock_irqsave(&prtd->lock, flags);
			/*
			/*
			Don't reset these as these vars map to
			 * Don't reset these as these vars map to
			total_bytes_transferred and total_bytes_available
			 * total_bytes_transferred and total_bytes_available.
			directly, only total_bytes_transferred will be updated
			 * Just total_bytes_transferred will be updated
			in the next avail() ioctl
			 * in the next avail() ioctl.
			prtd->copied_total = 0;
			 * prtd->copied_total = 0;
			prtd->bytes_received = 0;
			 * prtd->bytes_received = 0;
			do not reset prtd->bytes_sent as well as the same
			 * do not reset prtd->bytes_sent as well as the same
			session is used for gapless playback
			 * session is used for gapless playback
			 */
			 */
			prtd->byte_offset = 0;
			prtd->byte_offset = 0;


@@ -1445,8 +1450,15 @@ static int msm_compr_trigger(struct snd_compr_stream *cstream, int cmd)
			prtd->last_buffer = 0;
			prtd->last_buffer = 0;
			atomic_set(&prtd->drain, 0);
			atomic_set(&prtd->drain, 0);
			atomic_set(&prtd->xrun, 1);
			atomic_set(&prtd->xrun, 1);
			q6asm_run_nowait(prtd->audio_client, 0, 0, 0);
			spin_unlock_irqrestore(&prtd->lock, flags);
			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;
		prtd->cmd_interrupt = 0;
		break;
		break;
@@ -1575,6 +1587,8 @@ static int msm_compr_pointer(struct snd_compr_stream *cstream,
				__func__, timestamp);
				__func__, timestamp);
			return -EAGAIN;
			return -EAGAIN;
		}
		}
	} else {
		timestamp = prtd->marker_timestamp;
	}
	}


	/* DSP returns timestamp in usec */
	/* DSP returns timestamp in usec */