audio_output_delegate.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2016 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_OUTPUT_DELEGATE_H_
  5. #define MEDIA_AUDIO_AUDIO_OUTPUT_DELEGATE_H_
  6. #include <memory>
  7. #include "base/memory/ref_counted.h"
  8. #include "media/base/media_export.h"
  9. namespace base {
  10. class UnsafeSharedMemoryRegion;
  11. class CancelableSyncSocket;
  12. }
  13. namespace media {
  14. class MEDIA_EXPORT AudioOutputDelegate {
  15. public:
  16. // An AudioOutputDelegate must not call back to its EventHandler in its
  17. // constructor.
  18. class MEDIA_EXPORT EventHandler {
  19. public:
  20. virtual ~EventHandler() = 0;
  21. // Called when the underlying stream is ready for playout.
  22. virtual void OnStreamCreated(
  23. int stream_id,
  24. base::UnsafeSharedMemoryRegion shared_memory_region,
  25. std::unique_ptr<base::CancelableSyncSocket> socket) = 0;
  26. // Called if stream encounters an error and has become unusable.
  27. virtual void OnStreamError(int stream_id) = 0;
  28. };
  29. virtual ~AudioOutputDelegate() = 0;
  30. virtual int GetStreamId() = 0;
  31. // Stream control:
  32. virtual void OnPlayStream() = 0;
  33. virtual void OnPauseStream() = 0;
  34. virtual void OnFlushStream() = 0;
  35. virtual void OnSetVolume(double volume) = 0;
  36. };
  37. } // namespace media
  38. #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DELEGATE_H_