File: audio_devices_pref_handler_stub.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (119 lines) | stat: -rw-r--r-- 4,657 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_STUB_H_
#define CHROMEOS_ASH_COMPONENTS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_STUB_H_

#include <stdint.h>

#include <map>

#include "base/component_export.h"
#include "base/observer_list.h"
#include "chromeos/ash/components/audio/audio_devices_pref_handler.h"

namespace ash {

// Stub class for AudioDevicesPrefHandler, used for testing.
class COMPONENT_EXPORT(CHROMEOS_ASH_COMPONENTS_AUDIO)
    AudioDevicesPrefHandlerStub : public AudioDevicesPrefHandler {
 public:
  struct DeviceState {
    bool active;
    bool activate_by_user;
  };

  using AudioDeviceMute = std::map<uint64_t, bool>;
  using AudioDeviceVolumeGain = std::map<uint64_t, int>;
  using AudioDeviceStateMap = std::map<uint64_t, DeviceState>;
  using AudioDeviceUserPriority = std::map<uint64_t, int>;
  using AudioDevicePreferenceSetMap = std::map<std::string, std::string>;
  using MostRecentActivatedDeviceIdList = base::Value::List;

  AudioDevicesPrefHandlerStub();

  AudioDevicesPrefHandlerStub(const AudioDevicesPrefHandlerStub&) = delete;
  AudioDevicesPrefHandlerStub& operator=(const AudioDevicesPrefHandlerStub&) =
      delete;

  // AudioDevicesPrefHandler:
  double GetOutputVolumeValue(const AudioDevice* device) override;
  double GetInputGainValue(const AudioDevice* device) override;
  void SetVolumeGainValue(const AudioDevice& device, double value) override;
  bool GetMuteValue(const AudioDevice& device) override;
  void SetMuteValue(const AudioDevice& device, bool mute_on) override;
  void SetDeviceActive(const AudioDevice& device,
                       bool active,
                       bool activate_by_user) override;
  bool GetDeviceActive(const AudioDevice& device,
                       bool* active,
                       bool* activate_by_user) override;
  void SetUserPriorityHigherThan(const AudioDevice& target,
                                 const AudioDevice* base) override;
  int32_t GetUserPriority(const AudioDevice& device) override;
  void DropLeastRecentlySeenDevices(
      const std::vector<AudioDevice>& connected_devices,
      size_t keep_devices) override;
  bool GetAudioOutputAllowedValue() const override;
  void AddAudioPrefObserver(AudioPrefObserver* observer) override;
  void RemoveAudioPrefObserver(AudioPrefObserver* observer) override;

  bool GetVoiceIsolationState() const override;
  void SetVoiceIsolationState(bool voice_isolation_state) override;

  uint32_t GetVoiceIsolationPreferredEffect() const override;
  void SetVoiceIsolationPreferredEffect(uint32_t effect) override;

  bool GetNoiseCancellationState() override;
  void SetNoiseCancellationState(bool noise_cancellation_state) override;

  bool GetStyleTransferState() const override;
  void SetStyleTransferState(bool style_transfer_state) override;

  void SetAudioOutputAllowedValue(bool is_audio_output_allowed);

  bool GetForceRespectUiGainsState() override;
  void SetForceRespectUiGainsState(bool force_respect_ui_gains) override;
  bool GetHfpMicSrState() override;
  void SetHfpMicSrState(bool hfp_mic_sr_state) override;
  bool GetSpatialAudioState() override;
  void SetSpatialAudioState(bool spatial_audio) override;

  const std::optional<uint64_t> GetPreferredDeviceFromPreferenceSet(
      bool is_input,
      const AudioDeviceList& devices) override;
  void UpdateDevicePreferenceSet(const AudioDeviceList& devices,
                                 const AudioDevice& preferred_device) override;

  const base::Value::List& GetMostRecentActivatedDeviceIdList(
      bool is_input) override;
  void UpdateMostRecentActivatedDeviceIdList(
      const AudioDevice& device) override;

  const AudioDevicePreferenceSetMap& GetDevicePreferenceSetMap();

 protected:
  ~AudioDevicesPrefHandlerStub() override;

 private:
  AudioDeviceMute audio_device_mute_map_;
  AudioDeviceVolumeGain audio_device_volume_gain_map_;
  AudioDeviceStateMap audio_device_state_map_;
  AudioDeviceUserPriority user_priority_map_;
  AudioDevicePreferenceSetMap device_preference_set_map_;
  MostRecentActivatedDeviceIdList most_recent_activated_device_id_list;

  base::ObserverList<AudioPrefObserver>::Unchecked observers_;

  bool is_audio_output_allowed_ = true;
  bool voice_isolation_state_ = false;
  uint32_t voice_isolation_preferred_effect_ = 0;
  bool force_respect_ui_gains_ = false;
  bool hfp_mic_sr_ = false;
  bool spatial_audio_ = false;
};

}  // namespace ash

#endif  // CHROMEOS_ASH_COMPONENTS_AUDIO_AUDIO_DEVICES_PREF_HANDLER_STUB_H_