Adds "tts" permission for Input Tools & XKB extension.
[chromium-blink-merge.git] / media / audio / android / audio_manager_android.h
blobd1a8c8bf6236b230f411c1346f885c07bdc8e7d4
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 <set>
10 #include "base/android/jni_android.h"
11 #include "base/gtest_prod_util.h"
12 #include "base/synchronization/lock.h"
13 #include "base/synchronization/waitable_event.h"
14 #include "media/audio/audio_manager_base.h"
16 namespace media {
18 class OpenSLESOutputStream;
20 // Android implemention of AudioManager.
21 class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase {
22 public:
23 AudioManagerAndroid(AudioLogFactory* audio_log_factory);
25 // Implementation of AudioManager.
26 virtual bool HasAudioOutputDevices() override;
27 virtual bool HasAudioInputDevices() override;
28 virtual void GetAudioInputDeviceNames(
29 AudioDeviceNames* device_names) override;
30 virtual void GetAudioOutputDeviceNames(
31 AudioDeviceNames* device_names) override;
32 virtual AudioParameters GetInputStreamParameters(
33 const std::string& device_id) override;
35 virtual AudioOutputStream* MakeAudioOutputStream(
36 const AudioParameters& params,
37 const std::string& device_id) override;
38 virtual AudioInputStream* MakeAudioInputStream(
39 const AudioParameters& params,
40 const std::string& device_id) override;
41 virtual void ReleaseOutputStream(AudioOutputStream* stream) override;
42 virtual void ReleaseInputStream(AudioInputStream* stream) override;
44 // Implementation of AudioManagerBase.
45 virtual AudioOutputStream* MakeLinearOutputStream(
46 const AudioParameters& params) override;
47 virtual AudioOutputStream* MakeLowLatencyOutputStream(
48 const AudioParameters& params,
49 const std::string& device_id) override;
50 virtual AudioInputStream* MakeLinearInputStream(
51 const AudioParameters& params,
52 const std::string& device_id) override;
53 virtual AudioInputStream* MakeLowLatencyInputStream(
54 const AudioParameters& params,
55 const std::string& device_id) override;
57 static bool RegisterAudioManager(JNIEnv* env);
59 void SetMute(JNIEnv* env, jobject obj, jboolean muted);
61 protected:
62 virtual ~AudioManagerAndroid();
64 virtual AudioParameters GetPreferredOutputStreamParameters(
65 const std::string& output_device_id,
66 const AudioParameters& input_params) override;
68 private:
69 void InitializeOnAudioThread();
70 void ShutdownOnAudioThread();
72 bool HasNoAudioInputStreams();
73 void SetCommunicationAudioModeOn(bool on);
74 bool SetAudioDevice(const std::string& device_id);
75 int GetNativeOutputSampleRate();
76 bool IsAudioLowLatencySupported();
77 int GetAudioLowLatencyOutputFrameSize();
78 int GetOptimalOutputFrameSize(int sample_rate, int channels);
80 void DoSetMuteOnAudioThread(bool muted);
82 // Java AudioManager instance.
83 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_;
85 typedef std::set<OpenSLESOutputStream*> OutputStreams;
86 OutputStreams streams_;
88 // Enabled when first input stream is created and set to false when last
89 // input stream is destroyed. Also affects the stream type of output streams.
90 bool communication_mode_is_on_;
92 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid);
95 } // namespace media
97 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_