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

rymek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 18970d976a15eda90ae0ecf629d4edf5c33d2b8a
Author: Krzysztof Kopyściński <[email protected]>
AuthorDate: Fri May 10 08:42:47 2024 +0200

    apps/auracast_usb: fix broadcast with HCI feedback disabled
    
    When HCI feedback is disabled, we shall use LC3 internal resampler.
    Adjusted samplerate on LC3 input to accomodate this.
---
 apps/auracast_usb/src/app_priv.h  | 6 +++++-
 apps/auracast_usb/src/audio_usb.c | 8 ++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/apps/auracast_usb/src/app_priv.h b/apps/auracast_usb/src/app_priv.h
index 87a901a7..5304e082 100644
--- a/apps/auracast_usb/src/app_priv.h
+++ b/apps/auracast_usb/src/app_priv.h
@@ -28,12 +28,16 @@
 
 #define AUDIO_CHANNELS          MYNEWT_VAL(AURACAST_CHAN_NUM)
 #define AUDIO_SAMPLE_SIZE       sizeof(int16_t)
+#if MYNEWT_VAL(ISO_HCI_FEEDBACK)
+#define AUDIO_PCM_SAMPLE_RATE   LC3_SAMPLING_FREQ
+#else
 #define AUDIO_PCM_SAMPLE_RATE   MYNEWT_VAL(USB_AUDIO_OUT_SAMPLE_RATE)
+#endif
 
 #define LC3_FRAME_DURATION      (MYNEWT_VAL(LC3_FRAME_DURATION))
 #define LC3_SAMPLING_FREQ       (MYNEWT_VAL(LC3_SAMPLING_FREQ))
 #define LC3_BITRATE             (MYNEWT_VAL(LC3_BITRATE))
-#define LC3_FPDT                (LC3_SAMPLING_FREQ * LC3_FRAME_DURATION / 
1000000)
+#define LC3_FPDT                (AUDIO_PCM_SAMPLE_RATE * LC3_FRAME_DURATION / 
1000000)
 #define BIG_NUM_BIS             (MIN(AUDIO_CHANNELS, MYNEWT_VAL(BIG_NUM_BIS)))
 
 struct chan {
diff --git a/apps/auracast_usb/src/audio_usb.c 
b/apps/auracast_usb/src/audio_usb.c
index 3d51be51..933a04d8 100644
--- a/apps/auracast_usb/src/audio_usb.c
+++ b/apps/auracast_usb/src/audio_usb.c
@@ -60,7 +60,7 @@ static int16_t samples_read[AUDIO_BUF_SIZE];
 /* 155 is maximum value Octets Per Codec Frame described in Table 3.5 of BAP 
specification */
 static float samples_read_float[AUDIO_BUF_SIZE];
 static float resampled_float[AUDIO_BUF_SIZE];
-float resampler_in_rate = AUDIO_PCM_SAMPLE_RATE;
+float resampler_in_rate = MYNEWT_VAL(USB_AUDIO_OUT_SAMPLE_RATE);
 float resampler_out_rate = LC3_SAMPLING_FREQ;
 float resampler_ratio;
 SRC_STATE *resampler_state;
@@ -250,14 +250,14 @@ audio_usb_init(void)
     usb_desc_sample_rate_set(AUDIO_PCM_SAMPLE_RATE);
 
     assert(LC3_FPDT == lc3_frame_samples(LC3_FRAME_DURATION,
-                                         LC3_SAMPLING_FREQ));
+                                         AUDIO_PCM_SAMPLE_RATE));
 
     unsigned esize = lc3_encoder_size(LC3_FRAME_DURATION,
-                                      LC3_SAMPLING_FREQ);
+                                      AUDIO_PCM_SAMPLE_RATE);
     for (int i = 0; i < AUDIO_CHANNELS; i++) {
         chans[i].encoder = calloc(1, esize);
         lc3_setup_encoder(LC3_FRAME_DURATION, LC3_SAMPLING_FREQ,
-                          0, chans[i].encoder);
+                          AUDIO_PCM_SAMPLE_RATE, chans[i].encoder);
     }
 
     g_usb_enabled = 1;

Reply via email to