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

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

Issue 2582703003: Audio output debug recording. (Closed)
Patch Set: Using callbacks instead. 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
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/macros.h" 10 #include "base/macros.h"
(...skipping 13 matching lines...) Expand all
24 // AudioConverter class for details on the conversion process. 24 // AudioConverter class for details on the conversion process.
25 // 25 //
26 // AOR works by intercepting the AudioSourceCallback provided to StartStream() 26 // AOR works by intercepting the AudioSourceCallback provided to StartStream()
27 // and redirecting it through an AudioConverter instance. 27 // and redirecting it through an AudioConverter instance.
28 // 28 //
29 // AOR will automatically fall back from AUDIO_PCM_LOW_LATENCY to 29 // AOR will automatically fall back from AUDIO_PCM_LOW_LATENCY to
30 // AUDIO_PCM_LINEAR if the output device fails to open at the requested output 30 // AUDIO_PCM_LINEAR if the output device fails to open at the requested output
31 // parameters. If opening still fails, it will fallback to AUDIO_FAKE. 31 // parameters. If opening still fails, it will fallback to AUDIO_FAKE.
32 class MEDIA_EXPORT AudioOutputResampler : public AudioOutputDispatcher { 32 class MEDIA_EXPORT AudioOutputResampler : public AudioOutputDispatcher {
33 public: 33 public:
34 // Callbacks for debug recording. RegisterDebugRecordingSourceCallback is used
35 // for registering a stream so that recording can be setup. The Unregister-
36 // counterpart ungeisters for shutting down recording. DebugRecordingCallback
37 // is used for passing data. The int in all callbacks is a unique id to
38 // identify the stream.
39 using RegisterDebugRecordingSourceCallback =
40 base::Callback<void(int, const AudioParameters&)>;
41 using UnregisterDebugRecordingSourceCallback = base::Callback<void(int)>;
42 using DebugRecordingCallback = base::Callback<void(int, AudioBus*)>;
43
34 AudioOutputResampler(AudioManager* audio_manager, 44 AudioOutputResampler(AudioManager* audio_manager,
35 const AudioParameters& input_params, 45 const AudioParameters& input_params,
36 const AudioParameters& output_params, 46 const AudioParameters& output_params,
37 const std::string& output_device_id, 47 const std::string& output_device_id,
38 const base::TimeDelta& close_delay); 48 const base::TimeDelta& close_delay);
39 ~AudioOutputResampler() override; 49 ~AudioOutputResampler() override;
40 50
41 // AudioOutputDispatcher interface. 51 // AudioOutputDispatcher interface.
42 AudioOutputProxy* CreateStreamProxy() override; 52 AudioOutputProxy* CreateStreamProxy() override;
43 bool OpenStream() override; 53 bool OpenStream() override;
44 bool StartStream(AudioOutputStream::AudioSourceCallback* callback, 54 bool StartStream(AudioOutputStream::AudioSourceCallback* callback,
45 AudioOutputProxy* stream_proxy) override; 55 AudioOutputProxy* stream_proxy) override;
46 void StopStream(AudioOutputProxy* stream_proxy) override; 56 void StopStream(AudioOutputProxy* stream_proxy) override;
47 void StreamVolumeSet(AudioOutputProxy* stream_proxy, double volume) override; 57 void StreamVolumeSet(AudioOutputProxy* stream_proxy, double volume) override;
48 void CloseStream(AudioOutputProxy* stream_proxy) override; 58 void CloseStream(AudioOutputProxy* stream_proxy) override;
49 59
60 // Sets debug recording callbacks. See comment on callback definitions above.
61 void SetDebugRecordingCallbacks(
62 const RegisterDebugRecordingSourceCallback&
63 register_debug_recording_source_callback,
64 const UnregisterDebugRecordingSourceCallback&
65 unregister_debug_recording_source_callback,
66 const DebugRecordingCallback& debug_recording_callback);
67
50 private: 68 private:
51 using CallbackMap = 69 using CallbackMap =
52 std::map<AudioOutputProxy*, std::unique_ptr<OnMoreDataConverter>>; 70 std::map<AudioOutputProxy*, std::unique_ptr<OnMoreDataConverter>>;
53 71
54 // Converts low latency based output parameters into high latency 72 // Converts low latency based output parameters into high latency
55 // appropriate output parameters in error situations. 73 // appropriate output parameters in error situations.
56 void SetupFallbackParams(); 74 void SetupFallbackParams();
57 75
58 // Used to reinitialize |dispatcher_|. 76 // Used to reinitialize |dispatcher_|.
59 void Reinitialize(); 77 void Reinitialize();
(...skipping 23 matching lines...) Expand all
83 // Whether any streams have been opened through |dispatcher_|, if so we can't 101 // Whether any streams have been opened through |dispatcher_|, if so we can't
84 // fallback on future OpenStream() failures. 102 // fallback on future OpenStream() failures.
85 bool streams_opened_; 103 bool streams_opened_;
86 104
87 // The reinitialization timer provides a way to recover from temporary failure 105 // 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 106 // 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 107 // have been created within |close_delay_|. Without this, audio may be lost
90 // to a fake stream indefinitely for transient errors. 108 // to a fake stream indefinitely for transient errors.
91 base::Timer reinitialize_timer_; 109 base::Timer reinitialize_timer_;
92 110
111 // Used for audio debug recordings. See comment on callback definitions above.
112 RegisterDebugRecordingSourceCallback
113 register_debug_recording_source_callback_;
114 UnregisterDebugRecordingSourceCallback
115 unregister_debug_recording_source_callback_;
116 DebugRecordingCallback debug_recording_callback_;
117
93 base::WeakPtrFactory<AudioOutputResampler> weak_factory_; 118 base::WeakPtrFactory<AudioOutputResampler> weak_factory_;
94 DISALLOW_COPY_AND_ASSIGN(AudioOutputResampler); 119 DISALLOW_COPY_AND_ASSIGN(AudioOutputResampler);
95 }; 120 };
96 121
97 } // namespace media 122 } // namespace media
98 123
99 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_ 124 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_RESAMPLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698