| 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/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "media/audio/audio_manager_base.h" | 14 #include "media/audio/audio_manager_base.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 | 17 |
| 18 class OpenSLESOutputStream; | 18 class MuteableAudioOutputStream; |
| 19 | 19 |
| 20 // Android implemention of AudioManager. | 20 // Android implemention of AudioManager. |
| 21 class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase { | 21 class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase { |
| 22 public: | 22 public: |
| 23 AudioManagerAndroid(std::unique_ptr<AudioThread> audio_thread, | 23 AudioManagerAndroid(std::unique_ptr<AudioThread> audio_thread, |
| 24 AudioLogFactory* audio_log_factory); | 24 AudioLogFactory* audio_log_factory); |
| 25 ~AudioManagerAndroid() override; | 25 ~AudioManagerAndroid() override; |
| 26 | 26 |
| 27 void InitializeIfNeeded(); | 27 void InitializeIfNeeded(); |
| 28 | 28 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 const char* GetName() override; | 47 const char* GetName() override; |
| 48 | 48 |
| 49 // Implementation of AudioManagerBase. | 49 // Implementation of AudioManagerBase. |
| 50 AudioOutputStream* MakeLinearOutputStream( | 50 AudioOutputStream* MakeLinearOutputStream( |
| 51 const AudioParameters& params, | 51 const AudioParameters& params, |
| 52 const LogCallback& log_callback) override; | 52 const LogCallback& log_callback) override; |
| 53 AudioOutputStream* MakeLowLatencyOutputStream( | 53 AudioOutputStream* MakeLowLatencyOutputStream( |
| 54 const AudioParameters& params, | 54 const AudioParameters& params, |
| 55 const std::string& device_id, | 55 const std::string& device_id, |
| 56 const LogCallback& log_callback) override; | 56 const LogCallback& log_callback) override; |
| 57 AudioOutputStream* MakeBitstreamOutputStream( |
| 58 const AudioParameters& params, |
| 59 const std::string& device_id, |
| 60 const LogCallback& log_callback) override; |
| 57 AudioInputStream* MakeLinearInputStream( | 61 AudioInputStream* MakeLinearInputStream( |
| 58 const AudioParameters& params, | 62 const AudioParameters& params, |
| 59 const std::string& device_id, | 63 const std::string& device_id, |
| 60 const LogCallback& log_callback) override; | 64 const LogCallback& log_callback) override; |
| 61 AudioInputStream* MakeLowLatencyInputStream( | 65 AudioInputStream* MakeLowLatencyInputStream( |
| 62 const AudioParameters& params, | 66 const AudioParameters& params, |
| 63 const std::string& device_id, | 67 const std::string& device_id, |
| 64 const LogCallback& log_callback) override; | 68 const LogCallback& log_callback) override; |
| 65 | 69 |
| 66 static bool RegisterAudioManager(JNIEnv* env); | 70 static bool RegisterAudioManager(JNIEnv* env); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 89 bool IsAudioLowLatencySupported(); | 93 bool IsAudioLowLatencySupported(); |
| 90 int GetAudioLowLatencyOutputFrameSize(); | 94 int GetAudioLowLatencyOutputFrameSize(); |
| 91 int GetOptimalOutputFrameSize(int sample_rate, int channels); | 95 int GetOptimalOutputFrameSize(int sample_rate, int channels); |
| 92 | 96 |
| 93 void DoSetMuteOnAudioThread(bool muted); | 97 void DoSetMuteOnAudioThread(bool muted); |
| 94 void DoSetVolumeOnAudioThread(double volume); | 98 void DoSetVolumeOnAudioThread(double volume); |
| 95 | 99 |
| 96 // Java AudioManager instance. | 100 // Java AudioManager instance. |
| 97 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_; | 101 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_; |
| 98 | 102 |
| 99 typedef std::set<OpenSLESOutputStream*> OutputStreams; | 103 typedef std::set<MuteableAudioOutputStream*> OutputStreams; |
| 100 OutputStreams streams_; | 104 OutputStreams streams_; |
| 101 | 105 |
| 102 // Enabled when first input stream is created and set to false when last | 106 // Enabled when first input stream is created and set to false when last |
| 103 // input stream is destroyed. Also affects the stream type of output streams. | 107 // input stream is destroyed. Also affects the stream type of output streams. |
| 104 bool communication_mode_is_on_; | 108 bool communication_mode_is_on_; |
| 105 | 109 |
| 106 // If set, overrides volume level on output streams | 110 // If set, overrides volume level on output streams |
| 107 bool output_volume_override_set_; | 111 bool output_volume_override_set_; |
| 108 double output_volume_override_; | 112 double output_volume_override_; |
| 109 | 113 |
| 110 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid); | 114 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid); |
| 111 }; | 115 }; |
| 112 | 116 |
| 113 } // namespace media | 117 } // namespace media |
| 114 | 118 |
| 115 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ | 119 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ |
| OLD | NEW |