Chromium Code Reviews| Index: media/audio/audio_debug_recording_helper.h |
| diff --git a/media/audio/audio_debug_recording_helper.h b/media/audio/audio_debug_recording_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4db25afbca95fb91f55763750ccec38cc0e946cc |
| --- /dev/null |
| +++ b/media/audio/audio_debug_recording_helper.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_HELPER_H_ |
| +#define MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_HELPER_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "media/audio/audio_file_writer.h" |
| + |
| +namespace base { |
| +class FilePath; |
| +class SingleThreadTaskRunner; |
| +} |
| + |
| +namespace media { |
| + |
| +class AudioBus; |
| +class AudioManager; |
| + |
| +// A helper class for objects that want to use AudioFileWriter. It handles |
| +// copying AudioBus data, thread jump (MaybeWrite() can be called on any |
| +// thread), and creating and deleting the AudioFileWriter at enable and disable. |
| +class AudioDebugRecordingHelper { |
| + public: |
| + AudioDebugRecordingHelper(AudioManager* audio_manager, |
| + base::SingleThreadTaskRunner* task_runner); |
|
DaleCurtis
2017/01/19 17:44:34
scoped_refptr
Henrik Grunell
2017/01/20 10:38:55
Done.
|
| + ~AudioDebugRecordingHelper(); |
| + |
| + // Enable and disable debug recording. When enabled, |audio_manager_| is asked |
| + // to create a DebugWriter. Extension "wav" will be added to |file_name|. |
| + void EnableDebugRecording(const AudioParameters& params, |
| + const base::FilePath& file_name); |
| + void DisableDebugRecording(); |
| + |
| + // If debug recording is enabled, copies audio data and posts DoWrite() on |
| + // |task_runner_|. Can be called on any thread. |
| + void MaybeWrite(const AudioBus* source); |
| + |
| + // Pass-through to AudioFileWriter::WillWrite(). Can be called on any thread. |
| + bool WillWrite(); |
| + |
| + private: |
| + // Writes debug data to |debug_writer_|. |
| + void DoWrite(std::unique_ptr<media::AudioBus> data); |
| + |
| + AudioManager* audio_manager_; |
| + std::unique_ptr<AudioFileWriter> debug_writer_; |
| + base::SingleThreadTaskRunner* task_runner_; |
| + |
| + base::WeakPtrFactory<AudioDebugRecordingHelper> weak_factory_; |
| +}; |
|
DaleCurtis
2017/01/19 17:44:34
DISALLOW
Henrik Grunell
2017/01/20 10:38:55
Done.
|
| + |
| +} // namspace media |
| + |
| +#endif // MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_HELPER_H_ |