qiaohaijiao commented on code in PR #7717:
URL: https://github.com/apache/nuttx/pull/7717#discussion_r1037818394


##########
arch/sim/src/sim/sim_alsa.c:
##########
@@ -702,6 +855,147 @@ static int sim_mixer_open(struct sim_audio_s *priv)
   return 0;
 }
 
+static int sim_audio_mp3_scale(mad_fixed_t sample)
+{
+  sample += 1L << (MAD_F_FRACBITS - 16);
+
+  if (sample >= MAD_F_ONE)
+    {
+      sample = MAD_F_ONE - 1;
+    }
+  else if (sample < -MAD_F_ONE)
+    {
+      sample = -MAD_F_ONE;
+    }
+
+  return sample >> (MAD_F_FRACBITS + 1 - 16);
+}
+
+static void *sim_audio_mp3_init()
+{
+  struct sim_decoder_mp3_s *codec;
+
+  codec = malloc(sizeof(struct sim_decoder_mp3_s));

Review Comment:
   done



##########
arch/sim/src/sim/sim_alsa.c:
##########
@@ -702,6 +855,147 @@ static int sim_mixer_open(struct sim_audio_s *priv)
   return 0;
 }
 
+static int sim_audio_mp3_scale(mad_fixed_t sample)
+{
+  sample += 1L << (MAD_F_FRACBITS - 16);
+
+  if (sample >= MAD_F_ONE)
+    {
+      sample = MAD_F_ONE - 1;
+    }
+  else if (sample < -MAD_F_ONE)
+    {
+      sample = -MAD_F_ONE;
+    }
+
+  return sample >> (MAD_F_FRACBITS + 1 - 16);
+}
+
+static void *sim_audio_mp3_init()
+{
+  struct sim_decoder_mp3_s *codec;
+
+  codec = malloc(sizeof(struct sim_decoder_mp3_s));
+  if (codec == NULL)
+    {
+      return NULL;
+    }
+
+  mad_stream_init(&codec->stream);
+  mad_frame_init(&codec->frame);
+  mad_synth_init(&codec->synth);
+
+  codec->out = malloc(sizeof(codec->synth.pcm.samples));

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to