Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_HELPER_H_ | |
| 6 #define MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_HELPER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 #include "media/audio/audio_file_writer.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class FilePath; | |
| 16 class SingleThreadTaskRunner; | |
| 17 } | |
| 18 | |
| 19 namespace media { | |
| 20 | |
| 21 class AudioBus; | |
| 22 class AudioManager; | |
| 23 | |
| 24 // A helper class for objects that want to use AudioFileWriter. It handles | |
| 25 // copying AudioBus data, thread jump (MaybeWrite() can be called on any | |
| 26 // thread), and creating and deleting the AudioFileWriter at enable and disable. | |
| 27 class AudioDebugRecordingHelper { | |
| 28 public: | |
| 29 AudioDebugRecordingHelper(AudioManager* audio_manager, | |
| 30 base::SingleThreadTaskRunner* task_runner); | |
|
DaleCurtis
2017/01/19 17:44:34
scoped_refptr
Henrik Grunell
2017/01/20 10:38:55
Done.
| |
| 31 ~AudioDebugRecordingHelper(); | |
| 32 | |
| 33 // Enable and disable debug recording. When enabled, |audio_manager_| is asked | |
| 34 // to create a DebugWriter. Extension "wav" will be added to |file_name|. | |
| 35 void EnableDebugRecording(const AudioParameters& params, | |
| 36 const base::FilePath& file_name); | |
| 37 void DisableDebugRecording(); | |
| 38 | |
| 39 // If debug recording is enabled, copies audio data and posts DoWrite() on | |
| 40 // |task_runner_|. Can be called on any thread. | |
| 41 void MaybeWrite(const AudioBus* source); | |
| 42 | |
| 43 // Pass-through to AudioFileWriter::WillWrite(). Can be called on any thread. | |
| 44 bool WillWrite(); | |
| 45 | |
| 46 private: | |
| 47 // Writes debug data to |debug_writer_|. | |
| 48 void DoWrite(std::unique_ptr<media::AudioBus> data); | |
| 49 | |
| 50 AudioManager* audio_manager_; | |
| 51 std::unique_ptr<AudioFileWriter> debug_writer_; | |
| 52 base::SingleThreadTaskRunner* task_runner_; | |
| 53 | |
| 54 base::WeakPtrFactory<AudioDebugRecordingHelper> weak_factory_; | |
| 55 }; | |
|
DaleCurtis
2017/01/19 17:44:34
DISALLOW
Henrik Grunell
2017/01/20 10:38:55
Done.
| |
| 56 | |
| 57 } // namspace media | |
| 58 | |
| 59 #endif // MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_HELPER_H_ | |
| OLD | NEW |