Audio: Standardize WASAPI output errors to HRESULT for UMA [chromium/src : main]

0 views
Skip to first unread message

Henrik Andreasson (Gerrit)

unread,
May 13, 2026, 7:35:40 AM (5 days ago) May 13
to chromium...@chromium.org, feature-me...@chromium.org

Henrik Andreasson added 2 comments

File media/audio/win/core_audio_util_win.cc
Line 930, Patchset 10 (Latest): return CreateClientInternal(device.Get(), hr_out);
Henrik Andreasson . resolved

If `CreateDevice` fails, it populates `hr_out` with the exact failure reason (e.g. `E_INVALIDARG`). However, `device.Get()` evaluates to `nullptr`.

The subsequent call to `CreateClientInternal(nullptr, hr_out)` will then overwrite the `hr_out` with `E_POINTER`, discarding the actual `CreateDevice` error. This results in the UMA logs being polluted by `E_POINTER` errors instead of the specific actionable COM code.

To fix this, add an early return:
```cpp
ComPtr<IMMDevice> device(CreateDevice(device_id, data_flow, role, hr_out));
if (!device) {
return ComPtr<IAudioClient>();
}
return CreateClientInternal(device.Get(), hr_out);
```
Line 938, Patchset 10 (Latest): return CreateClientInternal3(device.Get(), hr_out);
Henrik Andreasson . resolved

Similar to `CreateClient`, calling `CreateClientInternal3(nullptr, hr_out)` when `CreateDevice` fails will overwrite the actual `hr_out` with `E_POINTER`. You should add an early return here as well.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I247635c8d92329eeb438b4be402196a422dbb6b4
Gerrit-Change-Number: 7841692
Gerrit-PatchSet: 10
Gerrit-Owner: Henrik Andreasson <hen...@chromium.org>
Gerrit-Comment-Date: Wed, 13 May 2026 11:35:27 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Olga Sharonova (Gerrit)

unread,
5:07 AM (4 hours ago) 5:07 AM
to Henrik Andreasson, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org
Attention needed from Henrik Andreasson

Olga Sharonova added 3 comments

Patchset-level comments
File-level comment, Patchset 12 (Latest):
Olga Sharonova . resolved

We may need to reversion UMA histograms, otherwise it will remain polluted for a long time.

File media/audio/win/audio_low_latency_output_win.cc
Line 666, Patchset 12 (Latest): HRESULT hr = S_FALSE;
Olga Sharonova . unresolved

Declare locally where used?

File media/audio/win/core_audio_util_win.h
Line 107, Patchset 12 (Latest): HRESULT* hr_out = nullptr);
Olga Sharonova . unresolved

Do we have to have it as a pointer defaulted to nullptr, rather than a reference?

Open in Gerrit

Related details

Attention is currently required from:
  • Henrik Andreasson
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement 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: I247635c8d92329eeb438b4be402196a422dbb6b4
    Gerrit-Change-Number: 7841692
    Gerrit-PatchSet: 12
    Gerrit-Owner: Henrik Andreasson <hen...@chromium.org>
    Gerrit-Reviewer: Henrik Andreasson <hen...@chromium.org>
    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
    Gerrit-Comment-Date: Mon, 18 May 2026 09:07:43 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Henrik Andreasson (Gerrit)

    unread,
    6:12 AM (3 hours ago) 6:12 AM
    to Olga Sharonova, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org
    Attention needed from Olga Sharonova

    Henrik Andreasson added 2 comments

    File media/audio/win/audio_low_latency_output_win.cc
    Line 666, Patchset 12: HRESULT hr = S_FALSE;
    Olga Sharonova . resolved

    Declare locally where used?

    Henrik Andreasson

    Done. Removed the top-level function-scoped declaration of hr and declared
    it locally in the blocks where it is used.

    File media/audio/win/core_audio_util_win.h
    Line 107, Patchset 12: HRESULT* hr_out = nullptr);
    Olga Sharonova . resolved

    Do we have to have it as a pointer defaulted to nullptr, rather than a reference?

    Henrik Andreasson

    I felt it was better to use a pointer defaulted to nullptr primarily to keep the out-parameter optional. That way we avoid forcing all users follow my changes.

    Additionally (my personal preference) using a pointer requires callers to explicitly pass &hr, which makes it visually clear at the call site that the variable is going to be mutated.

    So, No it is not *required* but nice to have imo.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Olga Sharonova
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement 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: I247635c8d92329eeb438b4be402196a422dbb6b4
      Gerrit-Change-Number: 7841692
      Gerrit-PatchSet: 12
      Gerrit-Owner: Henrik Andreasson <hen...@chromium.org>
      Gerrit-Reviewer: Henrik Andreasson <hen...@chromium.org>
      Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
      Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
      Gerrit-Comment-Date: Mon, 18 May 2026 10:12:42 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Henrik Andreasson (Gerrit)

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

      Henrik Andreasson added 1 comment

      Patchset-level comments
      File-level comment, Patchset 13 (Latest):
      Henrik Andreasson . resolved

      PTAL

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Olga Sharonova
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement 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: I247635c8d92329eeb438b4be402196a422dbb6b4
      Gerrit-Change-Number: 7841692
      Gerrit-PatchSet: 13
      Gerrit-Owner: Henrik Andreasson <hen...@chromium.org>
      Gerrit-Reviewer: Henrik Andreasson <hen...@chromium.org>
      Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
      Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
      Gerrit-Comment-Date: Mon, 18 May 2026 10:13:02 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Olga Sharonova (Gerrit)

      unread,
      7:17 AM (2 hours ago) 7:17 AM
      to Henrik Andreasson, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org
      Attention needed from Henrik Andreasson

      Olga Sharonova added 2 comments

      Patchset-level comments
      File-level comment, Patchset 12:
      Olga Sharonova . unresolved

      We may need to reversion UMA histograms, otherwise it will remain polluted for a long time.

      Olga Sharonova

      Still holds.

      File media/audio/win/core_audio_util_win.h
      Line 107, Patchset 12: HRESULT* hr_out = nullptr);
      Olga Sharonova . unresolved

      Do we have to have it as a pointer defaulted to nullptr, rather than a reference?

      Henrik Andreasson

      I felt it was better to use a pointer defaulted to nullptr primarily to keep the out-parameter optional. That way we avoid forcing all users follow my changes.

      Additionally (my personal preference) using a pointer requires callers to explicitly pass &hr, which makes it visually clear at the call site that the variable is going to be mutated.

      So, No it is not *required* but nice to have imo.

      Olga Sharonova

      https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs

      Are there many users we are concerned with? (Also: we can overload a function for those)

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Henrik Andreasson
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement 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: I247635c8d92329eeb438b4be402196a422dbb6b4
        Gerrit-Change-Number: 7841692
        Gerrit-PatchSet: 13
        Gerrit-Owner: Henrik Andreasson <hen...@chromium.org>
        Gerrit-Reviewer: Henrik Andreasson <hen...@chromium.org>
        Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
        Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
        Gerrit-Comment-Date: Mon, 18 May 2026 11:17:37 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
        Comment-In-Reply-To: Henrik Andreasson <hen...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Henrik Andreasson (Gerrit)

        unread,
        8:48 AM (1 hour ago) 8:48 AM
        to Olga Sharonova, Chromium LUCI CQ, chromium...@chromium.org, feature-me...@chromium.org
        Attention needed from Olga Sharonova

        Henrik Andreasson added 3 comments

        Patchset-level comments
        File-level comment, Patchset 12:
        Olga Sharonova . resolved

        We may need to reversion UMA histograms, otherwise it will remain polluted for a long time.

        Olga Sharonova

        Still holds.

        Henrik Andreasson

        Missed this. Now fixed.

        File-level comment, Patchset 14:
        Henrik Andreasson . resolved

        Thanks.

        PTAL

        File media/audio/win/core_audio_util_win.h
        Line 107, Patchset 12: HRESULT* hr_out = nullptr);
        Olga Sharonova . resolved

        Do we have to have it as a pointer defaulted to nullptr, rather than a reference?

        Henrik Andreasson

        I felt it was better to use a pointer defaulted to nullptr primarily to keep the out-parameter optional. That way we avoid forcing all users follow my changes.

        Additionally (my personal preference) using a pointer requires callers to explicitly pass &hr, which makes it visually clear at the call site that the variable is going to be mutated.

        So, No it is not *required* but nice to have imo.

        Olga Sharonova

        https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs

        Are there many users we are concerned with? (Also: we can overload a function for those)

        Henrik Andreasson

        A summary of what broke is given in https://paste.googleplex.com/5385095356743680. I did not list all details but instead implemented the overloads as you suggested.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Olga Sharonova
        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: I247635c8d92329eeb438b4be402196a422dbb6b4
        Gerrit-Change-Number: 7841692
        Gerrit-PatchSet: 14
        Gerrit-Owner: Henrik Andreasson <hen...@chromium.org>
        Gerrit-Reviewer: Henrik Andreasson <hen...@chromium.org>
        Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
        Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
        Gerrit-Comment-Date: Mon, 18 May 2026 12:48:08 +0000
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Johannes Kron (Gerrit)

        unread,
        9:16 AM (6 minutes ago) 9:16 AM
        to Henrik Andreasson, Chromium Metrics Reviews, android-bu...@system.gserviceaccount.com, Olga Sharonova, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, feature-me...@chromium.org
        Attention needed from Henrik Andreasson and Olga Sharonova

        Johannes Kron voted Code-Review+1

        Code-Review+1
        Open in Gerrit

        Related details

        Attention is currently required from:
        • Henrik Andreasson
        • Olga Sharonova
        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: I247635c8d92329eeb438b4be402196a422dbb6b4
        Gerrit-Change-Number: 7841692
        Gerrit-PatchSet: 15
        Gerrit-Owner: Henrik Andreasson <hen...@chromium.org>
        Gerrit-Reviewer: Henrik Andreasson <hen...@chromium.org>
        Gerrit-Reviewer: Johannes Kron <kr...@chromium.org>
        Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
        Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
        Gerrit-Attention: Henrik Andreasson <hen...@chromium.org>
        Gerrit-Comment-Date: Mon, 18 May 2026 13:16:00 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        open
        diffy
        Reply all
        Reply to author
        Forward
        0 new messages