summaryrefslogtreecommitdiff
path: root/nuttx/drivers/audio/audio_null.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-07-31 16:36:09 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-07-31 16:36:09 -0600
commit753c87342ecb63da03961944f13bd80d897a45d8 (patch)
treee22d11b966d50315aae625bd499c049a83d15309 /nuttx/drivers/audio/audio_null.c
parent46d2d7391d973f805d633c1a112ad37cc4ec1f78 (diff)
downloadnuttx-753c87342ecb63da03961944f13bd80d897a45d8.tar.gz
nuttx-753c87342ecb63da03961944f13bd80d897a45d8.tar.bz2
nuttx-753c87342ecb63da03961944f13bd80d897a45d8.zip
Audio: Change how the end of the audio stream is detected by the leaf audio component. This used by be done by looking for the first partial buffer. That does not work with the in-place sub-sampling performed by the PCM decoder: That always reduces the size of the buffer so that all buffers only partially filled by the time they get to the leaf. Now, a flag is set in the audio buffer flags set to indicate the final buffer in the stream.
Diffstat (limited to 'nuttx/drivers/audio/audio_null.c')
-rw-r--r--nuttx/drivers/audio/audio_null.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/nuttx/drivers/audio/audio_null.c b/nuttx/drivers/audio/audio_null.c
index e753f5171..4ebb0042f 100644
--- a/nuttx/drivers/audio/audio_null.c
+++ b/nuttx/drivers/audio/audio_null.c
@@ -650,6 +650,7 @@ static int null_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
FAR struct ap_buffer_s *apb)
{
FAR struct null_dev_s *priv = (FAR struct null_dev_s *)dev;
+ bool final;
audvdbg("apb=%p curbyte=%d nbytes=%d\n", apb, apb->curbyte, apb->nbytes);
@@ -657,6 +658,10 @@ static int null_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
apb->curbyte = apb->nbytes;
+ /* Check if this was the last buffer in the stream */
+
+ done = ((apb->flags & AUDIO_APB_FINAL) != 0);
+
/* And return the buffer to the upper level */
DEBUGASSERT(priv && apb && priv->dev.upper);
@@ -671,6 +676,17 @@ static int null_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_DEQUEUE, apb, OK);
#endif
+ /* Say we are done playing if this was the last buffer in the stream */
+
+ if (done)
+ {
+#ifdef CONFIG_AUDIO_MULTI_SESSION
+ priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_COMPLETE, NULL, OK, NULL);
+#else
+ priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_COMPLETE, NULL, OK);
+#endif
+ }
+
audvdbg("Return OK\n");
return OK;
}