Audio: Fix issue of ac_type always coming as AUDIO_TYPE_OUTPUT
authorKishore SN <kishore.sn@samsung.com>
Thu, 14 Sep 2017 04:31:45 +0000 (10:01 +0530)
committerShivam Garg <garg.shivam@samsung.com>
Mon, 18 Sep 2017 14:03:32 +0000 (23:03 +0900)
framework/src/tinyalsa/tinyalsa.c
os/audio/pcm_decode.c
os/drivers/audio/alc5658.c
os/include/tinyara/audio/audio.h

index 976dd2f..c0c3e2c 100644 (file)
@@ -934,6 +934,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, unsigned int flags,
 #ifdef CONFIG_AUDIO_FORMAT_PCM
        if (pcm->flags & PCM_IN) {
                struct ap_buffer_s *apb = (struct ap_buffer_s *)pcm->pBuffers[0];
+               apb->flags = AUDIO_APB_TYPE_INPUT;
                if (apb->nmaxbytes - apb->nbytes >= sizeof(struct wav_header_s)) {
                        struct wav_header_s *wav = (struct wav_header_s *)(&apb->samp[0]);
                        
index 027f027..4c0c2ec 100644 (file)
@@ -872,7 +872,6 @@ static int pcm_resume(FAR struct audio_lowerhalf_s *dev, FAR void *session)
 #else
 static int pcm_resume(FAR struct audio_lowerhalf_s *dev)
 #endif
-#endif
 {
        FAR struct pcm_decode_s *priv = (FAR struct pcm_decode_s *)dev;
        FAR struct audio_lowerhalf_s *lower;
@@ -891,6 +890,7 @@ static int pcm_resume(FAR struct audio_lowerhalf_s *dev)
        return lower->ops->resume(lower);
 #endif
 }
+#endif
 
 /****************************************************************************
  * Name: pcm_allocbuffer
@@ -1027,7 +1027,11 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, FAR struct ap_bu
                        DEBUGASSERT(priv->samprate < 65535);
 
                        caps.ac_len = sizeof(struct audio_caps_s);
-                       caps.ac_type = AUDIO_TYPE_OUTPUT;
+                       if (apb->flags & AUDIO_APB_TYPE_INPUT) {
+                               caps.ac_type = AUDIO_TYPE_INPUT;
+                       } else {
+                               caps.ac_type = AUDIO_TYPE_OUTPUT;
+                       }
                        caps.ac_channels = priv->nchannels;
 
                        caps.ac_controls.hw[0] = (uint16_t) priv->samprate;
index 8de592d..188f06c 100644 (file)
@@ -534,7 +534,7 @@ static int alc5658_configure(FAR struct audio_lowerhalf_s *dev, FAR const struct
                }
                break; /* Break for inner switch case */
        case AUDIO_TYPE_INPUT: {
-               audvdbg("  AUDIO_TYPE_OUTPUT:\n");
+               audvdbg("  AUDIO_TYPE_INPUT:\n");
                /* Verify that all of the requested values are supported */
 
                ret = -ERANGE;
index 7b5f48f..f2916e1 100644 (file)
 #define AUDIO_APB_DEQUEUED          (1 << 2)
 #define AUDIO_APB_FINAL             (1 << 3)   /* Last buffer in the stream */
 
+#define AUDIO_APB_TYPE_INPUT       (1 << 4)
+#define AUDIO_APB_TYPE_OUTPUT      (1 << 5)
 /****************************************************************************
  * Public Types
  ****************************************************************************/