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

Side by Side Diff: media/audio/audio_debug_file_writer.h

Issue 2885173002: Make AudioDebugFileWriter create its own file worker thread. (Closed)
Patch Set: Remove useless include Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 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 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_DEBUG_FILE_WRITER_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_DEBUG_FILE_WRITER_H_
6 #define MEDIA_AUDIO_AUDIO_DEBUG_FILE_WRITER_H_ 6 #define MEDIA_AUDIO_AUDIO_DEBUG_FILE_WRITER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/sequence_checker.h" 15 #include "base/sequence_checker.h"
16 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/task_scheduler/post_task.h"
18 #include "media/base/audio_parameters.h" 18 #include "media/base/audio_parameters.h"
19 #include "media/base/media_export.h" 19 #include "media/base/media_export.h"
20 20
21 namespace media { 21 namespace media {
22 22
23 class AudioBus; 23 class AudioBus;
24 24
25 // Writes audio data to a 16 bit PCM WAVE file used for debugging purposes. All 25 // Writes audio data to a 16 bit PCM WAVE file used for debugging purposes. All
26 // operations are non-blocking. 26 // operations are non-blocking.
27 // Functions are virtual for the purpose of test mocking. 27 // Functions are virtual for the purpose of test mocking.
28 class MEDIA_EXPORT AudioDebugFileWriter { 28 class MEDIA_EXPORT AudioDebugFileWriter {
29 public: 29 public:
30 // Number of channels and sample rate are used from |params|, the other 30 // Number of channels and sample rate are used from |params|, the other
31 // parameters are ignored. The number of channels in the data passed to 31 // parameters are ignored. The number of channels in the data passed to
32 // Write() must match |params|. 32 // Write() must match |params|.
33 AudioDebugFileWriter( 33 AudioDebugFileWriter(const AudioParameters& params);
34 const AudioParameters& params,
35 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
36 34
37 virtual ~AudioDebugFileWriter(); 35 virtual ~AudioDebugFileWriter();
38 36
39 // Must be called before calling Write() for the first time after creation or 37 // Must be called before calling Write() for the first time after creation or
40 // Stop() call. Can be called on any sequence; Write() and Stop() must be 38 // Stop() call. Can be called on any sequence; Write() and Stop() must be
41 // called on the same sequence as Start(). 39 // called on the same sequence as Start().
42 virtual void Start(const base::FilePath& file); 40 virtual void Start(const base::FilePath& file);
43 41
44 // Must be called to finish recording. Each call to Start() requires a call to 42 // Must be called to finish recording. Each call to Start() requires a call to
45 // Stop(). Will be automatically called on destruction. 43 // Stop(). Will be automatically called on destruction.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 scoped_refptr<base::SequencedTaskRunner> task_runner_; 77 scoped_refptr<base::SequencedTaskRunner> task_runner_;
80 }; 78 };
81 79
82 using AudioFileWriterUniquePtr = 80 using AudioFileWriterUniquePtr =
83 std::unique_ptr<AudioFileWriter, OnSequenceDeleter>; 81 std::unique_ptr<AudioFileWriter, OnSequenceDeleter>;
84 82
85 AudioFileWriterUniquePtr file_writer_; 83 AudioFileWriterUniquePtr file_writer_;
86 base::SequenceChecker client_sequence_checker_; 84 base::SequenceChecker client_sequence_checker_;
87 85
88 // The task runner to do file output operations on. 86 // The task runner to do file output operations on.
89 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 87 const scoped_refptr<base::SequencedTaskRunner> file_task_runner_ =
88 base::CreateSequencedTaskRunnerWithTraits(
89 {base::MayBlock(), base::TaskPriority::BACKGROUND});
90 90
91 DISALLOW_COPY_AND_ASSIGN(AudioDebugFileWriter); 91 DISALLOW_COPY_AND_ASSIGN(AudioDebugFileWriter);
92 }; 92 };
93 93
94 } // namspace media 94 } // namspace media
95 95
96 #endif // MEDIA_AUDIO_AUDIO_DEBUG_FILE_WRITER_H_ 96 #endif // MEDIA_AUDIO_AUDIO_DEBUG_FILE_WRITER_H_
OLDNEW
« no previous file with comments | « content/browser/speech/speech_recognizer_impl.cc ('k') | media/audio/audio_debug_file_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698