log_factory_adapter.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2018 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_LOG_FACTORY_ADAPTER_H_
  5. #define SERVICES_AUDIO_LOG_FACTORY_ADAPTER_H_
  6. #include <memory>
  7. #include "base/containers/queue.h"
  8. #include "media/audio/audio_logging.h"
  9. #include "media/audio/fake_audio_log_factory.h"
  10. #include "media/mojo/mojom/audio_logging.mojom.h"
  11. #include "mojo/public/cpp/bindings/pending_remote.h"
  12. #include "mojo/public/cpp/bindings/remote.h"
  13. #include "services/audio/public/mojom/log_factory_manager.mojom.h"
  14. namespace media {
  15. class AudioLogFactory;
  16. } // namespace media
  17. namespace audio {
  18. // This class allows setting a mojo audio log factory to create audio logs
  19. // in the audio service. It also acts as a media::AudioLogFactory to interface
  20. // with AudioManager.
  21. class LogFactoryAdapter final : public media::AudioLogFactory {
  22. public:
  23. LogFactoryAdapter();
  24. LogFactoryAdapter(const LogFactoryAdapter&) = delete;
  25. LogFactoryAdapter& operator=(const LogFactoryAdapter&) = delete;
  26. ~LogFactoryAdapter() final;
  27. void SetLogFactory(
  28. mojo::PendingRemote<media::mojom::AudioLogFactory> log_factory);
  29. // media::AudioLogFactory implementation
  30. std::unique_ptr<media::AudioLog> CreateAudioLog(AudioComponent component,
  31. int component_id) override;
  32. private:
  33. struct PendingLogRequest;
  34. mojo::Remote<media::mojom::AudioLogFactory> log_factory_;
  35. base::queue<PendingLogRequest> pending_requests_;
  36. media::FakeAudioLogFactory fake_log_factory_;
  37. };
  38. } // namespace audio
  39. #endif // SERVICES_AUDIO_LOG_FACTORY_ADAPTER_H_