dom/system/gonk/AudioManager.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:105c5d82b042
1 /* Copyright 2012 Mozilla Foundation and Mozilla contributors
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifndef mozilla_dom_system_b2g_audiomanager_h__
17 #define mozilla_dom_system_b2g_audiomanager_h__
18
19 #include "mozilla/Observer.h"
20 #include "nsAutoPtr.h"
21 #include "nsIAudioManager.h"
22 #include "nsIObserver.h"
23 #include "AudioChannelAgent.h"
24 #include "android_audio/AudioSystem.h"
25
26 // {b2b51423-502d-4d77-89b3-7786b562b084}
27 #define NS_AUDIOMANAGER_CID {0x94f6fd70, 0x7615, 0x4af9, \
28 {0x89, 0x10, 0xf9, 0x3c, 0x55, 0xe6, 0x62, 0xec}}
29 #define NS_AUDIOMANAGER_CONTRACTID "@mozilla.org/telephony/audiomanager;1"
30
31 namespace mozilla {
32 namespace hal {
33 class SwitchEvent;
34 typedef Observer<SwitchEvent> SwitchObserver;
35 } // namespace hal
36
37 namespace dom {
38 namespace gonk {
39 class RecoverTask;
40 class AudioChannelVolInitCallback;
41 class AudioManager : public nsIAudioManager
42 , public nsIObserver
43 {
44 public:
45 NS_DECL_ISUPPORTS
46 NS_DECL_NSIAUDIOMANAGER
47 NS_DECL_NSIOBSERVER
48
49 AudioManager();
50 ~AudioManager();
51
52 // When audio backend is dead, recovery task needs to read all volume
53 // settings then set back into audio backend.
54 friend class RecoverTask;
55 friend class AudioChannelVolInitCallback;
56
57 protected:
58 int32_t mPhoneState;
59 int mCurrentStreamVolumeTbl[AUDIO_STREAM_CNT];
60
61 nsresult SetStreamVolumeIndex(int32_t aStream, int32_t aIndex);
62 nsresult GetStreamVolumeIndex(int32_t aStream, int32_t *aIndex);
63
64 private:
65 nsAutoPtr<mozilla::hal::SwitchObserver> mObserver;
66 nsCOMPtr<nsIAudioChannelAgent> mPhoneAudioAgent;
67 #ifdef MOZ_B2G_RIL
68 bool mMuteCallToRIL;
69 // mIsMicMuted is only used for toggling mute call to RIL.
70 bool mIsMicMuted;
71 #endif
72
73 void HandleBluetoothStatusChanged(nsISupports* aSubject,
74 const char* aTopic,
75 const nsCString aAddress);
76 };
77
78 } /* namespace gonk */
79 } /* namespace dom */
80 } /* namespace mozilla */
81
82 #endif // mozilla_dom_system_b2g_audiomanager_h__

mercurial