Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / renderer_host / media / audio_input_debug_writer.h
blob683321105948ad576a4b2c171f7b2be4d2c7dd2b
1 // Copyright 2015 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.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEBUG_WRITER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEBUG_WRITER_H_
8 #include "base/files/file.h"
9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/move.h"
14 #include "media/audio/audio_input_writer.h"
16 namespace media {
18 class AudioBus;
19 class AudioBusRefCounted;
21 } // namespace media
23 namespace content {
25 // Writes audio input data used for debugging purposes. Can be created on any
26 // thread. Must be destroyed on the FILE thread. Write call can be made on any
27 // thread. This object must be unregistered in Write caller before destroyed.
28 // When created, it takes ownership of |file|.
29 class AudioInputDebugWriter : public media::AudioInputWriter {
30 public:
31 explicit AudioInputDebugWriter(base::File file);
33 ~AudioInputDebugWriter() override;
35 // Write data from |data| to file.
36 void Write(scoped_ptr<media::AudioBus> data) override;
38 private:
39 // Write data from |data| to file. Called on the FILE thread.
40 void DoWrite(scoped_ptr<media::AudioBus> data);
42 // The file to write to.
43 base::File file_;
45 // Intermediate buffer to be written to file. Interleaved 16 bit audio data.
46 scoped_ptr<int16[]> interleaved_data_;
47 int interleaved_data_size_;
49 base::WeakPtrFactory<AudioInputDebugWriter> weak_factory_;
52 } // namspace content
54 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_INPUT_DEBUG_WRITER_H_