1// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_H_
6#define CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_H_
7#pragma once
8
9#include "base/basictypes.h"
10#include "base/callback.h"
11
12namespace chromeos {
13
14class AudioMixer {
15 public:
16  // Approximation of pure silence expressed in decibels.
17  static const double kSilenceDb = -200.0;
18
19  enum State {
20    UNINITIALIZED = 0,
21    INITIALIZING,
22    READY,
23    SHUTTING_DOWN,
24    IN_ERROR,
25  };
26
27  AudioMixer() {}
28  virtual ~AudioMixer() {}
29
30  // Non-Blocking call.  Connect to Mixer, find a default device, then call the
31  // callback when complete with success code.
32  typedef Callback1<bool>::Type InitDoneCallback;
33  virtual void Init(InitDoneCallback* callback) = 0;
34
35  // Call may block.  Mixer will be connected before returning, unless error.
36  virtual bool InitSync() = 0;
37
38  // Call may block.  Returns a default of kSilenceDb on error.
39  virtual double GetVolumeDb() const = 0;
40
41  // Non-Blocking call.  Returns the actual volume limits possible according
42  // to the mixer.  Limits are left unchanged on error
43  virtual bool GetVolumeLimits(double* vol_min, double* vol_max) = 0;
44
45  // Non-blocking call.
46  virtual void SetVolumeDb(double vol_db) = 0;
47
48  // Call may block.  Gets the mute state of the default device (true == mute).
49  // Returns a default of false on error.
50  virtual bool IsMute() const = 0;
51
52  // Non-Blocking call.
53  virtual void SetMute(bool mute) = 0;
54
55  // Returns READY if we have a valid working connection to the Mixer.
56  // This can return IN_ERROR if we lose the connection, even after an original
57  // successful init.  Non-blocking call.
58  virtual State GetState() const = 0;
59
60 private:
61  DISALLOW_COPY_AND_ASSIGN(AudioMixer);
62};
63
64}  // namespace chromeos
65
66#endif  // CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_H_
67
68