kpb: add secure reset while buffering

This patch takes care of secure reset while
KPB is in buffering state.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This commit is contained in:
Marcin Rajwa 2019-07-25 23:51:48 +02:00 committed by Janusz Jankowski
parent 60f4f9baa9
commit 39f24fbc2a
1 changed files with 17 additions and 0 deletions

View File

@ -625,11 +625,26 @@ static int kpb_buffer_data(struct comp_dev *dev, struct comp_buffer *source,
void *read_ptr = source->r_ptr;
size_t timeout = platform_timer_get(platform_timer) +
clock_ms_to_ticks(PLATFORM_DEFAULT_CLOCK, 1);
enum kpb_state state_preserved = kpb->state;
tracev_kpb("kpb_buffer_data()");
if (kpb->state != KPB_STATE_RUN && kpb->state != KPB_STATE_DRAINING)
return PPL_STATUS_PATH_STOP;
kpb->state = KPB_STATE_BUFFERING;
/* Let's store audio stream data in internal history buffer */
while (size_to_copy) {
/* Reset was requested, it's time to stop buffering and finish
* KPB reset.
*/
if (kpb->state == KPB_STATE_RESETTING) {
kpb->state = KPB_STATE_RESET_FINISHING;
kpb_reset(dev);
return PPL_STATUS_PATH_STOP;
}
/* Are we stuck in buffering? */
if (timeout < platform_timer_get(platform_timer)) {
trace_kpb_error("kpb_buffer_data(): timeout.");
@ -690,6 +705,8 @@ static int kpb_buffer_data(struct comp_dev *dev, struct comp_buffer *source,
buff->state = KPB_BUFFER_FREE;
}
}
kpb->state = state_preserved;
return ret;
}