Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f665669 authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Gerrit Code Review
Browse files

Merge "Fix the stereo microphone cache issue"

parents 21441235 3083e1a2
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -2134,6 +2134,12 @@ class LeAudioClientImpl : public LeAudioClient {
    }
  }

  void CleanCachedMicrophoneData() {
    cached_channel_data_.clear();
    cached_channel_timestamp_ = 0;
    cached_channel_is_left_ = false;
  }

  void SendAudioData(uint8_t* data, uint16_t size, uint16_t cis_conn_hdl,
                     uint32_t timestamp) {
    /* Get only one channel for MONO microphone */
@@ -2226,9 +2232,9 @@ class LeAudioClientImpl : public LeAudioClient {
                        &pcm_data_decoded, nullptr);
      return;
    }

    /* both devices are connected */
    if (cached_channel_timestamp_ == 0) {

    if (cached_channel_timestamp_ == 0 && cached_channel_data_.empty()) {
      /* First packet received, cache it. We need both channel data to send it
       * to AF. */
      cached_channel_data_ = pcm_data_decoded;
@@ -2252,7 +2258,7 @@ class LeAudioClientImpl : public LeAudioClient {
                            &pcm_data_decoded, &cached_channel_data_);
        }

        cached_channel_timestamp_ = 0;
        CleanCachedMicrophoneData();
        return;
      }

@@ -2416,7 +2422,8 @@ class LeAudioClientImpl : public LeAudioClient {
    uint16_t remote_delay_ms =
        group->GetRemoteDelay(le_audio::types::kLeAudioDirectionSource);

    cached_channel_timestamp_ = 0;
    CleanCachedMicrophoneData();

    if (CodecManager::GetInstance()->GetCodecLocation() ==
        le_audio::types::CodecLocation::HOST) {
      if (lc3_decoder_left_mem) {