Skip to content

Commit 6b94226

Browse files
authored
Merge pull request #35 from zhigang-wu/topic/capture-resume-failure
capture pause/release failure when play/capture work at same time
2 parents c2feab8 + 3f1cab0 commit 6b94226

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/audio/dai.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,17 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd)
559559
platform_dai_wallclock(dev, &dd->wallclock);
560560
break;
561561
case COMP_TRIGGER_RELEASE:
562+
/* before release, we clear the buffer data to 0s,
563+
* then there is no history data sent out after release.
564+
* this is only supported at capture mode.
565+
*/
566+
if (dev->params.direction == SOF_IPC_STREAM_CAPTURE) {
567+
struct comp_buffer *dma_buffer =
568+
list_first_item(&dev->bsink_list,
569+
struct comp_buffer, source_list);
570+
buffer_zero(dma_buffer);
571+
}
572+
562573
/* only start the DAI if we are not XRUN handling */
563574
if (dd->xrun == 0) {
564575
/* recover the dma status */

src/audio/pipeline.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ static void pipeline_trigger_sched_comp(struct pipeline *p,
206206
pipeline_schedule_cancel(p);
207207
break;
208208
case COMP_TRIGGER_START:
209-
case COMP_TRIGGER_RELEASE:
210209
p->xrun_bytes = 0;
211210

212211
/* playback pipelines need scheduled now, capture pipelines are
@@ -223,6 +222,22 @@ static void pipeline_trigger_sched_comp(struct pipeline *p,
223222
}
224223
}
225224
break;
225+
case COMP_TRIGGER_RELEASE:
226+
p->xrun_bytes = 0;
227+
228+
/* in resume process, capture must be
229+
* scheduled to to avoid the xrun in DAI component
230+
*/
231+
if (p->ipc_pipe.timer) {
232+
/* timer - schedule initial copy */
233+
pipeline_schedule_copy(p, 0);
234+
} else {
235+
/* DAI - schedule initial
236+
* pipeline fill when next idle
237+
*/
238+
pipeline_schedule_copy_idle(p);
239+
}
240+
break;
226241
case COMP_TRIGGER_SUSPEND:
227242
case COMP_TRIGGER_RESUME:
228243
case COMP_TRIGGER_XRUN:

src/include/sof/audio/buffer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,11 @@ static inline int buffer_set_size(struct comp_buffer *buffer, uint32_t size)
139139
return 0;
140140
}
141141

142+
static inline void buffer_zero(struct comp_buffer *buffer)
143+
{
144+
tracev_buffer("BZr");
145+
146+
bzero(buffer->addr, buffer->size);
147+
}
148+
142149
#endif

0 commit comments

Comments
 (0)