Chromium Code Reviews| Index: media/base/audio_logging.h |
| diff --git a/media/base/audio_logging.h b/media/base/audio_logging.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b420fbc31e01089839c90e87bc9a006a7e78d74a |
| --- /dev/null |
| +++ b/media/base/audio_logging.h |
| @@ -0,0 +1,84 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_BASE_AUDIO_LOGGING_H_ |
|
acolwell GONE FROM CHROMIUM
2013/11/21 00:53:58
It seems like media/audio would be a better home f
DaleCurtis
2013/11/21 01:18:30
Done.
|
| +#define MEDIA_BASE_AUDIO_LOGGING_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +namespace media { |
| +class AudioParameters; |
|
acolwell GONE FROM CHROMIUM
2013/11/21 00:53:58
nit: move this down into the media namespace below
DaleCurtis
2013/11/21 01:18:30
Done.
|
| +} |
| + |
| +namespace media { |
| + |
| +// AudioLog logs state information about an active audio component. Each method |
| +// takes a |component_id|, a monotonically increasing integer, along with method |
|
acolwell GONE FROM CHROMIUM
2013/11/21 00:53:58
nit: Why is the monotonically increasing character
DaleCurtis
2013/11/21 01:18:30
It'd be nice if they were, but you're right that's
|
| +// specific information. Its methods are safe to call from any thread. |
| +class AudioLog { |
| + public: |
| + // Called when an audio component is created. |params| are the parameters of |
| + // the created stream. |input_device_id| and |output_device_id| are the |
| + // respective device ids for input and output. Either one or both may be |
| + // specified. |
| + virtual void OnCreated(int component_id, |
| + const media::AudioParameters& params, |
| + const std::string& input_device_id, |
| + const std::string& output_device_id) = 0; |
| + |
| + // Called when an audio component is started, generally this is synonymous |
| + // with "playing." |
| + virtual void OnStarted(int component_id) = 0; |
| + |
| + // Called when an audio component is stopped, generally this is synonymous |
| + // with "paused." |
| + virtual void OnStopped(int component_id) = 0; |
| + |
| + // Called when an audio component is deleted, generally this is synonymous |
| + // with "closed." |
| + virtual void OnDeleted(int component_id) = 0; |
| + |
| + // Called when an audio component changes volume. |volume| is the new volume. |
| + virtual void OnSetVolume(int component_id, double volume) = 0; |
| + |
| + protected: |
| + virtual ~AudioLog() {} |
| +}; |
| + |
| +// AudioLogDispenser dispenses AudioLog instances to owning classes for tracking |
| +// AudioComponent behavior. All AudioComponents have the concept of an owning |
| +// class: |
| +// |
| +// - AudioInputRendererHost for AudioInputController |
| +// - AudioRendererHost for AudioOutputController |
| +// - AudioOutputDispatcherImpl for AudioOutputStream |
| +// |
| +// Each of these owning classes may own multiple instances of each component, as |
| +// such each AudioLog supports logging for multiple instances. |
| +class AudioLogDispenser { |
|
acolwell GONE FROM CHROMIUM
2013/11/21 00:53:58
nit: s/Dispenser/Factory since this appears to be
DaleCurtis
2013/11/21 01:18:30
Done.
|
| + public: |
| + enum AudioComponent { |
| + // Input controllers have a 1:1 mapping with streams, so there's no need to |
| + // track both controllers and streams. |
| + AUDIO_INPUT_CONTROLLER, |
| + // Output controllers may or may not be backed by an active stream, so we |
| + // need to track both controllers and streams. |
| + AUDIO_OUTPUT_CONTROLLER, |
| + AUDIO_OUTPUT_STREAM, |
| + }; |
| + |
| + // Create a new AudioLog object for tracking the behavior for one or more |
| + // instances of the given component. Each instance of an "owning" class must |
| + // create its own AudioLog. |
| + virtual scoped_ptr<AudioLog> CreateAudioLog(AudioComponent component) = 0; |
| + |
| + protected: |
| + virtual ~AudioLogDispenser() {} |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_BASE_AUDIO_LOGGING_H_ |