Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: media/audio/android/audio_manager_android.h

Issue 131503006: Initialization of audio manager for Android is now done on the audio thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now compiles Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 : public AudioManagerBase {
21 public: 22 public:
22 AudioManagerAndroid(AudioLogFactory* audio_log_factory); 23 AudioManagerAndroid(AudioLogFactory* audio_log_factory);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void SetMute(JNIEnv* env, jobject obj, jboolean muted); 59 void SetMute(JNIEnv* env, jobject obj, jboolean muted);
59 60
60 protected: 61 protected:
61 virtual ~AudioManagerAndroid(); 62 virtual ~AudioManagerAndroid();
62 63
63 virtual AudioParameters GetPreferredOutputStreamParameters( 64 virtual AudioParameters GetPreferredOutputStreamParameters(
64 const std::string& output_device_id, 65 const std::string& output_device_id,
65 const AudioParameters& input_params) OVERRIDE; 66 const AudioParameters& input_params) OVERRIDE;
66 67
67 private: 68 private:
69 void InitializeOnAudioThread();
70 void ShutdownOnAudioThread();
71
68 bool HasNoAudioInputStreams(); 72 bool HasNoAudioInputStreams();
69 void Init();
70 void Close();
71 void SetCommunicationAudioModeOn(bool on); 73 void SetCommunicationAudioModeOn(bool on);
72 bool SetAudioDevice(const std::string& device_id); 74 bool SetAudioDevice(const std::string& device_id);
73 int GetNativeOutputSampleRate(); 75 int GetNativeOutputSampleRate();
74 bool IsAudioLowLatencySupported(); 76 bool IsAudioLowLatencySupported();
75 int GetAudioLowLatencyOutputFrameSize(); 77 int GetAudioLowLatencyOutputFrameSize();
76 int GetOptimalOutputFrameSize(int sample_rate, int channels); 78 int GetOptimalOutputFrameSize(int sample_rate, int channels);
77 79
78 void DoSetMuteOnAudioThread(bool muted); 80 void DoSetMuteOnAudioThread(bool muted);
79 81
80 // Allow the AudioAndroidTest to access private methods.
81 FRIEND_TEST_ALL_PREFIXES(AudioAndroidOutputTest, IsAudioLowLatencySupported);
82
83 // Java AudioManager instance. 82 // Java AudioManager instance.
84 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_; 83 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_;
85 84
86 typedef std::set<OpenSLESOutputStream*> OutputStreams; 85 typedef std::set<OpenSLESOutputStream*> OutputStreams;
87 OutputStreams streams_; 86 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 87
93 // Enabled when first input stream is created and set to false when last 88 // Enabled when first input stream is created and set to false when last
94 // input stream is destroyed. Also affects the stream type of output streams. 89 // input stream is destroyed. Also affects the stream type of output streams.
95 bool communication_mode_is_on_; 90 bool communication_mode_is_on_;
96 91
97 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid); 92 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid);
98 }; 93 };
99 94
100 } // namespace media 95 } // namespace media
101 96
102 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ 97 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_
OLDNEW
« no previous file with comments | « media/audio/android/audio_android_unittest.cc ('k') | media/audio/android/audio_manager_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698