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

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


The following commit(s) were added to refs/heads/master by this push:
     new a9142015d52 sim/alsa: Skip mixer calls when no host volume element
a9142015d52 is described below

commit a9142015d52ff246c6180eccc2e49439054ac94d
Author: Anand Mohan <[email protected]>
AuthorDate: Tue Nov 10 17:38:39 2026 +0530

    sim/alsa: Skip mixer calls when no host volume element
    
    play aborts when the host ALSA device has no Master mixer element.
    sim_mixer_open() leaves priv->volume NULL and still returns success,
    then sim_audio_configure() passes that pointer to
    snd_mixer_selem_set_playback_volume_all(), which asserts.
    
    Skip the volume and input-gain mixer get/set calls when priv->volume
    is NULL so PCM playback continues.
    
    Testing: sim:alsa on Linux with no sound card, default PCM pointed at
    the ALSA file plugin. play of a 1-second stereo WAV no longer aborts,
    q returns to nsh, and the recorded file is 176400 bytes.
    
    Signed-off-by: Anand Mohan <[email protected]>
---
 arch/sim/src/sim/posix/sim_alsa.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/arch/sim/src/sim/posix/sim_alsa.c 
b/arch/sim/src/sim/posix/sim_alsa.c
index 751cc9a7347..09d88abfe97 100644
--- a/arch/sim/src/sim/posix/sim_alsa.c
+++ b/arch/sim/src/sim/posix/sim_alsa.c
@@ -401,18 +401,24 @@ static int sim_audio_getcaps(struct audio_lowerhalf_s 
*dev, int type,
         switch (caps->ac_format.hw)
           {
             case AUDIO_FU_VOLUME:
-              host_uninterruptible(snd_mixer_selem_get_playback_volume,
-                                   priv->volume,
-                                   SND_MIXER_SCHN_UNKNOWN,
-                                   &val);
-              caps->ac_controls.w = val;
+              if (priv->volume)
+                {
+                  host_uninterruptible(snd_mixer_selem_get_playback_volume,
+                                       priv->volume,
+                                       SND_MIXER_SCHN_UNKNOWN,
+                                       &val);
+                  caps->ac_controls.w = val;
+                }
               break;
             case AUDIO_FU_INP_GAIN:
-              host_uninterruptible(snd_mixer_selem_get_capture_volume,
-                                   priv->volume,
-                                   SND_MIXER_SCHN_MONO,
-                                   &val);
-              caps->ac_controls.w = val;
+              if (priv->volume)
+                {
+                  host_uninterruptible(snd_mixer_selem_get_capture_volume,
+                                       priv->volume,
+                                       SND_MIXER_SCHN_MONO,
+                                       &val);
+                  caps->ac_controls.w = val;
+                }
               break;
             default:
               break;
@@ -459,11 +465,21 @@ static int sim_audio_configure(struct audio_lowerhalf_s 
*dev,
         switch (caps->ac_format.hw)
           {
             case AUDIO_FU_VOLUME:
+              if (!priv->volume)
+                {
+                  break;
+                }
+
               ret = host_uninterruptible(
                       snd_mixer_selem_set_playback_volume_all,
                       priv->volume, caps->ac_controls.hw[0]);
               break;
             case AUDIO_FU_INP_GAIN:
+              if (!priv->volume)
+                {
+                  break;
+                }
+
               ret = host_uninterruptible(
                         snd_mixer_selem_set_capture_volume_all,
                         priv->volume, caps->ac_controls.hw[0]);

Reply via email to