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

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

Issue 93233003: Mute audio when volume is zero on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: henrika@'s comment Created 7 years 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>
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"
12 #include "base/synchronization/lock.h"
10 #include "media/audio/audio_manager_base.h" 13 #include "media/audio/audio_manager_base.h"
11 14
12 namespace media { 15 namespace media {
13 16
17 class OpenSLESOutputStream;
18
14 // Android implemention of AudioManager. 19 // Android implemention of AudioManager.
15 class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase { 20 class MEDIA_EXPORT AudioManagerAndroid : public AudioManagerBase {
16 public: 21 public:
17 AudioManagerAndroid(); 22 AudioManagerAndroid();
18 23
19 // Implementation of AudioManager. 24 // Implementation of AudioManager.
20 virtual bool HasAudioOutputDevices() OVERRIDE; 25 virtual bool HasAudioOutputDevices() OVERRIDE;
21 virtual bool HasAudioInputDevices() OVERRIDE; 26 virtual bool HasAudioInputDevices() OVERRIDE;
22 virtual void GetAudioInputDeviceNames( 27 virtual void GetAudioInputDeviceNames(
23 AudioDeviceNames* device_names) OVERRIDE; 28 AudioDeviceNames* device_names) OVERRIDE;
(...skipping 21 matching lines...) Expand all
45 const std::string& input_device_id) OVERRIDE; 50 const std::string& input_device_id) OVERRIDE;
46 virtual AudioInputStream* MakeLinearInputStream( 51 virtual AudioInputStream* MakeLinearInputStream(
47 const AudioParameters& params, 52 const AudioParameters& params,
48 const std::string& device_id) OVERRIDE; 53 const std::string& device_id) OVERRIDE;
49 virtual AudioInputStream* MakeLowLatencyInputStream( 54 virtual AudioInputStream* MakeLowLatencyInputStream(
50 const AudioParameters& params, 55 const AudioParameters& params,
51 const std::string& device_id) OVERRIDE; 56 const std::string& device_id) OVERRIDE;
52 57
53 static bool RegisterAudioManager(JNIEnv* env); 58 static bool RegisterAudioManager(JNIEnv* env);
54 59
60 void SetMute(JNIEnv* env, jobject obj, jboolean muted);
61
55 protected: 62 protected:
56 virtual ~AudioManagerAndroid(); 63 virtual ~AudioManagerAndroid();
57 64
58 virtual AudioParameters GetPreferredOutputStreamParameters( 65 virtual AudioParameters GetPreferredOutputStreamParameters(
59 const std::string& output_device_id, 66 const std::string& output_device_id,
60 const AudioParameters& input_params) OVERRIDE; 67 const AudioParameters& input_params) OVERRIDE;
61 68
62 private: 69 private:
63 void Init(); 70 void Init();
64 void Close(); 71 void Close();
65 void SetAudioMode(int mode); 72 void SetAudioMode(int mode);
66 void SetAudioDevice(const std::string& device_id); 73 void SetAudioDevice(const std::string& device_id);
67 int GetNativeOutputSampleRate(); 74 int GetNativeOutputSampleRate();
68 bool IsAudioLowLatencySupported(); 75 bool IsAudioLowLatencySupported();
69 int GetAudioLowLatencyOutputFrameSize(); 76 int GetAudioLowLatencyOutputFrameSize();
70 int GetOptimalOutputFrameSize(int sample_rate, int channels); 77 int GetOptimalOutputFrameSize(int sample_rate, int channels);
71 78
79 void DoSetMuteOnAudioThread(bool muted);
80
72 // Allow the AudioAndroidTest to access private methods. 81 // Allow the AudioAndroidTest to access private methods.
73 FRIEND_TEST_ALL_PREFIXES(AudioAndroidTest, IsAudioLowLatencySupported); 82 FRIEND_TEST_ALL_PREFIXES(AudioAndroidTest, IsAudioLowLatencySupported);
74 83
75 // Java AudioManager instance. 84 // Java AudioManager instance.
76 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_; 85 base::android::ScopedJavaGlobalRef<jobject> j_audio_manager_;
77 86
87 typedef std::set<OpenSLESOutputStream*> OutputStreams;
88 OutputStreams streams_;
89 // TODO(wjia): remove this lock once unit test modules are fixed to call
90 // AudioManager::MakeAudioOutputStream on the audio thread. For now, this
91 // lock is used to guard access to |streams_|.
92 base::Lock streams_lock_;
93
78 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid); 94 DISALLOW_COPY_AND_ASSIGN(AudioManagerAndroid);
79 }; 95 };
80 96
81 } // namespace media 97 } // namespace media
82 98
83 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_ 99 #endif // MEDIA_AUDIO_ANDROID_AUDIO_MANAGER_ANDROID_H_
OLDNEW
« no previous file with comments | « build/android/findbugs_filter/findbugs_known_bugs.txt ('k') | media/audio/android/audio_manager_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698