OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_HANDLER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_AUDIO_HANDLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_AUDIO_HANDLER_H_ |
7 | 7 |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 // blocking call. | 34 // blocking call. |
35 void AdjustVolumeByPercent(double adjust_by_percent); | 35 void AdjustVolumeByPercent(double adjust_by_percent); |
36 | 36 |
37 // Just returns true if mute, false if not or an error occurred. | 37 // Just returns true if mute, false if not or an error occurred. |
38 // Blocking call. | 38 // Blocking call. |
39 bool IsMute(); | 39 bool IsMute(); |
40 | 40 |
41 // Mutes all audio. Non-blocking call. | 41 // Mutes all audio. Non-blocking call. |
42 void SetMute(bool do_mute); | 42 void SetMute(bool do_mute); |
43 | 43 |
| 44 // AudioHandler is a singleton initialized at startup. Use this to determine |
| 45 // if there is a valid connection to a mixer. |
| 46 bool IsValid(); |
| 47 |
44 private: | 48 private: |
45 // Defines the delete on exit Singleton traits we like. Best to have this | 49 // Defines the delete on exit Singleton traits we like. Best to have this |
46 // and constructor/destructor private as recommended for Singletons. | 50 // and constructor/destructor private as recommended for Singletons. |
47 friend struct DefaultSingletonTraits<AudioHandler>; | 51 friend struct DefaultSingletonTraits<AudioHandler>; |
48 | 52 |
49 void OnMixerInitialized(bool success); | |
50 | |
51 AudioHandler(); | 53 AudioHandler(); |
52 virtual ~AudioHandler(); | 54 virtual ~AudioHandler(); |
53 bool VerifyMixerConnection(); | 55 bool VerifyMixerConnection(); |
54 | 56 |
55 // Conversion between our internal scaling (0-100%) and decibels. | 57 // Conversion between our internal scaling (0-100%) and decibels. |
56 static double VolumeDbToPercent(double volume_db); | 58 static double VolumeDbToPercent(double volume_db); |
57 static double PercentToVolumeDb(double volume_percent); | 59 static double PercentToVolumeDb(double volume_percent); |
58 | 60 |
59 scoped_ptr<PulseAudioMixer> mixer_; | 61 scoped_ptr<PulseAudioMixer> mixer_; |
60 bool connected_; | 62 bool connected_; |
61 int reconnect_tries_; | 63 int reconnect_tries_; |
62 | 64 |
63 DISALLOW_COPY_AND_ASSIGN(AudioHandler); | 65 DISALLOW_COPY_AND_ASSIGN(AudioHandler); |
64 }; | 66 }; |
65 | 67 |
66 } // namespace chromeos | 68 } // namespace chromeos |
67 | 69 |
68 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_HANDLER_H_ | 70 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_HANDLER_H_ |
69 | 71 |
OLD | NEW |