Add input pool to ConvertingAudioFifo [chromium/src : main]

0 views
Skip to first unread message

Johannes Kron (Gerrit)

unread,
Apr 1, 2026, 9:10:34 AM (yesterday) Apr 1
to Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org
Attention needed from Thomas Guilbert

Johannes Kron voted and added 1 comment

Votes added by Johannes Kron

Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 11 (Latest):
Johannes Kron . resolved

Hey Thomas!
Can you review this change to ConvertingAudioFifo that I need to use this component in another [CL](https://chromium-review.git.corp.google.com/c/chromium/src/+/7673640)?
Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Thomas Guilbert
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I5779e2d23bea28389ad992cf6ec3542a57136ee5
Gerrit-Change-Number: 7691654
Gerrit-PatchSet: 11
Gerrit-Owner: Johannes Kron <kr...@chromium.org>
Gerrit-Reviewer: Johannes Kron <kr...@chromium.org>
Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
Gerrit-Comment-Date: Wed, 01 Apr 2026 13:10:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Thomas Guilbert (Gerrit)

unread,
Apr 1, 2026, 7:44:45 PM (24 hours ago) Apr 1
to Johannes Kron, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org
Attention needed from Johannes Kron

Thomas Guilbert added 7 comments

File media/base/converting_audio_fifo.h
Line 84, Patchset 11 (Latest): void PopInput();
Thomas Guilbert . unresolved

Tiniest of nits: do you mind renaming this to `PopInputs()`

File media/base/converting_audio_fifo.cc
Line 41, Patchset 11 (Latest): // Max capacity needed to safely hold frames until min_input_frames_needed_
Thomas Guilbert . unresolved

NIT: wrap with backticks ```

Line 44, Patchset 11 (Latest): (min_input_frames_needed_ + input_params_.frames_per_buffer() - 1) /
Thomas Guilbert . unresolved

It's not obvious to me where the `-1` comes from. Is this just to force a rounding down of the number of buffers?

This would be easier to understand if the calculation was broken down into an intermediary named variable (which the compiler will optimize away anyway).

Line 63, Patchset 11 (Latest): inputs_.emplace_back(EnsureExpectedChannelCount(std::move(input_bus)));
Thomas Guilbert . unresolved

This behavior complicates things quite a bit when it comes to pool usage.

If we push a bus with a different channel count than `input_params_`, we will still be allocating busses constantly, which negates the point of the pool.

Also calling pushing a bus with a certain channel count and saving the mixed bus to the pool forces callers to check for a channel count match when calling `GetInputAudioBus()`, which is surprising.

I would suggest only accepting busses that match `input_params_.channels()` when using the pool. Alternatively, we could use 2 pools (the one you're adding and one more for the mixer), but I feel like this would complicate things... It depends how often you expect channel counts to change in your dependent CL.

Line 73, Patchset 11 (Latest): return base::Seconds(static_cast<double>(total_frames_) /
Thomas Guilbert . unresolved

Use `AudioTimestampHelper::FramesToTime()`

File media/base/converting_audio_fifo_unittest.cc
Line 193, Patchset 11 (Latest): EXPECT_NEAR(fifo()->GetBufferedInputDuration().InSecondsF(),
static_cast<double>(total_frames_pushed) / kInputSampleRate,
Thomas Guilbert . unresolved

Use `AudioTimestampHelper::FramesToTime` here as well.

Line 418, Patchset 11 (Latest): EXPECT_EQ(pooled_bus->channels(), kDefaultParams.channels());
EXPECT_EQ(pooled_bus->frames(), kDefaultParams.frames_per_buffer());
Thomas Guilbert . unresolved

As mentioned in the .cc file, I find this behavior surprising, and I think it would be easiest to reason about if this wasn't allowed.

Open in Gerrit

Related details

Attention is currently required from:
  • Johannes Kron
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I5779e2d23bea28389ad992cf6ec3542a57136ee5
    Gerrit-Change-Number: 7691654
    Gerrit-PatchSet: 11
    Gerrit-Owner: Johannes Kron <kr...@chromium.org>
    Gerrit-Reviewer: Johannes Kron <kr...@chromium.org>
    Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
    Gerrit-Attention: Johannes Kron <kr...@chromium.org>
    Gerrit-Comment-Date: Wed, 01 Apr 2026 23:44:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Johannes Kron (Gerrit)

    unread,
    6:13 AM (13 hours ago) 6:13 AM
    to Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org
    Attention needed from Thomas Guilbert

    Johannes Kron voted and added 7 comments

    Votes added by Johannes Kron

    Commit-Queue+1

    7 comments

    File media/base/converting_audio_fifo.h
    Line 84, Patchset 11: void PopInput();
    Thomas Guilbert . resolved

    Tiniest of nits: do you mind renaming this to `PopInputs()`

    Johannes Kron

    Not at all. Done.

    File media/base/converting_audio_fifo.cc
    Line 41, Patchset 11: // Max capacity needed to safely hold frames until min_input_frames_needed_
    Thomas Guilbert . resolved

    NIT: wrap with backticks ```

    Johannes Kron

    Done

    Line 44, Patchset 11: (min_input_frames_needed_ + input_params_.frames_per_buffer() - 1) /
    Thomas Guilbert . resolved

    It's not obvious to me where the `-1` comes from. Is this just to force a rounding down of the number of buffers?

    This would be easier to understand if the calculation was broken down into an intermediary named variable (which the compiler will optimize away anyway).

    Johannes Kron

    I'll blame this one on Gemini—it insisted I optimize away the ceil method. Re-reading this a week later, it’s not obvious to me what’s happening at a glance, so I’m reverting to the more readable version.

    Line 63, Patchset 11: inputs_.emplace_back(EnsureExpectedChannelCount(std::move(input_bus)));
    Thomas Guilbert . resolved

    This behavior complicates things quite a bit when it comes to pool usage.

    If we push a bus with a different channel count than `input_params_`, we will still be allocating busses constantly, which negates the point of the pool.

    Also calling pushing a bus with a certain channel count and saving the mixed bus to the pool forces callers to check for a channel count match when calling `GetInputAudioBus()`, which is surprising.

    I would suggest only accepting busses that match `input_params_.channels()` when using the pool. Alternatively, we could use 2 pools (the one you're adding and one more for the mixer), but I feel like this would complicate things... It depends how often you expect channel counts to change in your dependent CL.

    Johannes Kron

    I agree. Since there are no channel count changes in my dependent CL, I’ll restrict `EnsureExpectedChannelCount` to only accept buses matching `input_params_.channels()` if the pool is used. I'll add a `CHECK` to enforce this; since pooling is an explicit opt-in, a mismatch is a logic error that we should catch immediately. This keeps the pool efficient and `GetInputAudioBus()` predictable.

    Line 73, Patchset 11: return base::Seconds(static_cast<double>(total_frames_) /
    Thomas Guilbert . resolved

    Use `AudioTimestampHelper::FramesToTime()`

    Johannes Kron

    Done

    File media/base/converting_audio_fifo_unittest.cc
    Line 193, Patchset 11: EXPECT_NEAR(fifo()->GetBufferedInputDuration().InSecondsF(),

    static_cast<double>(total_frames_pushed) / kInputSampleRate,
    Thomas Guilbert . resolved

    Use `AudioTimestampHelper::FramesToTime` here as well.

    Johannes Kron

    Done

    Line 418, Patchset 11: EXPECT_EQ(pooled_bus->channels(), kDefaultParams.channels());
    EXPECT_EQ(pooled_bus->frames(), kDefaultParams.frames_per_buffer());
    Thomas Guilbert . resolved

    As mentioned in the .cc file, I find this behavior surprising, and I think it would be easiest to reason about if this wasn't allowed.

    Johannes Kron

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Thomas Guilbert
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I5779e2d23bea28389ad992cf6ec3542a57136ee5
      Gerrit-Change-Number: 7691654
      Gerrit-PatchSet: 14
      Gerrit-Owner: Johannes Kron <kr...@chromium.org>
      Gerrit-Reviewer: Johannes Kron <kr...@chromium.org>
      Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
      Gerrit-Attention: Thomas Guilbert <tgui...@chromium.org>
      Gerrit-Comment-Date: Thu, 02 Apr 2026 10:13:07 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Thomas Guilbert <tgui...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Thomas Guilbert (Gerrit)

      unread,
      2:46 PM (5 hours ago) 2:46 PM
      to Johannes Kron, Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org
      Attention needed from Johannes Kron

      Thomas Guilbert voted and added 1 comment

      Votes added by Thomas Guilbert

      Code-Review+1

      1 comment

      Patchset-level comments
      File-level comment, Patchset 14 (Latest):
      Thomas Guilbert . resolved

      LGTM, TY!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Johannes Kron
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I5779e2d23bea28389ad992cf6ec3542a57136ee5
      Gerrit-Change-Number: 7691654
      Gerrit-PatchSet: 14
      Gerrit-Owner: Johannes Kron <kr...@chromium.org>
      Gerrit-Reviewer: Johannes Kron <kr...@chromium.org>
      Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
      Gerrit-Attention: Johannes Kron <kr...@chromium.org>
      Gerrit-Comment-Date: Thu, 02 Apr 2026 18:46:34 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Johannes Kron (Gerrit)

      unread,
      3:41 PM (4 hours ago) 3:41 PM
      to Thomas Guilbert, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org

      Johannes Kron voted and added 1 comment

      Votes added by Johannes Kron

      Commit-Queue+2

      1 comment

      Patchset-level comments
      Johannes Kron . resolved

      Thanks for the review!

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I5779e2d23bea28389ad992cf6ec3542a57136ee5
      Gerrit-Change-Number: 7691654
      Gerrit-PatchSet: 14
      Gerrit-Owner: Johannes Kron <kr...@chromium.org>
      Gerrit-Reviewer: Johannes Kron <kr...@chromium.org>
      Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
      Gerrit-Comment-Date: Thu, 02 Apr 2026 19:41:30 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Chromium LUCI CQ (Gerrit)

      unread,
      3:53 PM (4 hours ago) 3:53 PM
      to Johannes Kron, Thomas Guilbert, chromium...@chromium.org, feature-me...@chromium.org

      Chromium LUCI CQ submitted the change

      Change information

      Commit message:
      Add input pool to ConvertingAudioFifo

      Introduces an optional input `AudioBusPoolImpl` to `ConvertingAudioFifo`
      to reduce memory allocations on the audio processing hot path. Input
      buses are safely recycled in `PopInput()` only if their frame counts
      strictly match `input_params_.frames_per_buffer()`, avoiding DCHECKs
      when handling dynamically sized buffers.

      Additionally, adds `GetBufferedInputDuration()` to provide the total
      duration of audio currently held in the FIFO.
      Bug: 481295177
      Change-Id: I5779e2d23bea28389ad992cf6ec3542a57136ee5
      Reviewed-by: Thomas Guilbert <tgui...@chromium.org>
      Commit-Queue: Johannes Kron <kr...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#1609442}
      Files:
      • M media/base/converting_audio_fifo.cc
      • M media/base/converting_audio_fifo.h
      • M media/base/converting_audio_fifo_unittest.cc
      Change size: M
      Delta: 3 files changed, 150 insertions(+), 9 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Thomas Guilbert
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I5779e2d23bea28389ad992cf6ec3542a57136ee5
      Gerrit-Change-Number: 7691654
      Gerrit-PatchSet: 15
      Gerrit-Owner: Johannes Kron <kr...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Johannes Kron <kr...@chromium.org>
      Gerrit-Reviewer: Thomas Guilbert <tgui...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages