Commit c487c459 authored by Marina Ciocea's avatar Marina Ciocea Committed by Commit Bot

Add UMA stats for AudioManagerWin::GetPreferredOutputStreamParameters

* Add uma logging callback to CreateDeviceEnumeratorInternal,
CreateDeviceInternal and CreateClientInternal
* Add 5 new histograms to track HRESULT of the steps in which
GetPreferredOutputStreamParameters can potentially fail: creating
device enumerator, creating device, creating client, getting
shared-mode mix format and getting device period
* Keep public only one version of each of the 3 CreateDevice,
3 CreateClient and 2 GetPreferredAudioParameters functions and
move the behavior of removed public functions to internal functions
* Refactor CreateDevice and CreateClient
* Remove IsDefaultDevice that duplicates
AudioDeviceDescription::IsDeviceDefault behavior
* Remove unused functions DeviceIsDefault

Bug: 774998
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I8688f38a6b7bc8b093a95ba3ccf83f5b7eafaced
Reviewed-on: https://chromium-review.googlesource.com/750807
Commit-Queue: Marina Ciocea <marinaciocea@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Reviewed-by: default avatarMax Morin <maxmorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517063}
parent f0872687
......@@ -138,7 +138,7 @@ STDMETHODIMP AudioDeviceListenerWin::OnDefaultDeviceChanged(
DVLOG(1) << "OnDefaultDeviceChanged() "
<< "new_default_device: "
<< (new_default_device_id
? CoreAudioUtil::GetFriendlyName(new_device_id)
? CoreAudioUtil::GetFriendlyName(new_device_id, flow, role)
: "no device")
<< ", flow: " << FlowToString(flow)
<< ", role: " << RoleToString(role)
......
......@@ -134,22 +134,11 @@ bool WASAPIAudioOutputStream::Open() {
DCHECK(!audio_client_.Get());
DCHECK(!audio_render_client_.Get());
// Will be set to true if we ended up opening the default communications
// device.
bool communications_device = false;
// Create an IAudioClient interface for the default rendering IMMDevice.
Microsoft::WRL::ComPtr<IAudioClient> audio_client;
if (device_id_.empty()) {
audio_client = CoreAudioUtil::CreateDefaultClient(eRender, device_role_);
communications_device = (device_role_ == eCommunications);
} else {
Microsoft::WRL::ComPtr<IMMDevice> device =
CoreAudioUtil::CreateDevice(device_id_);
DLOG_IF(ERROR, !device.Get()) << "Failed to open device: " << device_id_;
if (device.Get())
audio_client = CoreAudioUtil::CreateClient(device.Get());
}
const bool communications_device =
device_id_.empty() ? (device_role_ == eCommunications) : false;
Microsoft::WRL::ComPtr<IAudioClient> audio_client(
CoreAudioUtil::CreateClient(device_id_, eRender, device_role_));
if (!audio_client.Get())
return false;
......
This diff is collapsed.
......@@ -61,21 +61,16 @@ class MEDIA_EXPORT CoreAudioUtil {
// enumerating audio endpoint devices.
static Microsoft::WRL::ComPtr<IMMDeviceEnumerator> CreateDeviceEnumerator();
// Creates a default endpoint device that is specified by a data-flow
// direction and role, e.g. default render device.
static Microsoft::WRL::ComPtr<IMMDevice> CreateDefaultDevice(
EDataFlow data_flow,
ERole role);
// Create an endpoint device specified by |device_id| or a default device
// specified by data-flow direction and role if
// AudioDeviceDescription::IsDefaultDevice(|device_id|).
static Microsoft::WRL::ComPtr<IMMDevice>
CreateDevice(const std::string& device_id, EDataFlow data_flow, ERole role);
// Returns the device id of the default output device or an empty string
// if no such device exists or if the default device has been disabled.
static std::string GetDefaultOutputDeviceID();
// Creates an endpoint device that is specified by a unique endpoint device-
// identification string.
static Microsoft::WRL::ComPtr<IMMDevice> CreateDevice(
const std::string& device_id);
// Returns the unique ID and user-friendly name of a given endpoint device.
// Example: "{0.0.1.00000000}.{8db6020f-18e3-4f25-b6f5-7726c9122574}", and
// "Microphone (Realtek High Definition Audio)".
......@@ -101,12 +96,9 @@ class MEDIA_EXPORT CoreAudioUtil {
// Gets the user-friendly name of the endpoint device which is represented
// by a unique id in |device_id|.
static std::string GetFriendlyName(const std::string& device_id);
// Returns true if the provided unique |device_id| corresponds to the current
// default device for the specified by a data-flow direction and role.
static bool DeviceIsDefault(
EDataFlow flow, ERole role, const std::string& device_id);
static std::string GetFriendlyName(const std::string& device_id,
EDataFlow data_flow,
ERole role);
// Query if the audio device is a rendering device or a capture device.
static EDataFlow GetDataFlow(IMMDevice* device);
......@@ -115,26 +107,11 @@ class MEDIA_EXPORT CoreAudioUtil {
// manage the flow of audio data between the application and an audio endpoint
// device.
// Create an IAudioClient instance for the default IMMDevice where
// flow direction and role is define by |data_flow| and |role|.
// The IAudioClient interface enables a client to create and initialize an
// audio stream between an audio application and the audio engine (for a
// shared-mode stream) or the hardware buffer of an audio endpoint device
// (for an exclusive-mode stream).
static Microsoft::WRL::ComPtr<IAudioClient> CreateDefaultClient(
EDataFlow data_flow,
ERole role);
// Create an IAudioClient instance for a specific device _or_ the default
// device if |device_id| is empty.
// device if AudioDeviceDescription::IsDefaultDevice(device_id).
static Microsoft::WRL::ComPtr<IAudioClient>
CreateClient(const std::string& device_id, EDataFlow data_flow, ERole role);
// Create an IAudioClient interface for an existing IMMDevice given by
// |audio_device|. Flow direction and role is define by the |audio_device|.
static Microsoft::WRL::ComPtr<IAudioClient> CreateClient(
IMMDevice* audio_device);
// Get the mix format that the audio engine uses internally for processing
// of shared-mode streams. This format is not necessarily a format that the
// audio endpoint device supports. Thus, the caller might not succeed in
......@@ -169,13 +146,9 @@ class MEDIA_EXPORT CoreAudioUtil {
AUDCLNT_SHAREMODE share_mode,
REFERENCE_TIME* device_period);
// Get the preferred audio parameters for the specified |client| or the
// given direction and role is define by |data_flow| and |role|, or the
// unique device id given by |device_id|.
// The acquired values should only be utilized for shared mode streamed since
// there are no preferred settings for an exclusive mode stream.
static HRESULT GetPreferredAudioParameters(IAudioClient* client,
AudioParameters* params);
// Get the preferred audio parameters for the given |device_id|. The acquired
// values should only be utilized for shared mode streamed since there are no
// preferred settings for an exclusive mode stream.
static HRESULT GetPreferredAudioParameters(const std::string& device_id,
bool is_output_device,
AudioParameters* params);
......
......@@ -20888,11 +20888,36 @@ Called by update_gpu_driver_bug_workaround_entries.py.-->
<int value="-2005270485" label="DXGI_ERROR_ACCESS_DENIED"/>
<int value="-2005270484" label="DXGI_ERROR_NAME_ALREADY_EXISTS"/>
<int value="-2005270483" label="DXGI_ERROR_SDK_COMPONENT_MISSING"/>
<int value="-2004287487" label="AUDCLNT_E_NOT_INITIALIZED"/>
<int value="-2004287486" label="AUDCLNT_E_ALREADY_INITIALIZED"/>
<int value="-2004287485" label="AUDCLNT_E_WRONG_ENDPOINT_TYPE"/>
<int value="-2004287484" label="AUDCLNT_E_DEVICE_INVALIDATED"/>
<int value="-2004287483" label="AUDCLNT_E_NOT_STOPPED"/>
<int value="-2004287482" label="AUDCLNT_E_BUFFER_TOO_LARGE"/>
<int value="-2004287481" label="AUDCLNT_E_OUT_OF_ORDER"/>
<int value="-2004287480" label="AUDCLNT_E_UNSUPPORTED_FORMAT"/>
<int value="-2004287479" label="AUDCLNT_E_INVALID_SIZE"/>
<int value="-2004287478" label="AUDCLNT_E_DEVICE_IN_USE"/>
<int value="-2004287477" label="AUDCLNT_E_BUFFER_OPERATION_PENDING"/>
<int value="-2004287476" label="AUDCLNT_E_THREAD_NOT_REGISTERED"/>
<int value="-2004287474" label="AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED"/>
<int value="-2004287473" label="AUDCLNT_E_ENDPOINT_CREATE_FAILED"/>
<int value="-2004287472" label="AUDCLNT_E_SERVICE_NOT_RUNNING"/>
<int value="-2004287471" label="AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED"/>
<int value="-2004287470" label="AUDCLNT_E_EXCLUSIVE_MODE_ONLY"/>
<int value="-2004287469" label="AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL"/>
<int value="-2004287468" label="AUDCLNT_E_EVENTHANDLE_NOT_SET"/>
<int value="-2004287467" label="AUDCLNT_E_INCORRECT_BUFFER_SIZE"/>
<int value="-2004287466" label="AUDCLNT_E_BUFFER_SIZE_ERROR"/>
<int value="-2004287465" label="AUDCLNT_E_CPUUSAGE_EXCEEDED"/>
<int value="-2004287464" label="AUDCLNT_E_BUFFER_ERROR"/>
<int value="-2004287463" label="AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED"/>
<int value="-2004287456" label="AUDCLNT_E_INVALID_DEVICE_PERIOD"/>
<int value="-1606219753" label="GOOPDATE_E_NON_BLOCKING_CALL_PENDING"/>
<int value="-1606219747" label="GOOPDATE_E_APP_USING_EXTERNAL_UPDATER"/>
<int value="143196161" label="AUDCLNT_S_BUFFER_EMPTY"/>
<int value="143196162" label="AUDCLNT_S_THREAD_ALREADY_REGISTERED"/>
<int value="143196163" label="AUDCLNT_S_POSITION_STALLED"/>
</enum>
<enum name="HttpAuthCount">
......@@ -32442,12 +32442,82 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram
name="Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.CreateClientResult"
enum="Hresult">
<owner>marinaciocea@chromium.org</owner>
<summary>
This histogram is the 3nd potential failure step in
CoreAudioUtil::GetPreferredAudioParameters. The success% of this histogram
is input for
Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.GetMixFormatResult
histogram.
</summary>
</histogram>
<histogram
name="Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.CreateDeviceEnumeratorResult"
enum="Hresult">
<owner>marinaciocea@chromium.org</owner>
<summary>
This histogram is the 1st potential failure step in
CoreAudioUtil::GetPreferredAudioParameters. The success% of this histogram
is input for
Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.CreateDeviceResult
histogram.
</summary>
</histogram>
<histogram
name="Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.CreateDeviceResult"
enum="Hresult">
<owner>marinaciocea@chromium.org</owner>
<summary>
This histogram is the 2nd potential failure step in
CoreAudioUtil::GetPreferredAudioParameters. The success% of this histogram
is input for
Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.CreateClientResult
histogram.
</summary>
</histogram>
<histogram
name="Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.GetDevicePeriodResult"
enum="Hresult">
<owner>marinaciocea@chromium.org</owner>
<summary>
This histogram is the last potential failure step in
CoreAudioUtil::GetPreferredAudioParameters.
</summary>
</histogram>
<histogram
name="Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.GetMixFormatResult"
enum="Hresult">
<owner>marinaciocea@chromium.org</owner>
<summary>
This histogram is the 4nd potential failure step in
CoreAudioUtil::GetPreferredAudioParameters. The success% of this histogram
is input for
Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.GetDevicePeriodResult
histogram.
</summary>
</histogram>
<histogram name="Media.AudioOutputStreamProxy.StreamFormat"
enum="AudioOutputProxyStreamFormat">
<owner>olka@chromium.org</owner>
<summary>
Records format used by AudioManager to create audio output stream proxy. If
a fake stream is created it results in muted audio playback.
On Windows, the failure reasons that can lead to fake stream creation are
tracked with the following histograms:
Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.CreateDeviceEnumeratorResult
Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.CreateDeviceResult
Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.CreateClientResult
Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.GetMixFormatResult
Media.AudioOutputStreamProxy.GetPreferredOutputStreamParametersWin.GetDevicePeriodResult
</summary>
</histogram>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment