OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
DaleCurtis
2017/02/21 18:00:58
We don't update copyright when moving IIRC.
Henrik Grunell
2017/02/22 10:47:43
Done.
| |
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_FILE_WRITER_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_DEBUG_FILE_WRITER_H_ |
6 #define MEDIA_AUDIO_AUDIO_FILE_WRITER_H_ | 6 #define MEDIA_AUDIO_AUDIO_DEBUG_FILE_WRITER_H_ |
7 | |
8 #include <stdint.h> | |
7 | 9 |
8 #include <memory> | 10 #include <memory> |
9 | 11 |
10 namespace base { | 12 #include "base/files/file.h" |
11 class FilePath; | 13 #include "base/macros.h" |
12 } | 14 #include "base/memory/ref_counted.h" |
15 #include "base/sequence_checker.h" | |
16 #include "base/single_thread_task_runner.h" | |
17 #include "media/base/audio_parameters.h" | |
18 #include "media/base/media_export.h" | |
13 | 19 |
14 namespace media { | 20 namespace media { |
15 | 21 |
16 class AudioBus; | 22 class AudioBus; |
17 | 23 |
18 // A writer interface used for writing audio data to file for debugging | 24 // Writes audio data used for debugging purposes. All operations are |
19 // purposes. | 25 // non-blocking. |
20 class AudioFileWriter { | 26 class MEDIA_EXPORT AudioDebugFileWriter { |
21 public: | 27 public: |
22 virtual ~AudioFileWriter() {} | 28 AudioDebugFileWriter( |
29 const AudioParameters& params, | |
30 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); | |
31 ~AudioDebugFileWriter(); | |
23 | 32 |
24 // Must be called before calling Write() for the first time after creation or | 33 // Must be called before calling Write() for the first time after creation or |
25 // Stop() call. Can be called on any sequence; Write() and Stop() must be | 34 // Stop() call. Can be called on any sequence; Write() and Stop() must be |
26 // called on the same sequence as Start(). | 35 // called on the same sequence as Start(). |
27 virtual void Start(const base::FilePath& file) = 0; | 36 void Start(const base::FilePath& file); |
28 | 37 |
29 // Must be called to finish recording. Each call to Start() requires a call to | 38 // Must be called to finish recording. Each call to Start() requires a call to |
30 // Stop(). Will be automatically called on destruction. | 39 // Stop(). Will be automatically called on destruction. |
31 virtual void Stop() = 0; | 40 void Stop(); |
32 | 41 |
33 // Write |data| to file. | 42 // Write |data| to file. |
34 virtual void Write(std::unique_ptr<AudioBus> data) = 0; | 43 void Write(std::unique_ptr<AudioBus> data); |
35 | 44 |
36 // Returns true if Write() call scheduled at this point will most likely write | 45 // Returns true if Write() call scheduled at this point will most likely write |
37 // data to the file, and false if it most likely will be a no-op. The result | 46 // data to the file, and false if it most likely will be a no-op. The result |
38 // may be ambigulous if Start() or Stop() is executed at the moment. Can be | 47 // may be ambigulous if Start() or Stop() is executed at the moment. Can be |
39 // called from any sequence. | 48 // called from any sequence. |
40 virtual bool WillWrite() = 0; | 49 bool WillWrite(); |
50 | |
51 private: | |
52 class AudioFileWriter; | |
53 | |
54 // AudioFileWriter deleter. | |
55 struct DeleteOnFileThread { | |
56 void operator()(AudioFileWriter* ptr) const; | |
57 }; | |
58 | |
59 using AudioFileWriterUniquePtr = | |
60 std::unique_ptr<AudioFileWriter, DeleteOnFileThread>; | |
61 | |
62 AudioFileWriterUniquePtr file_writer_; | |
63 const AudioParameters params_; | |
64 base::SequenceChecker client_sequence_checker_; | |
65 | |
66 // The task runner to do file output operations on. | |
67 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | |
41 }; | 68 }; |
DaleCurtis
2017/02/21 18:00:58
DISALLOW_COPY_AND_ASSIGN()
Henrik Grunell
2017/02/22 10:47:43
Done.
| |
42 | 69 |
43 } // namespace media | 70 } // namspace media |
44 | 71 |
45 #endif // MEDIA_AUDIO_AUDIO_FILE_WRITER_H_ | 72 #endif // MEDIA_AUDIO_AUDIO_DEBUG_FILE_WRITER_H_ |
OLD | NEW |