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> | 8 #include <set> |
9 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 #include "base/synchronization/waitable_event.h" | |
13 #include "media/audio/audio_manager_base.h" | 14 #include "media/audio/audio_manager_base.h" |
14 | 15 |
15 namespace media { | 16 namespace media { |
16 | 17 |
17 class OpenSLESOutputStream; | 18 class OpenSLESOutputStream; |
18 | 19 |
19 // Android implemention of AudioManager. | 20 // Android implemention of AudioManager. |
20 class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase { | 21 class MEDIA_EXPORT AudioManagerAndroid |
DaleCurtis
2014/02/19 19:10:16
One line.
henrika (OOO until Aug 14)
2014/02/21 11:46:16
Done.
| |
22 : public AudioManagerBase { | |
21 public: | 23 public: |
22 AudioManagerAndroid(AudioLogFactory* audio_log_factory); | 24 AudioManagerAndroid(AudioLogFactory* audio_log_factory); |
23 | 25 |
24 // Implementation of AudioManager. | 26 // Implementation of AudioManager. |
25 virtual bool HasAudioOutputDevices() OVERRIDE; | 27 virtual bool HasAudioOutputDevices() OVERRIDE; |
26 virtual bool HasAudioInputDevices() OVERRIDE; | 28 virtual bool HasAudioInputDevices() OVERRIDE; |
27 virtual void GetAudioInputDeviceNames( | 29 virtual void GetAudioInputDeviceNames( |
28 AudioDeviceNames* device_names) OVERRIDE; | 30 AudioDeviceNames* device_names) OVERRIDE; |
29 virtual void GetAudioOutputDeviceNames( | 31 virtual void GetAudioOutputDeviceNames( |
30 AudioDeviceNames* device_names) OVERRIDE; | 32 AudioDeviceNames* device_names) OVERRIDE; |
(...skipping 27 matching lines...) Expand all Loading... | |
58 void SetMute(JNIEnv* env, jobject obj, jboolean muted); | 60 void SetMute(JNIEnv* env, jobject obj, jboolean muted); |
59 | 61 |
60 protected: | 62 protected: |
61 virtual ~AudioManagerAndroid(); | 63 virtual ~AudioManagerAndroid(); |
62 | 64 |
63 virtual AudioParameters GetPreferredOutputStreamParameters( | 65 virtual AudioParameters GetPreferredOutputStreamParameters( |
64 const std::string& output_device_id, | 66 const std::string& output_device_id, |
65 const AudioParameters& input_params) OVERRIDE; | 67 const AudioParameters& input_params) OVERRIDE; |
66 | 68 |
67 private: | 69 private: |
68 bool HadNoAudioStreams(); | 70 void InitializeOnAudioThread(); |
69 void Init(); | 71 void ShutdownOnAudioThread(); |
70 void Close(); | 72 |
73 bool HasNoAudioStreams(); | |
71 void SetCommunicationAudioModeOn(bool on); | 74 void SetCommunicationAudioModeOn(bool on); |
72 bool SetAudioDevice(const std::string& device_id); | 75 bool SetAudioDevice(const std::string& device_id); |
73 int GetNativeOutputSampleRate(); | 76 int GetNativeOutputSampleRate(); |
74 bool IsAudioLowLatencySupported(); | 77 bool IsAudioLowLatencySupported(); |
75 int GetAudioLowLatencyOutputFrameSize(); | 78 int GetAudioLowLatencyOutputFrameSize(); |
76 int GetOptimalOutputFrameSize(int sample_rate, int channels); | 79 int GetOptimalOutputFrameSize(int sample_rate, int channels); |
77 | 80 |
78 void DoSetMuteOnAudioThread(bool muted); | 81 void DoSetMuteOnAudioThread(bool muted); |
79 | 82 |
80 // Allow the AudioAndroidTest to access private methods. | |
81 FRIEND_TEST_ALL_PREFIXES(AudioAndroidOutputTest, IsAudioLowLatencySupported); | |
82 | |
83 // Java AudioManager instance. | 83 // Java AudioManager instance. |
84 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_; | 84 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_; |
85 | 85 |
86 typedef std::set<OpenSLESOutputStream*> OutputStreams; | 86 typedef std::set<OpenSLESOutputStream*> OutputStreams; |
87 OutputStreams streams_; | 87 OutputStreams streams_; |
88 // TODO(wjia): remove this lock once unit test modules are fixed to call | |
89 // AudioManager::MakeAudioOutputStream on the audio thread. For now, this | |
90 // lock is used to guard access to |streams_|. | |
91 base::Lock streams_lock_; | |
92 | 88 |
93 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid); | 89 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid); |
94 }; | 90 }; |
95 | 91 |
96 } // namespace media | 92 } // namespace media |
97 | 93 |
98 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ | 94 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ |
OLD | NEW |