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

Side by Side Diff: media/audio/audio_input_controller.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: Fix cast + windows build 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
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_AUDIO_INPUT_CONTROLLER_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
6 #define MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ 6 #define MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory>
11 #include <string> 12 #include <string>
12 13
13 #include "base/atomicops.h" 14 #include "base/atomicops.h"
14 #include "base/callback.h" 15 #include "base/callback.h"
15 #include "base/files/file.h" 16 #include "base/files/file.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h"
19 #include "base/synchronization/lock.h" 19 #include "base/synchronization/lock.h"
20 #include "base/synchronization/waitable_event.h" 20 #include "base/synchronization/waitable_event.h"
21 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
22 #include "base/timer/timer.h" 22 #include "base/timer/timer.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "media/audio/audio_io.h" 24 #include "media/audio/audio_io.h"
25 #include "media/audio/audio_manager_base.h" 25 #include "media/audio/audio_manager_base.h"
26 #include "media/audio/audio_parameters.h" 26 #include "media/audio/audio_parameters.h"
27 #include "media/base/audio_bus.h" 27 #include "media/base/audio_bus.h"
28 28
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 const AudioParameters& params, 285 const AudioParameters& params,
286 const std::string& device_id); 286 const std::string& device_id);
287 void DoCreateForLowLatency(AudioManager* audio_manager, 287 void DoCreateForLowLatency(AudioManager* audio_manager,
288 const AudioParameters& params, 288 const AudioParameters& params,
289 const std::string& device_id); 289 const std::string& device_id);
290 void DoCreateForStream(AudioInputStream* stream_to_control); 290 void DoCreateForStream(AudioInputStream* stream_to_control);
291 void DoRecord(); 291 void DoRecord();
292 void DoClose(); 292 void DoClose();
293 void DoReportError(); 293 void DoReportError();
294 void DoSetVolume(double volume); 294 void DoSetVolume(double volume);
295 void DoOnData(scoped_ptr<AudioBus> data); 295 void DoOnData(std::unique_ptr<AudioBus> data);
296 void DoLogAudioLevels(float level_dbfs, int microphone_volume_percent); 296 void DoLogAudioLevels(float level_dbfs, int microphone_volume_percent);
297 297
298 // Method to check if we get recorded data after a stream was started, 298 // Method to check if we get recorded data after a stream was started,
299 // and log the result to UMA. 299 // and log the result to UMA.
300 void FirstCheckForNoData(); 300 void FirstCheckForNoData();
301 301
302 // Method which ensures that OnError() is triggered when data recording 302 // Method which ensures that OnError() is triggered when data recording
303 // times out. Called on the audio thread. 303 // times out. Called on the audio thread.
304 void DoCheckForNoData(); 304 void DoCheckForNoData();
305 305
(...skipping 11 matching lines...) Expand all
317 // Logs the silence state as UMA stat. 317 // Logs the silence state as UMA stat.
318 void LogSilenceState(SilenceState value); 318 void LogSilenceState(SilenceState value);
319 #endif 319 #endif
320 320
321 // Enable and disable debug recording of audio input. Called on the audio 321 // Enable and disable debug recording of audio input. Called on the audio
322 // thread. 322 // thread.
323 void DoEnableDebugRecording(AudioInputWriter* input_writer); 323 void DoEnableDebugRecording(AudioInputWriter* input_writer);
324 void DoDisableDebugRecording(); 324 void DoDisableDebugRecording();
325 325
326 // Called on the audio thread. 326 // Called on the audio thread.
327 void WriteInputDataForDebugging(scoped_ptr<AudioBus> data); 327 void WriteInputDataForDebugging(std::unique_ptr<AudioBus> data);
328 328
329 // Gives access to the task runner of the creating thread. 329 // Gives access to the task runner of the creating thread.
330 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_; 330 scoped_refptr<base::SingleThreadTaskRunner> creator_task_runner_;
331 331
332 // The task runner of audio-manager thread that this object runs on. 332 // The task runner of audio-manager thread that this object runs on.
333 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 333 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
334 334
335 // Contains the AudioInputController::EventHandler which receives state 335 // Contains the AudioInputController::EventHandler which receives state
336 // notifications from this class. 336 // notifications from this class.
337 EventHandler* handler_; 337 EventHandler* handler_;
338 338
339 // Pointer to the audio input stream object. 339 // Pointer to the audio input stream object.
340 AudioInputStream* stream_; 340 AudioInputStream* stream_;
341 341
342 // |no_data_timer_| is used to call OnError() when we stop receiving 342 // |no_data_timer_| is used to call OnError() when we stop receiving
343 // OnData() calls. This can occur when an audio input device is unplugged 343 // OnData() calls. This can occur when an audio input device is unplugged
344 // whilst recording on Windows. 344 // whilst recording on Windows.
345 // See http://crbug.com/79936 for details. 345 // See http://crbug.com/79936 for details.
346 // This member is only touched by the audio thread. 346 // This member is only touched by the audio thread.
347 scoped_ptr<base::Timer> no_data_timer_; 347 std::unique_ptr<base::Timer> no_data_timer_;
348 348
349 // This flag is used to signal that we are receiving OnData() calls, i.e, 349 // This flag is used to signal that we are receiving OnData() calls, i.e,
350 // that data is active. It can be touched by the audio thread and by the 350 // that data is active. It can be touched by the audio thread and by the
351 // low-level audio thread which calls OnData(). E.g. on Windows, the 351 // low-level audio thread which calls OnData(). E.g. on Windows, the
352 // low-level audio thread is called wasapi_capture_thread. 352 // low-level audio thread is called wasapi_capture_thread.
353 base::subtle::Atomic32 data_is_active_; 353 base::subtle::Atomic32 data_is_active_;
354 354
355 // |state_| is written on the audio thread and is read on the hardware audio 355 // |state_| is written on the audio thread and is read on the hardware audio
356 // thread. These operations need to be locked. But lock is not required for 356 // thread. These operations need to be locked. But lock is not required for
357 // reading on the audio input controller thread. 357 // reading on the audio input controller thread.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 // Used for audio debug recordings. Accessed on audio thread. 392 // Used for audio debug recordings. Accessed on audio thread.
393 AudioInputWriter* input_writer_; 393 AudioInputWriter* input_writer_;
394 394
395 DISALLOW_COPY_AND_ASSIGN(AudioInputController); 395 DISALLOW_COPY_AND_ASSIGN(AudioInputController);
396 }; 396 };
397 397
398 } // namespace media 398 } // namespace media
399 399
400 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_ 400 #endif // MEDIA_AUDIO_AUDIO_INPUT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698