audio_logging.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright 2013 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. #ifndef MEDIA_AUDIO_AUDIO_LOGGING_H_
  5. #define MEDIA_AUDIO_AUDIO_LOGGING_H_
  6. #include <memory>
  7. #include <string>
  8. namespace media {
  9. class AudioParameters;
  10. // AudioLog logs state information about an active audio component.
  11. class AudioLog {
  12. public:
  13. virtual ~AudioLog() {}
  14. // Called when an audio component is created. |params| are the parameters of
  15. // the created stream. |device_id| is the id of the audio device opened by
  16. // the created stream.
  17. virtual void OnCreated(const media::AudioParameters& params,
  18. const std::string& device_id) = 0;
  19. // Called when an audio component is started, generally this is synonymous
  20. // with "playing."
  21. virtual void OnStarted() = 0;
  22. // Called when an audio component is stopped, generally this is synonymous
  23. // with "paused."
  24. virtual void OnStopped() = 0;
  25. // Called when an audio component is closed, generally this is synonymous
  26. // with "deleted."
  27. virtual void OnClosed() = 0;
  28. // Called when an audio component encounters an error.
  29. virtual void OnError() = 0;
  30. // Called when an audio component changes volume. |volume| is the new volume.
  31. virtual void OnSetVolume(double volume) = 0;
  32. // Called with information about audio processing set-up for an audio
  33. // component.
  34. virtual void OnProcessingStateChanged(const std::string& message) = 0;
  35. // Called when an audio component wants to forward a log message.
  36. virtual void OnLogMessage(const std::string& message) = 0;
  37. };
  38. // AudioLogFactory dispenses AudioLog instances for tracking AudioComponent
  39. // behavior.
  40. class AudioLogFactory {
  41. public:
  42. enum AudioComponent {
  43. // Input controllers have a 1:1 mapping with streams, so there's no need to
  44. // track both controllers and streams.
  45. AUDIO_INPUT_CONTROLLER,
  46. // Output controllers may or may not be backed by an active stream, so we
  47. // need to track both controllers and streams.
  48. AUDIO_OUTPUT_CONTROLLER,
  49. AUDIO_OUTPUT_STREAM,
  50. AUDIO_COMPONENT_MAX
  51. };
  52. // Create a new AudioLog object for tracking the behavior for one instance of
  53. // the given component. Each instance of an "owning" class must create its
  54. // own AudioLog.
  55. virtual std::unique_ptr<AudioLog> CreateAudioLog(AudioComponent component,
  56. int component_id) = 0;
  57. protected:
  58. virtual ~AudioLogFactory() {}
  59. };
  60. } // namespace media
  61. #endif // MEDIA_AUDIO_AUDIO_LOGGING_H_