void pvr2_stream_kill(struct pvr2_stream *sp) { struct pvr2_buffer *bp; mutex_lock(&sp->mutex); do { pvr2_stream_internal_flush(sp); while ((bp = pvr2_stream_get_ready_buffer(sp)) != 0) { pvr2_buffer_set_idle(bp); } if (sp->buffer_total_count != sp->buffer_target_count) { pvr2_stream_achieve_buffer_count(sp); } } while(0); mutex_unlock(&sp->mutex); }
static void pvr2_stream_internal_flush(struct pvr2_stream *sp) { struct list_head *lp; struct pvr2_buffer *bp1; while ((lp = sp->queued_list.next) != &sp->queued_list) { bp1 = list_entry(lp,struct pvr2_buffer,list_overhead); pvr2_buffer_wipe(bp1); /* At this point, we should be guaranteed that no completion callback may happen on this buffer. But it's possible that it might have completed after we noticed it but before we wiped it. So double check its status here first. */ if (bp1->state != pvr2_buffer_state_queued) continue; pvr2_buffer_set_idle(bp1); } if (sp->buffer_total_count != sp->buffer_target_count) { pvr2_stream_achieve_buffer_count(sp); } }