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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Changed to record in AudioOutputResampler. 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
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_resampler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_OUTPUT_RESAMPLER_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_ 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/files/file_path.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
13 #include "media/audio/audio_io.h" 14 #include "media/audio/audio_io.h"
14 #include "media/audio/audio_manager.h" 15 #include "media/audio/audio_manager.h"
15 #include "media/audio/audio_output_dispatcher_impl.h" 16 #include "media/audio/audio_output_dispatcher_impl.h"
16 #include "media/base/audio_parameters.h" 17 #include "media/base/audio_parameters.h"
17 18
18 namespace media { 19 namespace media {
19 20
(...skipping 20 matching lines...) Expand all
40 41
41 // AudioOutputDispatcher interface. 42 // AudioOutputDispatcher interface.
42 AudioOutputProxy* CreateStreamProxy() override; 43 AudioOutputProxy* CreateStreamProxy() override;
43 bool OpenStream() override; 44 bool OpenStream() override;
44 bool StartStream(AudioOutputStream::AudioSourceCallback* callback, 45 bool StartStream(AudioOutputStream::AudioSourceCallback* callback,
45 AudioOutputProxy* stream_proxy) override; 46 AudioOutputProxy* stream_proxy) override;
46 void StopStream(AudioOutputProxy* stream_proxy) override; 47 void StopStream(AudioOutputProxy* stream_proxy) override;
47 void StreamVolumeSet(AudioOutputProxy* stream_proxy, double volume) override; 48 void StreamVolumeSet(AudioOutputProxy* stream_proxy, double volume) override;
48 void CloseStream(AudioOutputProxy* stream_proxy) override; 49 void CloseStream(AudioOutputProxy* stream_proxy) override;
49 50
51 // Controls debug recording.
DaleCurtis 2017/01/24 01:12:02 It seems like this should just be something like S
52 void EnableDebugRecording(const base::FilePath& file_name);
53 void DisableDebugRecording();
54
50 private: 55 private:
51 using CallbackMap = 56 using CallbackMap =
52 std::map<AudioOutputProxy*, std::unique_ptr<OnMoreDataConverter>>; 57 std::map<AudioOutputProxy*, std::unique_ptr<OnMoreDataConverter>>;
53 58
54 // Converts low latency based output parameters into high latency 59 // Converts low latency based output parameters into high latency
55 // appropriate output parameters in error situations. 60 // appropriate output parameters in error situations.
56 void SetupFallbackParams(); 61 void SetupFallbackParams();
57 62
58 // Used to reinitialize |dispatcher_|. 63 // Used to reinitialize |dispatcher_|.
59 void Reinitialize(); 64 void Reinitialize();
60 65
61 // Used to initialize |dispatcher_|. 66 // Used to initialize |dispatcher_|.
62 void Initialize(); 67 void Initialize();
63 68
64 // Stops the stream corresponding to the |item| in |callbacks_|. 69 // Stops the stream corresponding to the |item| in |callbacks_|.
65 void StopStreamInternal(const CallbackMap::value_type& item); 70 void StopStreamInternal(const CallbackMap::value_type& item);
66 71
72 // Helper function that conditionally starts debug recording.
73 void MaybeStartDebugRecording();
74
75 // The AudioManager that creates us.
76 AudioManager* audio_manager_;
77
67 // Dispatcher to proxy all AudioOutputDispatcher calls too. 78 // Dispatcher to proxy all AudioOutputDispatcher calls too.
68 std::unique_ptr<AudioOutputDispatcherImpl> dispatcher_; 79 std::unique_ptr<AudioOutputDispatcherImpl> dispatcher_;
69 80
70 // Map of outstanding OnMoreDataConverter objects. A new object is created 81 // Map of outstanding OnMoreDataConverter objects. A new object is created
71 // on every StartStream() call and destroyed on CloseStream(). 82 // on every StartStream() call and destroyed on CloseStream().
72 CallbackMap callbacks_; 83 CallbackMap callbacks_;
73 84
74 // Used by AudioOutputDispatcherImpl; kept so we can reinitialize on the fly. 85 // Used by AudioOutputDispatcherImpl; kept so we can reinitialize on the fly.
75 base::TimeDelta close_delay_; 86 base::TimeDelta close_delay_;
76 87
77 // AudioParameters used to setup the output stream; changed upon fallback. 88 // AudioParameters used to setup the output stream; changed upon fallback.
78 AudioParameters output_params_; 89 AudioParameters output_params_;
79 90
80 // The original AudioParameters we were constructed with. 91 // The original AudioParameters we were constructed with.
81 const AudioParameters original_output_params_; 92 const AudioParameters original_output_params_;
82 93
83 // Whether any streams have been opened through |dispatcher_|, if so we can't 94 // Whether any streams have been opened through |dispatcher_|, if so we can't
84 // fallback on future OpenStream() failures. 95 // fallback on future OpenStream() failures.
85 bool streams_opened_; 96 bool streams_opened_;
86 97
87 // The reinitialization timer provides a way to recover from temporary failure 98 // The reinitialization timer provides a way to recover from temporary failure
88 // states by clearing the dispatcher if all proxies have been closed and none 99 // states by clearing the dispatcher if all proxies have been closed and none
89 // have been created within |close_delay_|. Without this, audio may be lost 100 // have been created within |close_delay_|. Without this, audio may be lost
90 // to a fake stream indefinitely for transient errors. 101 // to a fake stream indefinitely for transient errors.
91 base::Timer reinitialize_timer_; 102 base::Timer reinitialize_timer_;
92 103
104 // Used for audio debug recordings. The file name is stored when enabling to
105 // be able to enable on new OnMoreDataConverters.
106 base::FilePath debug_recording_file_name_;
107
93 base::WeakPtrFactory<AudioOutputResampler> weak_factory_; 108 base::WeakPtrFactory<AudioOutputResampler> weak_factory_;
94 DISALLOW_COPY_AND_ASSIGN(AudioOutputResampler); 109 DISALLOW_COPY_AND_ASSIGN(AudioOutputResampler);
95 }; 110 };
96 111
97 } // namespace media 112 } // namespace media
98 113
99 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_ 114 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.cc ('k') | media/audio/audio_output_resampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698