* @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 */
| 188 | * @return error code, RT_EOK is successful otherwise means failure |
| 189 | */ |
| 190 | static 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 |
no test coverage detected