You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2022/04/10 18:41:23 UTC

[incubator-nuttx] 01/02: audio: Return audio_lowerhalf_s pointer instead error code in audio_comp_initialize

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit f3d20abe0725395f2fdcbe83fdecae8ec41f6dbb
Author: zhangyuebin <zh...@xiaomi.com>
AuthorDate: Tue Nov 9 14:47:49 2021 +0800

    audio: Return audio_lowerhalf_s pointer instead error code in audio_comp_initialize
---
 audio/audio_comp.c               | 11 ++++++-----
 include/nuttx/audio/audio_comp.h |  5 +++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/audio/audio_comp.c b/audio/audio_comp.c
index fd93121d30..ad3f929919 100644
--- a/audio/audio_comp.c
+++ b/audio/audio_comp.c
@@ -919,14 +919,15 @@ static void audio_comp_callback(FAR void *arg, uint16_t reason,
  *   ...  - The list of the lower half audio driver.
  *
  * Returned Value:
- *   Zero on success; a negated errno value on failure.
+ *   struct audio_lowerhalf_s* on success; NULL on failure.
  *
  * Note
  *   The variable argument list must be NULL terminated.
  *
  ****************************************************************************/
 
-int audio_comp_initialize(FAR const char *name, ...)
+FAR struct audio_lowerhalf_s *audio_comp_initialize(FAR const char *name,
+                                                    ...)
 {
   FAR struct audio_comp_priv_s *priv;
   va_list ap;
@@ -936,7 +937,7 @@ int audio_comp_initialize(FAR const char *name, ...)
   priv = kmm_zalloc(sizeof(struct audio_comp_priv_s));
   if (priv == NULL)
     {
-      return ret;
+      return NULL;
     }
 
   priv->export.ops = &g_audio_comp_ops;
@@ -974,11 +975,11 @@ int audio_comp_initialize(FAR const char *name, ...)
       goto free_lower;
     }
 
-  return OK;
+  return &priv->export;
 
 free_lower:
   kmm_free(priv->lower);
 free_priv:
   kmm_free(priv);
-  return ret;
+  return NULL;
 }
diff --git a/include/nuttx/audio/audio_comp.h b/include/nuttx/audio/audio_comp.h
index 92650c6599..4a98cb977e 100644
--- a/include/nuttx/audio/audio_comp.h
+++ b/include/nuttx/audio/audio_comp.h
@@ -65,14 +65,15 @@ extern "C"
  *   ...  - The list of the lower half audio driver.
  *
  * Returned Value:
- *   Zero on success; a negated errno value on failure.
+ *   struct audio_lowerhalf_s* on success; NULL on failure.
  *
  * Note
  *   The variable argument list must be NULL terminated.
  *
  ****************************************************************************/
 
-int audio_comp_initialize(FAR const char *name, ...);
+FAR struct audio_lowerhalf_s *audio_comp_initialize(FAR const char *name,
+                                                    ...);
 
 #undef EXTERN
 #ifdef __cplusplus