OLD | NEW |
---|---|
(Empty) | |
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 | |
12 namespace chromeos { | |
13 | |
14 class AudioMixer { | |
15 public: | |
16 enum State { | |
17 UNINITIALIZED = 0, | |
18 INITIALIZING, | |
19 READY, | |
20 SHUTTING_DOWN, | |
21 IN_ERROR, | |
22 }; | |
23 | |
24 AudioMixer() {} | |
scherkus (not reviewing)
2011/01/11 00:24:12
don't inline ctors / dtors (might have to write a
davejcool
2011/01/11 02:52:54
The style guide says it is fine to inline virtual
| |
25 virtual ~AudioMixer() {} | |
26 | |
27 // Non-Blocking call. Connect to Mixer, find a default device, then call the | |
28 // callback when complete with success code. | |
29 typedef Callback1<bool>::Type InitDoneCallback; | |
30 virtual bool Init(InitDoneCallback* callback) = 0; | |
scherkus (not reviewing)
2011/01/11 00:24:12
I'm inclined to say either use the callback to rep
davejcool
2011/01/11 02:52:54
Thanks, done.
| |
31 | |
32 // Call may block. Mixer will be connected before returning, unless error. | |
33 virtual bool InitSync() = 0; | |
scherkus (not reviewing)
2011/01/11 00:24:12
we can consider deferring to a later change but I'
davejcool
2011/01/11 02:52:54
I like the idea- it would simplify the AudioMixer
| |
34 | |
35 // Call may block. Returns a default of kSilenceDb on error. | |
36 virtual double GetVolumeDb() const = 0; | |
37 | |
38 // Non-Blocking call. Returns the actual volume limits possible according | |
39 // to the mixer. Limits are left unchanged on error | |
40 virtual bool GetVolumeLimits(double* vol_min, double* vol_max) = 0; | |
41 | |
42 // Non-blocking call. | |
43 virtual void SetVolumeDb(double vol_db) = 0; | |
44 | |
45 // Call may block. Gets the mute state of the default device (true == mute). | |
46 // Returns a default of false on error. | |
47 virtual bool IsMute() const = 0; | |
48 | |
49 // Non-Blocking call. | |
50 virtual void SetMute(bool mute) = 0; | |
51 | |
52 // Returns READY if we have a valid working connection to the Mixer. | |
53 // This can return IN_ERROR if we lose the connection, even after an original | |
54 // successful init. Non-blocking call. | |
55 virtual State CheckState() const = 0; | |
scherkus (not reviewing)
2011/01/11 00:24:12
nit: I think this used to be called CheckState() b
davejcool
2011/01/11 02:52:54
Yes, GetState() Now makes more sense.
| |
56 | |
57 // Approximation of pure silence expressed in decibels. | |
58 static const double kSilenceDb = -200.0; | |
scherkus (not reviewing)
2011/01/11 00:24:12
constants at top of class declarations + move the
davejcool
2011/01/11 02:52:54
Moved to the top where it belongs. I've seen cons
| |
59 | |
60 private: | |
61 DISALLOW_COPY_AND_ASSIGN(AudioMixer); | |
62 }; | |
63 | |
64 } // namespace chromeos | |
65 | |
66 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_H_ | |
67 | |
OLD | NEW |