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

Side by Side Diff: media/audio/android/opensles_output.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
« no previous file with comments | « media/audio/android/audio_manager_android.cc ('k') | media/audio/android/opensles_output.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_OPENSLES_OUTPUT_H_ 5 #ifndef MEDIA_AUDIO_ANDROID_OPENSLES_OUTPUT_H_
6 #define MEDIA_AUDIO_ANDROID_OPENSLES_OUTPUT_H_ 6 #define MEDIA_AUDIO_ANDROID_OPENSLES_OUTPUT_H_
7 7
8 #include <SLES/OpenSLES.h> 8 #include <SLES/OpenSLES.h>
9 #include <SLES/OpenSLES_Android.h> 9 #include <SLES/OpenSLES_Android.h>
10 10
(...skipping 22 matching lines...) Expand all
33 virtual ~OpenSLESOutputStream(); 33 virtual ~OpenSLESOutputStream();
34 34
35 // Implementation of AudioOutputStream. 35 // Implementation of AudioOutputStream.
36 virtual bool Open() OVERRIDE; 36 virtual bool Open() OVERRIDE;
37 virtual void Close() OVERRIDE; 37 virtual void Close() OVERRIDE;
38 virtual void Start(AudioSourceCallback* callback) OVERRIDE; 38 virtual void Start(AudioSourceCallback* callback) OVERRIDE;
39 virtual void Stop() OVERRIDE; 39 virtual void Stop() OVERRIDE;
40 virtual void SetVolume(double volume) OVERRIDE; 40 virtual void SetVolume(double volume) OVERRIDE;
41 virtual void GetVolume(double* volume) OVERRIDE; 41 virtual void GetVolume(double* volume) OVERRIDE;
42 42
43 // Set the value of |muted_|. It does not affect |volume_| which can be
44 // got by calling GetVolume(). See comments for |muted_| below.
45 void SetMute(bool muted);
46
43 private: 47 private:
44 bool CreatePlayer(); 48 bool CreatePlayer();
45 49
46 // Called from OpenSLES specific audio worker thread. 50 // Called from OpenSLES specific audio worker thread.
47 static void SimpleBufferQueueCallback( 51 static void SimpleBufferQueueCallback(
48 SLAndroidSimpleBufferQueueItf buffer_queue, 52 SLAndroidSimpleBufferQueueItf buffer_queue,
49 void* instance); 53 void* instance);
50 54
51 // Fills up one buffer by asking the registered source for data. 55 // Fills up one buffer by asking the registered source for data.
52 // Called from OpenSLES specific audio worker thread. 56 // Called from OpenSLES specific audio worker thread.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 93
90 // Audio buffers that are allocated in the constructor based on 94 // Audio buffers that are allocated in the constructor based on
91 // info from audio parameters. 95 // info from audio parameters.
92 uint8* audio_data_[kMaxNumOfBuffersInQueue]; 96 uint8* audio_data_[kMaxNumOfBuffersInQueue];
93 97
94 int active_buffer_index_; 98 int active_buffer_index_;
95 size_t buffer_size_bytes_; 99 size_t buffer_size_bytes_;
96 100
97 bool started_; 101 bool started_;
98 102
103 // Volume control coming from hardware. It overrides |volume_| when it's
104 // true. Otherwise, use |volume_| for scaling.
105 // This is needed because platform voice volume never goes to zero in
106 // COMMUNICATION mode on Android.
107 bool muted_;
108
99 // Volume level from 0 to 1. 109 // Volume level from 0 to 1.
100 float volume_; 110 float volume_;
101 111
102 // Container for retrieving data from AudioSourceCallback::OnMoreData(). 112 // Container for retrieving data from AudioSourceCallback::OnMoreData().
103 scoped_ptr<AudioBus> audio_bus_; 113 scoped_ptr<AudioBus> audio_bus_;
104 114
105 DISALLOW_COPY_AND_ASSIGN(OpenSLESOutputStream); 115 DISALLOW_COPY_AND_ASSIGN(OpenSLESOutputStream);
106 }; 116 };
107 117
108 } // namespace media 118 } // namespace media
109 119
110 #endif // MEDIA_AUDIO_ANDROID_OPENSLES_OUTPUT_H_ 120 #endif // MEDIA_AUDIO_ANDROID_OPENSLES_OUTPUT_H_
OLDNEW
« no previous file with comments | « media/audio/android/audio_manager_android.cc ('k') | media/audio/android/opensles_output.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698