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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Code review (dalecurtis@ and maxmorin@). Created 3 years, 11 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
(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 {
o1ka 2017/01/20 11:36:26 Switch AudioInputController to using this as well?
o1ka 2017/01/25 17:47:00 Ping?
Henrik Grunell 2017/01/26 10:25:09 Good point. I'll do that.
28 public:
29 AudioDebugRecordingHelper(
30 AudioManager* audio_manager,
31 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
32 ~AudioDebugRecordingHelper();
33
34 // Enable and disable debug recording. When enabled, |audio_manager_| is asked
35 // to create a DebugWriter. Extension "wav" will be added to |file_name|.
36 void EnableDebugRecording(const AudioParameters& params,
37 const base::FilePath& file_name);
38 void DisableDebugRecording();
39
40 // If debug recording is enabled, copies audio data and posts DoWrite() on
41 // |task_runner_|. Can be called on any thread.
42 void MaybeWrite(const AudioBus* source);
43
44 // Pass-through to AudioFileWriter::WillWrite(). Can be called on any thread.
45 bool WillWrite();
46
47 private:
48 // Writes debug data to |debug_writer_|.
49 void DoWrite(std::unique_ptr<media::AudioBus> data);
50
51 AudioManager* audio_manager_;
52 std::unique_ptr<AudioFileWriter> debug_writer_;
53 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
o1ka 2017/01/20 11:36:26 Add a comment what |task_runner_| is for?
Henrik Grunell 2017/01/26 10:25:09 Done.
54
55 base::WeakPtrFactory<AudioDebugRecordingHelper> weak_factory_;
56 DISALLOW_COPY_AND_ASSIGN(AudioDebugRecordingHelper);
57 };
58
59 } // namspace media
60
61 #endif // MEDIA_AUDIO_AUDIO_DEBUG_RECORDING_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698