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

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
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.
37 static void InitializeForTesting(AudioMixer* mixer);
Daniel Erat 2012/05/18 23:45:13 nit: mention that this takes ownership of |mixer|
Jun Mukai 2012/05/18 23:53:19 Done.
38
36 // GetInstance returns NULL if not initialized or if already shutdown. 39 // GetInstance returns NULL if not initialized or if already shutdown.
37 static AudioHandler* GetInstance(); 40 static AudioHandler* GetInstance();
38 41
39 // Registers volume and mute preferences. 42 // Registers volume and mute preferences.
40 static void RegisterPrefs(PrefService* local_state); 43 static void RegisterPrefs(PrefService* local_state);
41 44
42 // Gets volume level in our internal 0-100% range, 0 being pure silence. 45 // Gets volume level in our internal 0-100% range, 0 being pure silence.
43 double GetVolumePercent(); 46 double GetVolumePercent();
44 47
45 // Sets volume level from 0-100%. 48 // Sets volume level from 0-100%.
46 void SetVolumePercent(double volume_percent); 49 void SetVolumePercent(double volume_percent);
47 50
48 // Adjusts volume up (positive percentage) or down (negative percentage). 51 // Adjusts volume up (positive percentage) or down (negative percentage).
49 void AdjustVolumeByPercent(double adjust_by_percent); 52 void AdjustVolumeByPercent(double adjust_by_percent);
50 53
51 // Is the volume currently muted? 54 // Is the volume currently muted?
52 bool IsMuted(); 55 bool IsMuted();
53 56
54 // Mutes or unmutes all audio. 57 // Mutes or unmutes all audio.
55 void SetMuted(bool do_mute); 58 void SetMuted(bool do_mute);
56 59
57 void AddVolumeObserver(VolumeObserver* observer); 60 void AddVolumeObserver(VolumeObserver* observer);
58 void RemoveVolumeObserver(VolumeObserver* observer); 61 void RemoveVolumeObserver(VolumeObserver* observer);
59 62
60 private: 63 private:
61 // Defines the delete on exit Singleton traits we like. Best to have this 64 // Defines the delete on exit Singleton traits we like. Best to have this
62 // and constructor/destructor private as recommended for Singletons. 65 // and constructor/destructor private as recommended for Singletons.
63 friend struct DefaultSingletonTraits<AudioHandler>; 66 friend struct DefaultSingletonTraits<AudioHandler>;
64 67
65 AudioHandler(); 68 explicit AudioHandler(AudioMixer* mixer);
Daniel Erat 2012/05/18 23:45:13 nit: mention that this takes ownership of |mixer|
Jun Mukai 2012/05/18 23:53:19 Done.
66 virtual ~AudioHandler(); 69 virtual ~AudioHandler();
67 70
68 scoped_ptr<AudioMixer> mixer_; 71 scoped_ptr<AudioMixer> mixer_;
69 72
70 ObserverList<VolumeObserver> volume_observers_; 73 ObserverList<VolumeObserver> volume_observers_;
71 74
72 PrefService* prefs_; // not owned 75 PrefService* prefs_; // not owned
73 76
74 DISALLOW_COPY_AND_ASSIGN(AudioHandler); 77 DISALLOW_COPY_AND_ASSIGN(AudioHandler);
75 }; 78 };
76 79
77 } // namespace chromeos 80 } // namespace chromeos
78 81
79 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_ 82 #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') | chrome/browser/chromeos/audio/audio_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698