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

Side by Side Diff: media/audio/pulse/pulse_input.h

Issue 645923002: Add support for audio input mute detection on all platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added default implementation for cras Created 6 years, 2 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
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_PULSE_PULSE_INPUT_H_ 5 #ifndef MEDIA_AUDIO_PULSE_PULSE_INPUT_H_
6 #define MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ 6 #define MEDIA_AUDIO_PULSE_PULSE_INPUT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
(...skipping 23 matching lines...) Expand all
34 virtual ~PulseAudioInputStream(); 34 virtual ~PulseAudioInputStream();
35 35
36 // Implementation of AudioInputStream. 36 // Implementation of AudioInputStream.
37 virtual bool Open() override; 37 virtual bool Open() override;
38 virtual void Start(AudioInputCallback* callback) override; 38 virtual void Start(AudioInputCallback* callback) override;
39 virtual void Stop() override; 39 virtual void Stop() override;
40 virtual void Close() override; 40 virtual void Close() override;
41 virtual double GetMaxVolume() override; 41 virtual double GetMaxVolume() override;
42 virtual void SetVolume(double volume) override; 42 virtual void SetVolume(double volume) override;
43 virtual double GetVolume() override; 43 virtual double GetVolume() override;
44 virtual bool IsMuted() override;
44 45
45 private: 46 private:
46 // PulseAudio Callbacks. 47 // PulseAudio Callbacks.
47 static void ReadCallback(pa_stream* handle, size_t length, void* user_data); 48 static void ReadCallback(pa_stream* handle, size_t length, void* user_data);
48 static void StreamNotifyCallback(pa_stream* stream, void* user_data); 49 static void StreamNotifyCallback(pa_stream* stream, void* user_data);
49 static void VolumeCallback(pa_context* context, const pa_source_info* info, 50 static void VolumeCallback(pa_context* context, const pa_source_info* info,
50 int error, void* user_data); 51 int error, void* user_data);
52 static void MuteCallback(pa_context* context, const pa_source_info* info,
53 int error, void* user_data);
51 54
52 // Helper for the ReadCallback. 55 // Helper for the ReadCallback.
53 void ReadData(); 56 void ReadData();
54 57
55 AudioManagerPulse* audio_manager_; 58 AudioManagerPulse* audio_manager_;
56 AudioInputCallback* callback_; 59 AudioInputCallback* callback_;
57 std::string device_name_; 60 std::string device_name_;
58 AudioParameters params_; 61 AudioParameters params_;
59 int channels_; 62 int channels_;
60 double volume_; 63 double volume_;
61 bool stream_started_; 64 bool stream_started_;
62 65
66 // Set to true in IsMuted() if user has muted the selected microphone in the
67 // sound settings UI.
68 bool muted_;
69
63 // Holds the data from the OS. 70 // Holds the data from the OS.
64 AudioBlockFifo fifo_; 71 AudioBlockFifo fifo_;
65 72
66 // PulseAudio API structs. 73 // PulseAudio API structs.
67 pa_threaded_mainloop* pa_mainloop_; // Weak. 74 pa_threaded_mainloop* pa_mainloop_; // Weak.
68 pa_context* pa_context_; // Weak. 75 pa_context* pa_context_; // Weak.
69 pa_stream* handle_; 76 pa_stream* handle_;
70 77
71 // Flag indicating the state of the context has been changed. 78 // Flag indicating the state of the context has been changed.
72 bool context_state_changed_; 79 bool context_state_changed_;
73 80
74 base::ThreadChecker thread_checker_; 81 base::ThreadChecker thread_checker_;
75 82
76 DISALLOW_COPY_AND_ASSIGN(PulseAudioInputStream); 83 DISALLOW_COPY_AND_ASSIGN(PulseAudioInputStream);
77 }; 84 };
78 85
79 } // namespace media 86 } // namespace media
80 87
81 #endif // MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ 88 #endif // MEDIA_AUDIO_PULSE_PULSE_INPUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698