summaryrefslogtreecommitdiff
path: root/nuttx/audio
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-08-02 14:27:12 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-08-02 14:27:12 -0600
commit619aa22b7d80cdcd2ef48c9cdd5f905f68c590ba (patch)
treeb76e9f2bd166be73e37190a6ef50a679eb156850 /nuttx/audio
parent2799307735d82cc4a366b64d4906745bc2094dec (diff)
downloadnuttx-619aa22b7d80cdcd2ef48c9cdd5f905f68c590ba.tar.gz
nuttx-619aa22b7d80cdcd2ef48c9cdd5f905f68c590ba.tar.bz2
nuttx-619aa22b7d80cdcd2ef48c9cdd5f905f68c590ba.zip
PCM decoder: Correct the end of audio stream handling. It was not being detected before so that logic was not examining the WAV header in the first buffer of the next audio file
Diffstat (limited to 'nuttx/audio')
-rw-r--r--nuttx/audio/pcm_decode.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/nuttx/audio/pcm_decode.c b/nuttx/audio/pcm_decode.c
index 63477451a..1caf155d1 100644
--- a/nuttx/audio/pcm_decode.c
+++ b/nuttx/audio/pcm_decode.c
@@ -785,6 +785,10 @@ static int pcm_shutdown(FAR struct audio_lowerhalf_s *dev)
DEBUGASSERT(priv);
+ /* We are no longer streaming audio */
+
+ priv->streaming = false;
+
/* Defer the operation to the lower device driver */
lower = priv->lower;
@@ -851,6 +855,10 @@ static int pcm_stop(FAR struct audio_lowerhalf_s *dev)
DEBUGASSERT(priv);
+ /* We are no longer streaming */
+
+ priv->streaming = false;
+
/* Defer the operation to the lower device driver */
lower = priv->lower;
@@ -1026,6 +1034,14 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
if (priv->streaming)
{
/* Yes, we are streaming */
+ /* Check for the last audio buffer in the stream */
+
+ if ((apb->flags & AUDIO_APB_FINAL) != 0)
+ {
+ /* Yes.. then we are no longer streaming */
+
+ priv->streaming = false;
+ }
#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD
audvdbg("Received: apb=%p curbyte=%d nbytes=%d\n",
@@ -1062,9 +1078,15 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
{
struct audio_caps_s caps;
- /* Now we are streaming */
+ /* Now we are streaming. Unless for some reason there is only one
+ * audio buffer in the audio stream. In that case, this will be
+ * marked as the final buffer
+ */
- priv->streaming = true;
+ if ((apb->flags & AUDIO_APB_FINAL) == 0)
+ {
+ priv->streaming = true;
+ }
/* Configure the lower level for the number of channels, bitrate,
* and sample bitwidth.
@@ -1110,6 +1132,18 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
return lower->ops->enqueuebuffer(lower, apb);
}
+
+ /* Return the unhandled buffer to the previous level with an error
+ * indication.
+ */
+
+#ifdef CONFIG_AUDIO_MULTI_SESSION
+ priv->export.upper(priv->export.priv, AUDIO_CALLBACK_DEQUEUE, apb,
+ -EINVAL, NULL);
+#else
+ priv->export.upper(priv->export.priv, AUDIO_CALLBACK_DEQUEUE, apb,
+ -EINVAL);
+#endif
}
/* This is not a WAV file! */