summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/audio_dsp_client.h
blob: 5db7880c120db862ef39b774e974cbeada33cc4d (plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_DBUS_AUDIO_DSP_CLIENT_H_
#define CHROMEOS_DBUS_AUDIO_DSP_CLIENT_H_

#include <stdint.h>

#include "base/macros.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client.h"
#include "chromeos/dbus/dbus_method_call_status.h"

namespace chromeos {

// A DBus client class for the org.chromium.AudioDsp service.
class CHROMEOS_EXPORT AudioDspClient : public DBusClient {
 public:
  // A callback to handle responses of methods returning a double value.
  typedef base::Callback<void(DBusMethodCallStatus call_status, double result)>
      DoubleDBusMethodCallback;

  // A callback to handle responses of methods returning two string values.
  typedef base::Callback<void(DBusMethodCallStatus call_status,
                              const std::string& result1,
                              const std::string& result2)>
      TwoStringDBusMethodCallback;

  // A callback to handle responses of methods returning three string values.
  typedef base::Callback<void(DBusMethodCallStatus call_status,
                              const std::string& result1,
                              const std::string& result2,
                              const std::string& result3)>
      ThreeStringDBusMethodCallback;

  // Interface for observing DSP events from a DSP client.
  class Observer {
   public:
    virtual ~Observer() {}

    // Called when the Error signal is received.
    virtual void OnError(int32_t error_code) = 0;
  };

  ~AudioDspClient() override;

  // Adds and removes observers for AUDIO_DSP events.
  virtual void AddObserver(Observer* observer) = 0;
  virtual void RemoveObserver(Observer* observer) = 0;

  // Factory function; creates a new instance which is owned by the caller.
  // For normal usage, access the singleton via DBusThreadManager::Get().
  static AudioDspClient* Create();

  // Calls Initialize method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded, and a bool that is the return value from
  // the DBus method.
  virtual void Initialize(const BoolDBusMethodCallback& callback) = 0;

  // Calls SetStandbyMode method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded.
  virtual void SetStandbyMode(bool standby,
                              const VoidDBusMethodCallback& callback) = 0;

  // Calls SetNightMode method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded.
  virtual void SetNightMode(bool night_mode,
                            const VoidDBusMethodCallback& callback) = 0;

  // Calls GetNightMode method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded, and a bool that is the return value from
  // the DBus method.
  virtual void GetNightMode(const BoolDBusMethodCallback& callback) = 0;

  // Calls SetTreble method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded.
  virtual void SetTreble(double db_fs,
                         const VoidDBusMethodCallback& callback) = 0;

  // Calls GetTreble method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded, and a double that is the return value from
  // the DBus method.
  virtual void GetTreble(const DoubleDBusMethodCallback& callback) = 0;

  // Calls SetBass method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded.
  virtual void SetBass(double db_fs,
                       const VoidDBusMethodCallback& callback) = 0;

  // Calls SetBass method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded, and a double that is the return value from
  // the DBus method.
  virtual void GetBass(const DoubleDBusMethodCallback& callback) = 0;

  // Calls GetCapabilitiesOEM method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded, and three std::strings that constitute
  // the return value from the DBus method.
  virtual void GetCapabilitiesOEM(
      const ThreeStringDBusMethodCallback& callback) = 0;

  // Calls SetCapabilitiesOEM method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded.
  virtual void SetCapabilitiesOEM(uint32_t speaker_id,
                                  const std::string& speaker_capabilities,
                                  const std::string& driver_capabilities,
                                  const VoidDBusMethodCallback& callback) = 0;

  // Calls GetFilterConfigOEM method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded, and two std::strings that constitute
  // the return value from the DBus method.
  virtual void GetFilterConfigOEM(
      uint32_t speaker_id,
      const TwoStringDBusMethodCallback& callback) = 0;

  // Calls SetFilterConfigOEM method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded.
  virtual void SetFilterConfigOEM(const std::string& speaker_config,
                                  const std::string& driver_config,
                                  const VoidDBusMethodCallback& callback) = 0;

  // Calls SetSourceType method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded.
  virtual void SetSourceType(uint16_t source_type,
                             const VoidDBusMethodCallback& callback) = 0;

  // Calls AmplifierVolumeChanged method.
  // |callback| will be called with a DBusMethodCallStatus indicating whether
  // the DBus method call succeeded.
  virtual void AmplifierVolumeChanged(
      double db_spl,
      const VoidDBusMethodCallback& callback) = 0;

 protected:
  // Create() should be used instead.
  AudioDspClient();

 private:
  DISALLOW_COPY_AND_ASSIGN(AudioDspClient);
};

}  // namespace chromeos

#endif  // CHROMEOS_DBUS_AUDIO_DSP_CLIENT_H_