Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1471)

Side by Side Diff: chrome/browser/chromeos/audio/audio_handler.h

Issue 9310018: Revert 119948 - Support for showing/hiding status area volume controls in desktop devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/audio/audio_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_AUDIO_HANDLER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ 6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/observer_list.h"
11 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread.h" 11 #include "base/threading/thread.h"
13 12
14 template <typename T> struct DefaultSingletonTraits; 13 template <typename T> struct DefaultSingletonTraits;
15 14
16 namespace chromeos { 15 namespace chromeos {
17 16
18 class AudioMixer; 17 class AudioMixer;
19 18
20 class AudioHandler { 19 class AudioHandler {
21 public: 20 public:
22 class VolumeObserver {
23 public:
24 virtual void OnVolumeChanged() = 0;
25 protected:
26 VolumeObserver() {}
27 virtual ~VolumeObserver() {}
28 DISALLOW_COPY_AND_ASSIGN(VolumeObserver);
29 };
30
31 static void Initialize(); 21 static void Initialize();
32 static void Shutdown(); 22 static void Shutdown();
33 // GetInstance returns NULL if not initialized or if already shutdown. 23 // GetInstance returns NULL if not initialized or if already shutdown.
34 // The mixer may be uninitialized, so use GetInstanceIfInitialized
35 // for volume control until the TODO below is resolved.
36 static AudioHandler* GetInstance(); 24 static AudioHandler* GetInstance();
37 25
38 // GetInstanceIfInitialized returns NULL if GetInstance returns NULL or if 26 // Is the mixer initialized?
39 // the mixer has not finished initializing.
40 // TODO(derat): All of the volume-percent methods will produce "interesting" 27 // TODO(derat): All of the volume-percent methods will produce "interesting"
41 // results before the mixer is initialized, since the driver's volume range 28 // results before the mixer is initialized, since the driver's volume range
42 // isn't known at that point. This could be avoided if AudioMixer objects 29 // isn't known at that point. This could be avoided if AudioMixer objects
43 // instead took percentages and did their own conversions to decibels. 30 // instead took percentages and did their own conversions to decibels.
44 static AudioHandler* GetInstanceIfInitialized(); 31 bool IsInitialized();
45 32
46 // Gets volume level in our internal 0-100% range, 0 being pure silence. 33 // Gets volume level in our internal 0-100% range, 0 being pure silence.
47 double GetVolumePercent(); 34 double GetVolumePercent();
48 35
49 // Sets volume level from 0-100%. 36 // Sets volume level from 0-100%.
50 void SetVolumePercent(double volume_percent); 37 void SetVolumePercent(double volume_percent);
51 38
52 // Adjusts volume up (positive percentage) or down (negative percentage). 39 // Adjusts volume up (positive percentage) or down (negative percentage).
53 void AdjustVolumeByPercent(double adjust_by_percent); 40 void AdjustVolumeByPercent(double adjust_by_percent);
54 41
55 // Is the volume currently muted? 42 // Is the volume currently muted?
56 bool IsMuted(); 43 bool IsMuted();
57 44
58 // Mutes or unmutes all audio. 45 // Mutes or unmutes all audio.
59 void SetMuted(bool do_mute); 46 void SetMuted(bool do_mute);
60 47
61 void AddVolumeObserver(VolumeObserver* observer);
62 void RemoveVolumeObserver(VolumeObserver* observer);
63
64 private: 48 private:
65 // 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
66 // and constructor/destructor private as recommended for Singletons. 50 // and constructor/destructor private as recommended for Singletons.
67 friend struct DefaultSingletonTraits<AudioHandler>; 51 friend struct DefaultSingletonTraits<AudioHandler>;
68 52
69 AudioHandler(); 53 AudioHandler();
70 virtual ~AudioHandler(); 54 virtual ~AudioHandler();
71 55
72 bool IsMixerInitialized();
73
74 // Conversion between our internal scaling (0-100%) and decibels. 56 // Conversion between our internal scaling (0-100%) and decibels.
75 double VolumeDbToPercent(double volume_db) const; 57 double VolumeDbToPercent(double volume_db) const;
76 double PercentToVolumeDb(double volume_percent) const; 58 double PercentToVolumeDb(double volume_percent) const;
77 59
78 scoped_ptr<AudioMixer> mixer_; 60 scoped_ptr<AudioMixer> mixer_;
79 61
80 ObserverList<VolumeObserver> volume_observers_;
81
82 DISALLOW_COPY_AND_ASSIGN(AudioHandler); 62 DISALLOW_COPY_AND_ASSIGN(AudioHandler);
83 }; 63 };
84 64
85 } // namespace chromeos 65 } // namespace chromeos
86 66
87 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ 67 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/audio/audio_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698