pr_debug("%s\n", __func__);
if (!as->stop) {
as->stop = true;
- wait_till_stopped(as);
+ if (pending_buffer_requests(as))
+ wait_till_stopped(as);
for (i = 0; i < as->num_bufs; i++) {
init_completion(&as->comp[i]);
complete(&as->comp[i]);
}
}
+ if (!tegra_dma_is_empty(as->dma_chan))
+ pr_err("%s: DMA not empty!\n", __func__);
+ /* Stop the DMA then dequeue anything that's in progress. */
+ tegra_dma_cancel(as->dma_chan);
as->active = false; /* applies to recording only */
pr_debug("%s: done\n", __func__);
}
pr_debug("%s\n", __func__);
if (!as->stop) {
as->stop = true;
- wait_till_stopped(as);
+ if (pending_buffer_requests(as))
+ wait_till_stopped(as);
for (i = 0; i < as->num_bufs; i++) {
init_completion(&as->comp[i]);
complete(&as->comp[i]);
}
}
+ if (!tegra_dma_is_empty(as->dma_chan))
+ pr_err("%s: DMA not empty!\n", __func__);
+ /* Stop the DMA then dequeue anything that's in progress. */
+ tegra_dma_cancel(as->dma_chan);
as->active = false; /* applies to recording only */
pr_debug("%s: done\n", __func__);
}
complete(&aos->comp[req_num]);
- if (stop_playback_if_necessary(aos)) {
- pr_debug("%s: done (stopped)\n", __func__);
- if (!completion_done(&aos->stop_completion)) {
- pr_debug("%s: signalling stop completion\n", __func__);
- complete(&aos->stop_completion);
- }
- return;
+ if (!pending_buffer_requests(aos)) {
+ pr_debug("%s: Playback underflow", __func__);
+ complete(&aos->stop_completion);
}
}
request_stop_nosync(aos);
pr_debug("%s: flushed\n", __func__);
}
+ if (stop_playback_if_necessary(aos))
+ pr_debug("%s: done (stopped)\n", __func__);
aos->stop = false;
break;
case TEGRA_AUDIO_OUT_SET_NUM_BUFS: {
if (rc < 0)
break;
aos->num_bufs = num;
+ sound_ops->setup(ads);
}
break;
case TEGRA_AUDIO_OUT_GET_NUM_BUFS:
mutex_lock(&ads->out.lock);
ads->out.opened = 0;
request_stop_nosync(&ads->out);
+ if (stop_playback_if_necessary(&ads->out))
+ pr_debug("%s: done (stopped)\n", __func__);
allow_suspend(&ads->out);
mutex_unlock(&ads->out.lock);
pr_debug("%s: done\n", __func__);