MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _aduio_replay_stop

Function _aduio_replay_stop

components/drivers/audio/dev_audio.c:190–216  ·  view source on GitHub ↗

* @brief Stop replaying audio * * When audio->replay->queue is empty and the audio->replay->event was set REPLAY_EVT_STOP, * _audio_send_replay_frame will send completion to stop replaying audio. * * @param[in] audio pointer to audio device * * @return error code, RT_EOK is successful otherwise means failure */

Source from the content-addressed store, hash-verified

188 * @return error code, RT_EOK is successful otherwise means failure
189 */
190static rt_err_t _aduio_replay_stop(struct rt_audio_device *audio)
191{
192 rt_err_t result = RT_EOK;
193
194 if (audio->replay->activated == RT_TRUE)
195 {
196 /* flush replay remian frames */
197 _audio_flush_replay_frame(audio);
198
199 /* notify irq(or thread) to stop the data transmission */
200 audio->replay->event |= REPLAY_EVT_STOP;
201
202 /* waiting for the remaining data transfer to complete */
203 rt_completion_init(&audio->replay->cmp);
204 rt_completion_wait(&audio->replay->cmp, RT_WAITING_FOREVER);
205 audio->replay->event &= ~REPLAY_EVT_STOP;
206
207 /* stop playback hardware device */
208 if (audio->ops->stop)
209 result = audio->ops->stop(audio, AUDIO_STREAM_REPLAY);
210
211 audio->replay->activated = RT_FALSE;
212 LOG_D("stop audio replay device");
213 }
214
215 return result;
216}
217
218/**
219 * @brief Open audio pipe and start to record audio

Callers 2

_audio_dev_closeFunction · 0.85
_audio_dev_controlFunction · 0.85

Calls 3

rt_completion_waitFunction · 0.85
rt_completion_initFunction · 0.50

Tested by

no test coverage detected