reference_output.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2021 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 SERVICES_AUDIO_REFERENCE_OUTPUT_H_
  5. #define SERVICES_AUDIO_REFERENCE_OUTPUT_H_
  6. #include "base/time/time.h"
  7. namespace media {
  8. class AudioBus;
  9. } // namespace media
  10. namespace audio {
  11. class ReferenceOutput {
  12. public:
  13. class Listener {
  14. public:
  15. // Provides read-only access to the auio played by ReferenceOutput.
  16. // Must execute quickly, as it will typically be called on a realtime
  17. // thread; otherwise, audio glitches may occur.
  18. virtual void OnPlayoutData(const media::AudioBus& audio_bus,
  19. int sample_rate,
  20. base::TimeDelta audio_delay) = 0;
  21. protected:
  22. virtual ~Listener() = default;
  23. };
  24. // Starts/Stops listening to the reference output.
  25. virtual void StartListening(Listener* listener) = 0;
  26. virtual void StopListening(Listener* listener) = 0;
  27. protected:
  28. virtual ~ReferenceOutput() = default;
  29. };
  30. } // namespace audio
  31. #endif // SERVICES_AUDIO_REFERENCE_OUTPUT_H_