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

Side by Side Diff: chrome/browser/chromeos/audio_mixer_alsa.h

Issue 6118006: Save/Restore ALSA volume/mute (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos
Patch Set: responded to comments Created 9 years, 11 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) 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_MIXER_ALSA_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_ALSA_H_
6 #define CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_ALSA_H_ 6 #define CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_ALSA_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/lock.h" 11 #include "base/lock.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "chrome/browser/chromeos/audio_mixer.h" 14 #include "chrome/browser/chromeos/audio_mixer.h"
15 #include "chrome/browser/prefs/pref_member.h"
15 16
16 struct _snd_mixer_elem; 17 struct _snd_mixer_elem;
17 struct _snd_mixer; 18 struct _snd_mixer;
18 19
19 namespace chromeos { 20 namespace chromeos {
20 21
21 class AudioMixerAlsa : public AudioMixer { 22 class AudioMixerAlsa : public AudioMixer {
22 public: 23 public:
23 AudioMixerAlsa(); 24 AudioMixerAlsa();
24 virtual ~AudioMixerAlsa(); 25 virtual ~AudioMixerAlsa();
25 26
26 // Implementation of AudioMixer 27 // Implementation of AudioMixer
27 virtual void Init(InitDoneCallback* callback); 28 virtual void Init(InitDoneCallback* callback);
28 virtual bool InitSync(); 29 virtual bool InitSync();
29 virtual double GetVolumeDb() const; 30 virtual double GetVolumeDb() const;
30 virtual bool GetVolumeLimits(double* vol_min, double* vol_max); 31 virtual bool GetVolumeLimits(double* vol_min, double* vol_max);
31 virtual void SetVolumeDb(double vol_db); 32 virtual void SetVolumeDb(double vol_db);
32 virtual bool IsMute() const; 33 virtual bool IsMute() const;
33 virtual void SetMute(bool mute); 34 virtual void SetMute(bool mute);
34 virtual State GetState() const; 35 virtual State GetState() const;
35 36
36 private: 37 private:
37 // Called to do initialization in background from worker thread. 38 // Called to do initialization in background from worker thread.
38 void DoInit(InitDoneCallback* callback); 39 void DoInit(InitDoneCallback* callback);
39 40
40 // Helper function to just get our message loop thread going. 41 // Helper functions to get our message loop thread and prefs initialized.
41 bool InitThread(); 42 bool InitThread();
43 void InitPrefs();
42 44
43 // Try to connect to the ALSA mixer through their simple controls interface, 45 // Try to connect to the ALSA mixer through their simple controls interface,
44 // and cache mixer handle and mixer elements we'll be using. 46 // and cache mixer handle and mixer elements we'll be using.
45 bool InitializeAlsaMixer(); 47 bool InitializeAlsaMixer();
46 void FreeAlsaMixer(); 48 void FreeAlsaMixer();
49 void DoSetVolumeMute(double volume, bool mute);
50
51 // Access to PrefMember variables must be done on UI thread.
52 void RestoreVolumeMuteOnUIThread();
47 53
48 // All these internal volume commands must be called with the lock held. 54 // All these internal volume commands must be called with the lock held.
49 double DoGetVolumeDb_Locked() const; 55 double DoGetVolumeDb_Locked() const;
50 void DoSetVolumeDb_Locked(double vol_db); 56 void DoSetVolumeDb_Locked(double vol_db);
51 57
52 _snd_mixer_elem* FindElementWithName_Locked(_snd_mixer* handle, 58 _snd_mixer_elem* FindElementWithName_Locked(_snd_mixer* handle,
53 const char* element_name) const; 59 const char* element_name) const;
54 60
55 bool GetElementVolume_Locked(_snd_mixer_elem* elem, 61 bool GetElementVolume_Locked(_snd_mixer_elem* elem,
56 double* current_vol) const; 62 double* current_vol) const;
(...skipping 23 matching lines...) Expand all
80 double save_volume_; 86 double save_volume_;
81 87
82 mutable Lock mixer_state_lock_; 88 mutable Lock mixer_state_lock_;
83 mutable State mixer_state_; 89 mutable State mixer_state_;
84 90
85 // Cached contexts for use in ALSA calls. 91 // Cached contexts for use in ALSA calls.
86 _snd_mixer* alsa_mixer_; 92 _snd_mixer* alsa_mixer_;
87 _snd_mixer_elem* elem_master_; 93 _snd_mixer_elem* elem_master_;
88 _snd_mixer_elem* elem_pcm_; 94 _snd_mixer_elem* elem_pcm_;
89 95
96 BooleanPrefMember mute_pref_;
97 RealPrefMember volume_pref_;
98
90 scoped_ptr<base::Thread> thread_; 99 scoped_ptr<base::Thread> thread_;
91 100
92 DISALLOW_COPY_AND_ASSIGN(AudioMixerAlsa); 101 DISALLOW_COPY_AND_ASSIGN(AudioMixerAlsa);
93 }; 102 };
94 103
95 } // namespace chromeos 104 } // namespace chromeos
96 105
97 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::AudioMixerAlsa); 106 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::AudioMixerAlsa);
98 107
99 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_ALSA_H_ 108 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_MIXER_ALSA_H_
100 109
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/audio_mixer_alsa.cc » ('j') | chrome/browser/chromeos/audio_mixer_alsa.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698