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

Side by Side Diff: media/audio/audio_input_device.h

Issue 1911913002: Convert //media/audio from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
« no previous file with comments | « media/audio/audio_input_controller.cc ('k') | media/audio/audio_input_device.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 // Low-latency audio capturing class utilizing audio input stream provided 5 // Low-latency audio capturing class utilizing audio input stream provided
6 // by a server (browser) process by use of an IPC interface. 6 // by a server (browser) process by use of an IPC interface.
7 // 7 //
8 // Relationship of classes: 8 // Relationship of classes:
9 // 9 //
10 // AudioInputController AudioInputDevice 10 // AudioInputController AudioInputDevice
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // 2. Audio transport thread. 46 // 2. Audio transport thread.
47 // Responsible for calling the CaptureCallback and feed audio samples from 47 // Responsible for calling the CaptureCallback and feed audio samples from
48 // the server side audio layer using a socket and shared memory. 48 // the server side audio layer using a socket and shared memory.
49 // 49 //
50 // Implementation notes: 50 // Implementation notes:
51 // - The user must call Stop() before deleting the class instance. 51 // - The user must call Stop() before deleting the class instance.
52 52
53 #ifndef MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_ 53 #ifndef MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_
54 #define MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_ 54 #define MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_
55 55
56 #include <memory>
56 #include <string> 57 #include <string>
57 58
58 #include "base/compiler_specific.h" 59 #include "base/compiler_specific.h"
59 #include "base/macros.h" 60 #include "base/macros.h"
60 #include "base/memory/scoped_ptr.h"
61 #include "base/memory/shared_memory.h" 61 #include "base/memory/shared_memory.h"
62 #include "media/audio/audio_device_thread.h" 62 #include "media/audio/audio_device_thread.h"
63 #include "media/audio/audio_input_ipc.h" 63 #include "media/audio/audio_input_ipc.h"
64 #include "media/audio/scoped_task_runner_observer.h" 64 #include "media/audio/scoped_task_runner_observer.h"
65 #include "media/base/audio_capturer_source.h" 65 #include "media/base/audio_capturer_source.h"
66 #include "media/base/audio_parameters.h" 66 #include "media/base/audio_parameters.h"
67 #include "media/base/media_export.h" 67 #include "media/base/media_export.h"
68 68
69 namespace media { 69 namespace media {
70 70
71 // TODO(henrika): This class is based on the AudioOutputDevice class and it has 71 // TODO(henrika): This class is based on the AudioOutputDevice class and it has
72 // many components in common. Investigate potential for re-factoring. 72 // many components in common. Investigate potential for re-factoring.
73 // See http://crbug.com/179597. 73 // See http://crbug.com/179597.
74 // TODO(henrika): Add support for event handling (e.g. OnStateChanged, 74 // TODO(henrika): Add support for event handling (e.g. OnStateChanged,
75 // OnCaptureStopped etc.) and ensure that we can deliver these notifications 75 // OnCaptureStopped etc.) and ensure that we can deliver these notifications
76 // to any clients using this class. 76 // to any clients using this class.
77 class MEDIA_EXPORT AudioInputDevice 77 class MEDIA_EXPORT AudioInputDevice
78 : NON_EXPORTED_BASE(public AudioCapturerSource), 78 : NON_EXPORTED_BASE(public AudioCapturerSource),
79 NON_EXPORTED_BASE(public AudioInputIPCDelegate), 79 NON_EXPORTED_BASE(public AudioInputIPCDelegate),
80 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) { 80 NON_EXPORTED_BASE(public ScopedTaskRunnerObserver) {
81 public: 81 public:
82 // NOTE: Clients must call Initialize() before using. 82 // NOTE: Clients must call Initialize() before using.
83 AudioInputDevice( 83 AudioInputDevice(
84 scoped_ptr<AudioInputIPC> ipc, 84 std::unique_ptr<AudioInputIPC> ipc,
85 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); 85 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
86 86
87 // AudioCapturerSource implementation. 87 // AudioCapturerSource implementation.
88 void Initialize(const AudioParameters& params, 88 void Initialize(const AudioParameters& params,
89 CaptureCallback* callback, 89 CaptureCallback* callback,
90 int session_id) override; 90 int session_id) override;
91 void Start() override; 91 void Start() override;
92 void Stop() override; 92 void Stop() override;
93 void SetVolume(double volume) override; 93 void SetVolume(double volume) override;
94 void SetAutomaticGainControl(bool enabled) override; 94 void SetAutomaticGainControl(bool enabled) override;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // If the IO loop dies before we do, we shut down the audio thread from here. 129 // If the IO loop dies before we do, we shut down the audio thread from here.
130 void WillDestroyCurrentMessageLoop() override; 130 void WillDestroyCurrentMessageLoop() override;
131 131
132 AudioParameters audio_parameters_; 132 AudioParameters audio_parameters_;
133 133
134 CaptureCallback* callback_; 134 CaptureCallback* callback_;
135 135
136 // A pointer to the IPC layer that takes care of sending requests over to 136 // A pointer to the IPC layer that takes care of sending requests over to
137 // the AudioInputRendererHost. Only valid when state_ != IPC_CLOSED and must 137 // the AudioInputRendererHost. Only valid when state_ != IPC_CLOSED and must
138 // only be accessed on the IO thread. 138 // only be accessed on the IO thread.
139 scoped_ptr<AudioInputIPC> ipc_; 139 std::unique_ptr<AudioInputIPC> ipc_;
140 140
141 // Current state (must only be accessed from the IO thread). See comments for 141 // Current state (must only be accessed from the IO thread). See comments for
142 // State enum above. 142 // State enum above.
143 State state_; 143 State state_;
144 144
145 // The media session ID used to identify which input device to be started. 145 // The media session ID used to identify which input device to be started.
146 // Only modified in Initialize() and ShutDownOnIOThread(). 146 // Only modified in Initialize() and ShutDownOnIOThread().
147 int session_id_; 147 int session_id_;
148 148
149 // Stores the Automatic Gain Control state. Default is false. 149 // Stores the Automatic Gain Control state. Default is false.
150 // Only modified on the IO thread. 150 // Only modified on the IO thread.
151 bool agc_is_enabled_; 151 bool agc_is_enabled_;
152 152
153 // Our audio thread callback class. See source file for details. 153 // Our audio thread callback class. See source file for details.
154 class AudioThreadCallback; 154 class AudioThreadCallback;
155 155
156 // In order to avoid a race between OnStreamCreated and Stop(), we use this 156 // In order to avoid a race between OnStreamCreated and Stop(), we use this
157 // guard to control stopping and starting the audio thread. 157 // guard to control stopping and starting the audio thread.
158 base::Lock audio_thread_lock_; 158 base::Lock audio_thread_lock_;
159 AudioDeviceThread audio_thread_; 159 AudioDeviceThread audio_thread_;
160 scoped_ptr<AudioInputDevice::AudioThreadCallback> audio_callback_; 160 std::unique_ptr<AudioInputDevice::AudioThreadCallback> audio_callback_;
161 161
162 // Temporary hack to ignore OnStreamCreated() due to the user calling Stop() 162 // Temporary hack to ignore OnStreamCreated() due to the user calling Stop()
163 // so we don't start the audio thread pointing to a potentially freed 163 // so we don't start the audio thread pointing to a potentially freed
164 // |callback_|. 164 // |callback_|.
165 // 165 //
166 // TODO(miu): Replace this by changing AudioCapturerSource to accept the 166 // TODO(miu): Replace this by changing AudioCapturerSource to accept the
167 // callback via Start(). See http://crbug.com/151051 for details. 167 // callback via Start(). See http://crbug.com/151051 for details.
168 bool stopping_hack_; 168 bool stopping_hack_;
169 169
170 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice); 170 DISALLOW_IMPLICIT_CONSTRUCTORS(AudioInputDevice);
171 }; 171 };
172 172
173 } // namespace media 173 } // namespace media
174 174
175 #endif // MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_ 175 #endif // MEDIA_AUDIO_AUDIO_INPUT_DEVICE_H_
OLDNEW
« no previous file with comments | « media/audio/audio_input_controller.cc ('k') | media/audio/audio_input_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698