| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ | 5 #ifndef MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ |
| 6 #define MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ | 6 #define MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <set> |
| 9 |
| 8 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| 9 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 10 #include "media/audio/audio_manager_base.h" | 12 #include "media/audio/audio_manager_base.h" |
| 11 | 13 |
| 12 namespace media { | 14 namespace media { |
| 13 | 15 |
| 16 class OpenSLESOutputStream; |
| 17 |
| 14 // Android implemention of AudioManager. | 18 // Android implemention of AudioManager. |
| 15 class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase { | 19 class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase { |
| 16 public: | 20 public: |
| 17 AudioManagerAndroid(); | 21 AudioManagerAndroid(); |
| 18 | 22 |
| 19 // Implementation of AudioManager. | 23 // Implementation of AudioManager. |
| 20 virtual bool HasAudioOutputDevices() OVERRIDE; | 24 virtual bool HasAudioOutputDevices() OVERRIDE; |
| 21 virtual bool HasAudioInputDevices() OVERRIDE; | 25 virtual bool HasAudioInputDevices() OVERRIDE; |
| 22 virtual void GetAudioInputDeviceNames( | 26 virtual void GetAudioInputDeviceNames( |
| 23 AudioDeviceNames* device_names) OVERRIDE; | 27 AudioDeviceNames* device_names) OVERRIDE; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 45 const std::string& input_device_id) OVERRIDE; | 49 const std::string& input_device_id) OVERRIDE; |
| 46 virtual AudioInputStream* MakeLinearInputStream( | 50 virtual AudioInputStream* MakeLinearInputStream( |
| 47 const AudioParameters& params, | 51 const AudioParameters& params, |
| 48 const std::string& device_id) OVERRIDE; | 52 const std::string& device_id) OVERRIDE; |
| 49 virtual AudioInputStream* MakeLowLatencyInputStream( | 53 virtual AudioInputStream* MakeLowLatencyInputStream( |
| 50 const AudioParameters& params, | 54 const AudioParameters& params, |
| 51 const std::string& device_id) OVERRIDE; | 55 const std::string& device_id) OVERRIDE; |
| 52 | 56 |
| 53 static bool RegisterAudioManager(JNIEnv* env); | 57 static bool RegisterAudioManager(JNIEnv* env); |
| 54 | 58 |
| 59 void SetMute(JNIEnv* env, jobject obj, jboolean muted); |
| 60 |
| 55 protected: | 61 protected: |
| 56 virtual ~AudioManagerAndroid(); | 62 virtual ~AudioManagerAndroid(); |
| 57 | 63 |
| 58 virtual AudioParameters GetPreferredOutputStreamParameters( | 64 virtual AudioParameters GetPreferredOutputStreamParameters( |
| 59 const std::string& output_device_id, | 65 const std::string& output_device_id, |
| 60 const AudioParameters& input_params) OVERRIDE; | 66 const AudioParameters& input_params) OVERRIDE; |
| 61 | 67 |
| 62 private: | 68 private: |
| 63 void Init(); | 69 void Init(); |
| 64 void Close(); | 70 void Close(); |
| 65 void SetAudioMode(int mode); | 71 void SetAudioMode(int mode); |
| 66 void SetAudioDevice(const std::string& device_id); | 72 void SetAudioDevice(const std::string& device_id); |
| 67 int GetNativeOutputSampleRate(); | 73 int GetNativeOutputSampleRate(); |
| 68 bool IsAudioLowLatencySupported(); | 74 bool IsAudioLowLatencySupported(); |
| 69 int GetAudioLowLatencyOutputFrameSize(); | 75 int GetAudioLowLatencyOutputFrameSize(); |
| 70 int GetOptimalOutputFrameSize(int sample_rate, int channels); | 76 int GetOptimalOutputFrameSize(int sample_rate, int channels); |
| 71 | 77 |
| 78 void DoSetMuteOnAudioThread(bool muted); |
| 79 |
| 72 // Allow the AudioAndroidTest to access private methods. | 80 // Allow the AudioAndroidTest to access private methods. |
| 73 FRIEND_TEST_ALL_PREFIXES(AudioAndroidTest, IsAudioLowLatencySupported); | 81 FRIEND_TEST_ALL_PREFIXES(AudioAndroidTest, IsAudioLowLatencySupported); |
| 74 | 82 |
| 75 // Java AudioManager instance. | 83 // Java AudioManager instance. |
| 76 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_; | 84 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_; |
| 77 | 85 |
| 86 typedef std::set<OpenSLESOutputStream*> OutputStreams; |
| 87 OutputStreams streams_; |
| 88 |
| 78 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid); | 89 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid); |
| 79 }; | 90 }; |
| 80 | 91 |
| 81 } // namespace media | 92 } // namespace media |
| 82 | 93 |
| 83 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ | 94 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ |
| OLD | NEW |