This commit is contained in:
刘可亮
2025-01-08 19:12:06 +08:00
parent 3b8c04c942
commit 724d6bf65e
4315 changed files with 214394 additions and 1235797 deletions

View File

@@ -148,16 +148,18 @@ static rt_err_t _aduio_replay_stop(struct rt_audio_device *audio)
if (audio->replay->activated == RT_TRUE)
{
/* flush replay remian frames */
_audio_flush_replay_frame(audio);
if (!audio->replay->transfer_mode) {
/* flush replay remian frames */
_audio_flush_replay_frame(audio);
/* notify irq(or thread) to stop the data transmission */
audio->replay->event |= REPLAY_EVT_STOP;
/* notify irq(or thread) to stop the data transmission */
audio->replay->event |= REPLAY_EVT_STOP;
/* waiting for the remaining data transfer to complete */
rt_completion_init(&audio->replay->cmp);
rt_completion_wait(&audio->replay->cmp, RT_WAITING_FOREVER);
audio->replay->event &= ~REPLAY_EVT_STOP;
/* waiting for the remaining data transfer to complete */
rt_completion_init(&audio->replay->cmp);
rt_completion_wait(&audio->replay->cmp, RT_WAITING_FOREVER);
audio->replay->event &= ~REPLAY_EVT_STOP;
}
/* stop playback hardware device */
if (audio->ops->stop)
@@ -314,6 +316,7 @@ static rt_err_t _audio_dev_open(struct rt_device *dev, rt_uint16_t oflag)
audio->replay->read_index = 0;
audio->replay->pos = 0;
audio->replay->event = REPLAY_EVT_NONE;
audio->replay->transfer_mode = 0;
}
dev->open_flag |= RT_DEVICE_OFLAG_WRONLY;
}
@@ -514,6 +517,14 @@ static rt_err_t _audio_dev_control(struct rt_device *dev, int cmd, void *args)
break;
}
case AUDIO_CTL_DIRECT_TRANSFER:
{
if (audio->ops->direct_transfer)
audio->ops->direct_transfer(audio);
break;
}
default:
break;
}