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