blob: 27027f4d949d3a6ad8f00f3062eeaf1ccd4cc75f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
#pragma once
#include "base/basictypes.h"
#include "base/observer_list.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread.h"
template <typename T> struct DefaultSingletonTraits;
class PrefService;
namespace chromeos {
class AudioMixer;
class AudioHandler {
public:
class VolumeObserver {
public:
virtual void OnVolumeChanged() = 0;
protected:
VolumeObserver() {}
virtual ~VolumeObserver() {}
DISALLOW_COPY_AND_ASSIGN(VolumeObserver);
};
static void Initialize();
static void Shutdown();
// GetInstance returns NULL if not initialized or if already shutdown.
static AudioHandler* GetInstance();
// Registers volume and mute preferences.
static void RegisterPrefs(PrefService* local_state);
// Gets volume level in our internal 0-100% range, 0 being pure silence.
double GetVolumePercent();
// Sets volume level from 0-100%.
void SetVolumePercent(double volume_percent);
// Adjusts volume up (positive percentage) or down (negative percentage).
void AdjustVolumeByPercent(double adjust_by_percent);
// Is the volume currently muted?
bool IsMuted();
// Mutes or unmutes all audio.
void SetMuted(bool do_mute);
void AddVolumeObserver(VolumeObserver* observer);
void RemoveVolumeObserver(VolumeObserver* observer);
private:
// Defines the delete on exit Singleton traits we like. Best to have this
// and constructor/destructor private as recommended for Singletons.
friend struct DefaultSingletonTraits<AudioHandler>;
AudioHandler();
virtual ~AudioHandler();
scoped_ptr<AudioMixer> mixer_;
ObserverList<VolumeObserver> volume_observers_;
PrefService* prefs_; // not owned
DISALLOW_COPY_AND_ASSIGN(AudioHandler);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_HANDLER_H_
|