2012-07-20 02:10:44 -07: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 10:22:26 -08:00
|
|
|
|
|
|
|
#ifndef mozilla_dom_system_b2g_audiomanager_h__
|
|
|
|
#define mozilla_dom_system_b2g_audiomanager_h__
|
|
|
|
|
2012-04-22 11:14:36 -07:00
|
|
|
#include "mozilla/Observer.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2011-12-12 10:22:26 -08:00
|
|
|
#include "nsIAudioManager.h"
|
2012-09-29 02:39:05 -07:00
|
|
|
#include "nsIObserver.h"
|
2012-12-12 17:45:10 -08:00
|
|
|
#include "AudioChannelAgent.h"
|
2013-05-15 21:00:02 -07:00
|
|
|
#include "android_audio/AudioSystem.h"
|
2011-12-12 10:22:26 -08: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"
|
|
|
|
|
2012-12-12 17:45:10 -08:00
|
|
|
using namespace mozilla::dom;
|
2012-04-22 11:14:36 -07:00
|
|
|
|
2011-12-12 10:22:26 -08:00
|
|
|
namespace mozilla {
|
2012-04-22 11:14:36 -07:00
|
|
|
namespace hal {
|
|
|
|
class SwitchEvent;
|
|
|
|
typedef Observer<SwitchEvent> SwitchObserver;
|
|
|
|
} // namespace hal
|
|
|
|
|
2011-12-12 10:22:26 -08:00
|
|
|
namespace dom {
|
2012-03-14 15:43:26 -07:00
|
|
|
namespace gonk {
|
2013-07-17 22:22:36 -07:00
|
|
|
class RecoverTask;
|
2011-12-12 10:22:26 -08:00
|
|
|
class AudioManager : public nsIAudioManager
|
2012-09-29 02:39:05 -07:00
|
|
|
, public nsIObserver
|
2011-12-12 10:22:26 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIAUDIOMANAGER
|
2012-09-29 02:39:05 -07:00
|
|
|
NS_DECL_NSIOBSERVER
|
2011-12-12 10:22:26 -08:00
|
|
|
|
2012-04-22 11:14:36 -07:00
|
|
|
AudioManager();
|
|
|
|
~AudioManager();
|
2011-12-12 10:22:26 -08:00
|
|
|
|
2013-07-17 22:22:36 -07:00
|
|
|
// When audio backend is dead, recovery task needs to read all volume
|
|
|
|
// settings then set back into audio backend.
|
|
|
|
friend class RecoverTask;
|
|
|
|
|
2011-12-12 10:22:26 -08:00
|
|
|
protected:
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mPhoneState;
|
2013-05-15 21:00:02 -07:00
|
|
|
int mCurrentStreamVolumeTbl[AUDIO_STREAM_CNT];
|
2011-12-12 10:22:26 -08:00
|
|
|
|
2013-07-17 22:22:36 -07:00
|
|
|
android::status_t SetStreamVolumeIndex(int32_t aStream, int32_t aIndex);
|
|
|
|
android::status_t GetStreamVolumeIndex(int32_t aStream, int32_t *aIndex);
|
|
|
|
|
2012-04-22 11:14:36 -07:00
|
|
|
private:
|
|
|
|
nsAutoPtr<mozilla::hal::SwitchObserver> mObserver;
|
2012-12-12 17:45:10 -08:00
|
|
|
nsCOMPtr<AudioChannelAgent> mPhoneAudioAgent;
|
2013-07-29 23:58:58 -07:00
|
|
|
|
|
|
|
void HandleBluetoothStatusChanged(nsISupports* aSubject,
|
|
|
|
const char* aTopic,
|
|
|
|
const nsCString aAddress);
|
2012-04-22 11:14:36 -07:00
|
|
|
};
|
2011-12-12 10:22:26 -08:00
|
|
|
|
2012-04-22 11:14:36 -07:00
|
|
|
} /* namespace gonk */
|
2011-12-12 10:22:26 -08:00
|
|
|
} /* namespace dom */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif // mozilla_dom_system_b2g_audiomanager_h__
|