Misc bugfixes while integrating fast forward by sub-sampling

This commit is contained in:
Gregory Nutt
2014-07-27 19:32:07 -06:00
parent c9f15ffd3d
commit f235f95e52
2 changed files with 28 additions and 11 deletions
+20 -3
View File
@@ -127,6 +127,12 @@ struct pcm_decode_s
uint8_t skip; /* Number of samples to be skipped */ uint8_t skip; /* Number of samples to be skipped */
uint8_t npartial; /* Size of the partial sample */ uint8_t npartial; /* Size of the partial sample */
uint8_t partial[4]; /* Holds the partial sample */ uint8_t partial[4]; /* Holds the partial sample */
/* REVISIT: I think we could get rid of all of this special buffer
* processing. It seems like we should be able to do the sub-sampling
* in place without any additional buffers.
*/
struct audio_buf_desc_s bufdesc; /* Allocated buffer description */ struct audio_buf_desc_s bufdesc; /* Allocated buffer description */
FAR struct ap_buffer_s *ffwd; /* Audio buffer being subsampled into */ FAR struct ap_buffer_s *ffwd; /* Audio buffer being subsampled into */
FAR struct ap_buffer_s *next; /* Next available, empty audio buffer */ FAR struct ap_buffer_s *next; /* Next available, empty audio buffer */
@@ -520,6 +526,11 @@ static int pcm_subsample_configure(FAR struct pcm_decode_s *priv,
audvdbg("Start subsampling: apb=%p\n", priv->apb); audvdbg("Start subsampling: apb=%p\n", priv->apb);
/* REVISIT: I think we could get rid of this special buffer. It
* seems like we should be able to do the sub-sampling in place
* without any additional buffers.
*/
if (priv->apb == NULL) if (priv->apb == NULL)
{ {
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS #ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
@@ -950,7 +961,7 @@ static FAR struct ap_buffer_s *pcm_subsample(FAR struct pcm_decode_s *priv,
* is the case? * is the case?
* *
* REVISIT: Should there be a threshold here so that we do not send * REVISIT: Should there be a threshold here so that we do not send
* really tiny buffers to the * really tiny buffers to the lower-level driver.
*/ */
if (srcsize > 0) if (srcsize > 0)
@@ -1049,7 +1060,7 @@ exit_apb_empty:
/* Is there anything in the working buffer? /* Is there anything in the working buffer?
* *
* REVISIT: Should there be a threshold here so that we do not send * REVISIT: Should there be a threshold here so that we do not send
* really tiny buffers to the * really tiny buffers to the lower-level driver.
*/ */
if (work->nbytes > 0) if (work->nbytes > 0)
@@ -1444,6 +1455,8 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
lower = priv->lower; lower = priv->lower;
DEBUGASSERT(lower && lower->ops->enqueuebuffer && lower->ops->configure); DEBUGASSERT(lower && lower->ops->enqueuebuffer && lower->ops->configure);
apb->curbyte = 0;
/* Are we streaming yet? */ /* Are we streaming yet? */
if (priv->streaming) if (priv->streaming)
@@ -1467,6 +1480,8 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
return lower->ops->enqueuebuffer(lower, apb); return lower->ops->enqueuebuffer(lower, apb);
} }
return OK;
} }
/* No.. then this must be the first buffer that we have seen (since we /* No.. then this must be the first buffer that we have seen (since we
@@ -1536,6 +1551,8 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
return lower->ops->enqueuebuffer(lower, apb); return lower->ops->enqueuebuffer(lower, apb);
} }
return OK;
} }
} }
@@ -1737,7 +1754,7 @@ static void pcm_callback(FAR void *arg, uint16_t reason,
FAR struct pcm_decode_s *priv = (FAR struct pcm_decode_s *)arg; FAR struct pcm_decode_s *priv = (FAR struct pcm_decode_s *)arg;
#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD #ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD
/* If this is our internal working audio buffer that we use for subsampling, /* If this is our internal working audio buffer that we use for sub-sampling,
* then we are the owner of the buffer and we don't want to return it to * then we are the owner of the buffer and we don't want to return it to
* the upper level. * the upper level.
*/ */
+1 -1
View File
@@ -198,7 +198,7 @@
#define AUDIO_SUBSAMPLE_NONE 0 #define AUDIO_SUBSAMPLE_NONE 0
#define AUDIO_SUBSAMPLE_2X 2 #define AUDIO_SUBSAMPLE_2X 2
#define AUDIO_SUBSAMPLE_4X 4 #define AUDIO_SUBSAMPLE_4X 4
#define AUDIO_SUBSAMPLE_8X 5 #define AUDIO_SUBSAMPLE_8X 8
#define AUDIO_SUBSAMPLE_16X 16 #define AUDIO_SUBSAMPLE_16X 16
#define AUDIO_SUBSAMPLE_MIN AUDIO_SUBSAMPLE_2X #define AUDIO_SUBSAMPLE_MIN AUDIO_SUBSAMPLE_2X