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

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

Issue 10411028: Fix the volume controlling behaviors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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" 10 #include "base/observer_list.h"
(...skipping 15 matching lines...) Expand all
26 virtual void OnVolumeChanged() = 0; 26 virtual void OnVolumeChanged() = 0;
27 protected: 27 protected:
28 VolumeObserver() {} 28 VolumeObserver() {}
29 virtual ~VolumeObserver() {} 29 virtual ~VolumeObserver() {}
30 DISALLOW_COPY_AND_ASSIGN(VolumeObserver); 30 DISALLOW_COPY_AND_ASSIGN(VolumeObserver);
31 }; 31 };
32 32
33 static void Initialize(); 33 static void Initialize();
34 static void Shutdown(); 34 static void Shutdown();
35 35
36 // Same as Initialize but using the specified audio mixer. It takes
37 // ownership of |mixer|.
38 static void InitializeForTesting(AudioMixer* mixer);
39
36 // GetInstance returns NULL if not initialized or if already shutdown. 40 // GetInstance returns NULL if not initialized or if already shutdown.
37 static AudioHandler* GetInstance(); 41 static AudioHandler* GetInstance();
38 42
39 // Registers volume and mute preferences. 43 // Registers volume and mute preferences.
40 static void RegisterPrefs(PrefService* local_state); 44 static void RegisterPrefs(PrefService* local_state);
41 45
42 // Gets volume level in our internal 0-100% range, 0 being pure silence. 46 // Gets volume level in our internal 0-100% range, 0 being pure silence.
43 double GetVolumePercent(); 47 double GetVolumePercent();
44 48
45 // Sets volume level from 0-100%. 49 // Sets volume level from 0-100%.
46 void SetVolumePercent(double volume_percent); 50 void SetVolumePercent(double volume_percent);
47 51
48 // Adjusts volume up (positive percentage) or down (negative percentage). 52 // Adjusts volume up (positive percentage) or down (negative percentage).
49 void AdjustVolumeByPercent(double adjust_by_percent); 53 void AdjustVolumeByPercent(double adjust_by_percent);
50 54
51 // Is the volume currently muted? 55 // Is the volume currently muted?
52 bool IsMuted(); 56 bool IsMuted();
53 57
54 // Mutes or unmutes all audio. 58 // Mutes or unmutes all audio.
55 void SetMuted(bool do_mute); 59 void SetMuted(bool do_mute);
56 60
57 void AddVolumeObserver(VolumeObserver* observer); 61 void AddVolumeObserver(VolumeObserver* observer);
58 void RemoveVolumeObserver(VolumeObserver* observer); 62 void RemoveVolumeObserver(VolumeObserver* observer);
59 63
60 private: 64 private:
61 // Defines the delete on exit Singleton traits we like. Best to have this 65 // Defines the delete on exit Singleton traits we like. Best to have this
62 // and constructor/destructor private as recommended for Singletons. 66 // and constructor/destructor private as recommended for Singletons.
63 friend struct DefaultSingletonTraits<AudioHandler>; 67 friend struct DefaultSingletonTraits<AudioHandler>;
64 68
65 AudioHandler(); 69 // Takes ownership of |mixer|.
70 explicit AudioHandler(AudioMixer* mixer);
66 virtual ~AudioHandler(); 71 virtual ~AudioHandler();
67 72
68 scoped_ptr<AudioMixer> mixer_; 73 scoped_ptr<AudioMixer> mixer_;
69 74
70 ObserverList<VolumeObserver> volume_observers_; 75 ObserverList<VolumeObserver> volume_observers_;
71 76
72 PrefService* prefs_; // not owned 77 PrefService* prefs_; // not owned
73 78
74 DISALLOW_COPY_AND_ASSIGN(AudioHandler); 79 DISALLOW_COPY_AND_ASSIGN(AudioHandler);
75 }; 80 };
76 81
77 } // namespace chromeos 82 } // namespace chromeos
78 83
79 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ 84 #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