1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_
6 #define MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_
8 #include "base/android/jni_android.h"
9 #include "base/gtest_prod_util.h"
10 #include "media/audio/audio_manager_base.h"
14 // Android implemention of AudioManager.
15 class MEDIA_EXPORT AudioManagerAndroid
: public AudioManagerBase
{
17 AudioManagerAndroid();
19 // Implementation of AudioManager.
20 virtual bool HasAudioOutputDevices() OVERRIDE
;
21 virtual bool HasAudioInputDevices() OVERRIDE
;
22 virtual void GetAudioInputDeviceNames(
23 AudioDeviceNames
* device_names
) OVERRIDE
;
24 virtual void GetAudioOutputDeviceNames(
25 AudioDeviceNames
* device_names
) OVERRIDE
;
26 virtual AudioParameters
GetInputStreamParameters(
27 const std::string
& device_id
) OVERRIDE
;
29 virtual AudioOutputStream
* MakeAudioOutputStream(
30 const AudioParameters
& params
,
31 const std::string
& device_id
,
32 const std::string
& input_device_id
) OVERRIDE
;
33 virtual AudioInputStream
* MakeAudioInputStream(
34 const AudioParameters
& params
,
35 const std::string
& device_id
) OVERRIDE
;
36 virtual void ReleaseOutputStream(AudioOutputStream
* stream
) OVERRIDE
;
37 virtual void ReleaseInputStream(AudioInputStream
* stream
) OVERRIDE
;
39 // Implementation of AudioManagerBase.
40 virtual AudioOutputStream
* MakeLinearOutputStream(
41 const AudioParameters
& params
) OVERRIDE
;
42 virtual AudioOutputStream
* MakeLowLatencyOutputStream(
43 const AudioParameters
& params
,
44 const std::string
& device_id
,
45 const std::string
& input_device_id
) OVERRIDE
;
46 virtual AudioInputStream
* MakeLinearInputStream(
47 const AudioParameters
& params
,
48 const std::string
& device_id
) OVERRIDE
;
49 virtual AudioInputStream
* MakeLowLatencyInputStream(
50 const AudioParameters
& params
,
51 const std::string
& device_id
) OVERRIDE
;
53 static bool RegisterAudioManager(JNIEnv
* env
);
56 virtual ~AudioManagerAndroid();
58 virtual AudioParameters
GetPreferredOutputStreamParameters(
59 const std::string
& output_device_id
,
60 const AudioParameters
& input_params
) OVERRIDE
;
63 void SetAudioMode(int mode
);
64 void RegisterHeadsetReceiver();
65 void UnregisterHeadsetReceiver();
66 int GetNativeOutputSampleRate();
67 bool IsAudioLowLatencySupported();
68 int GetAudioLowLatencyOutputFrameSize();
69 int GetOptimalOutputFrameSize(int sample_rate
, int channels
);
71 // Allow the AudioAndroidTest to access private methods.
72 FRIEND_TEST_ALL_PREFIXES(AudioAndroidTest
, IsAudioLowLatencySupported
);
74 // Java AudioManager instance.
75 base::android::ScopedJavaGlobalRef
<jobject
> j_audio_manager_
;
77 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid
);
82 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_