You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/09/05 05:33:21 UTC
[nuttx] 08/11: esp32s3/i2s: Add interface to stop the I2S streams
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit f1b459347b7553614e87a340f7ea594deebbe4d1
Author: Tiago Medicci Serrano <ti...@espressif.com>
AuthorDate: Wed Aug 30 10:49:22 2023 -0300
esp32s3/i2s: Add interface to stop the I2S streams
In order to gracefully stop the I2S stream, add an interface to set
a `streaming` status variable that sets the `AUDIO_APB_FINAL` flag
that will be handled by the upper layers of the audio subsystem.
---
arch/xtensa/src/esp32s3/esp32s3_i2s.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/arch/xtensa/src/esp32s3/esp32s3_i2s.c b/arch/xtensa/src/esp32s3/esp32s3_i2s.c
index 94ed92acdb..2a9e681a45 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_i2s.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_i2s.c
@@ -315,6 +315,8 @@ struct esp32s3_i2s_s
bool rx_started; /* RX channel started */
#endif /* I2S_HAVE_RX */
+ bool streaming; /* Is I2S peripheral active? */
+
/* Pre-allocated pool of buffer containers */
sem_t bufsem; /* Buffer wait semaphore */
@@ -1303,7 +1305,10 @@ static void i2s_rx_worker(void *arg)
DEBUGASSERT(bfcontainer && bfcontainer->callback);
- /* Release the internal buffer used by the DMA inlink */
+ if (priv->streaming == false)
+ {
+ bfcontainer->apb->flags |= AUDIO_APB_FINAL;
+ }
bfcontainer->callback(&priv->dev, bfcontainer->apb,
bfcontainer->arg, bfcontainer->result);
@@ -2902,9 +2907,28 @@ static int i2s_ioctl(struct i2s_dev_s *dev, int cmd, unsigned long arg)
{
i2sinfo("AUDIOIOC_START\n");
+ priv->streaming = true;
+
+ ret = OK;
+ }
+ break;
+
+ /* AUDIOIOC_STOP - Stop the audio stream.
+ *
+ * ioctl argument: Audio session
+ */
+
+#ifndef CONFIG_AUDIO_EXCLUDE_STOP
+ case AUDIOIOC_STOP:
+ {
+ i2sinfo("AUDIOIOC_STOP\n");
+
+ priv->streaming = false;
+
ret = OK;
}
break;
+#endif /* CONFIG_AUDIO_EXCLUDE_STOP */
/* AUDIOIOC_ALLOCBUFFER - Allocate an audio buffer
*