2012-07-20 09:10:44 +00:00
|
|
|
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2011-12-12 18:22:26 +00:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_system_b2g_audiomanager_h__
|
|
|
|
#define mozilla_dom_system_b2g_audiomanager_h__
|
|
|
|
|
2012-04-22 18:14:36 +00:00
|
|
|
#include "mozilla/Observer.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2011-12-12 18:22:26 +00:00
|
|
|
#include "nsIAudioManager.h"
|
2012-09-29 09:39:05 +00:00
|
|
|
#include "nsIObserver.h"
|
2012-12-13 01:45:10 +00:00
|
|
|
#include "AudioChannelAgent.h"
|
2013-05-16 04:00:02 +00:00
|
|
|
#include "android_audio/AudioSystem.h"
|
2011-12-12 18:22:26 +00:00
|
|
|
|
|
|
|
// {b2b51423-502d-4d77-89b3-7786b562b084}
|
|
|
|
#define NS_AUDIOMANAGER_CID {0x94f6fd70, 0x7615, 0x4af9, \
|
|
|
|
{0x89, 0x10, 0xf9, 0x3c, 0x55, 0xe6, 0x62, 0xec}}
|
|
|
|
#define NS_AUDIOMANAGER_CONTRACTID "@mozilla.org/telephony/audiomanager;1"
|
|
|
|
|
|
|
|
namespace mozilla {
|
2012-04-22 18:14:36 +00:00
|
|
|
namespace hal {
|
|
|
|
class SwitchEvent;
|
|
|
|
typedef Observer<SwitchEvent> SwitchObserver;
|
|
|
|
} // namespace hal
|
|
|
|
|
2011-12-12 18:22:26 +00:00
|
|
|
namespace dom {
|
2012-03-14 22:43:26 +00:00
|
|
|
namespace gonk {
|
2013-07-18 05:22:36 +00:00
|
|
|
class RecoverTask;
|
2013-08-23 03:29:11 +00:00
|
|
|
class AudioChannelVolInitCallback;
|
2014-11-24 23:38:23 +00:00
|
|
|
class AudioManager MOZ_FINAL : public nsIAudioManager
|
|
|
|
, public nsIObserver
|
2011-12-12 18:22:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-05-28 06:19:22 +00:00
|
|
|
static already_AddRefed<AudioManager> GetInstance();
|
|
|
|
|
2011-12-12 18:22:26 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIAUDIOMANAGER
|
2012-09-29 09:39:05 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2011-12-12 18:22:26 +00:00
|
|
|
|
2013-07-18 05:22:36 +00:00
|
|
|
// When audio backend is dead, recovery task needs to read all volume
|
|
|
|
// settings then set back into audio backend.
|
|
|
|
friend class RecoverTask;
|
2013-08-23 03:29:11 +00:00
|
|
|
friend class AudioChannelVolInitCallback;
|
2013-07-18 05:22:36 +00:00
|
|
|
|
2011-12-12 18:22:26 +00:00
|
|
|
protected:
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mPhoneState;
|
2013-05-16 04:00:02 +00:00
|
|
|
int mCurrentStreamVolumeTbl[AUDIO_STREAM_CNT];
|
2011-12-12 18:22:26 +00:00
|
|
|
|
2013-11-22 07:20:25 +00:00
|
|
|
nsresult SetStreamVolumeIndex(int32_t aStream, int32_t aIndex);
|
|
|
|
nsresult GetStreamVolumeIndex(int32_t aStream, int32_t *aIndex);
|
2013-07-18 05:22:36 +00:00
|
|
|
|
2012-04-22 18:14:36 +00:00
|
|
|
private:
|
|
|
|
nsAutoPtr<mozilla::hal::SwitchObserver> mObserver;
|
2014-04-03 22:06:26 +00:00
|
|
|
nsCOMPtr<nsIAudioChannelAgent> mPhoneAudioAgent;
|
2013-12-04 06:57:40 +00:00
|
|
|
#ifdef MOZ_B2G_RIL
|
2013-11-27 07:46:27 +00:00
|
|
|
bool mMuteCallToRIL;
|
|
|
|
// mIsMicMuted is only used for toggling mute call to RIL.
|
|
|
|
bool mIsMicMuted;
|
2013-12-04 06:57:40 +00:00
|
|
|
#endif
|
2013-07-30 06:58:58 +00:00
|
|
|
|
|
|
|
void HandleBluetoothStatusChanged(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
|
|
|
const nsCString aAddress);
|
2014-05-29 07:20:42 +00:00
|
|
|
void HandleAudioChannelProcessChanged();
|
2014-05-28 06:19:22 +00:00
|
|
|
|
|
|
|
AudioManager();
|
|
|
|
~AudioManager();
|
2012-04-22 18:14:36 +00:00
|
|
|
};
|
2011-12-12 18:22:26 +00:00
|
|
|
|
2012-04-22 18:14:36 +00:00
|
|
|
} /* namespace gonk */
|
2011-12-12 18:22:26 +00:00
|
|
|
} /* namespace dom */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif // mozilla_dom_system_b2g_audiomanager_h__
|