OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 |
| 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_STREAM_PROVIDER_H_ |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_STREAM_PROVIDER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/threading/thread_checker.h" |
| 12 #include "media/audio/audio_output_delegate.h" |
| 13 #include "media/mojo/interfaces/audio_output_stream.mojom.h" |
| 14 #include "media/mojo/services/media_mojo_export.h" |
| 15 #include "media/mojo/services/mojo_audio_output_stream.h" |
| 16 #include "mojo/public/cpp/bindings/binding.h" |
| 17 |
| 18 namespace media { |
| 19 |
| 20 // Provides a single AudioOutput, given the audio parameters to use. |
| 21 class MEDIA_MOJO_EXPORT MojoAudioOutputStreamProvider |
| 22 : NON_EXPORTED_BASE(public mojom::AudioOutputStreamProvider) { |
| 23 public: |
| 24 using CreateDelegateCallback = |
| 25 base::OnceCallback<std::unique_ptr<AudioOutputDelegate>( |
| 26 const AudioParameters& params, |
| 27 AudioOutputDelegate::EventHandler*)>; |
| 28 using DeleterCallback = base::Callback<void(AudioOutputStreamProvider*)>; |
| 29 |
| 30 // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the |
| 31 // AudioOutput when it's initialized and |deleter_callback| is called when |
| 32 // this class should be removed (stream ended/error). |deleter_callback| is |
| 33 // required to destroy |this| synchronously. |
| 34 MojoAudioOutputStreamProvider(mojom::AudioOutputStreamProviderRequest request, |
| 35 CreateDelegateCallback create_delegate_callback, |
| 36 DeleterCallback deleter_callback); |
| 37 |
| 38 ~MojoAudioOutputStreamProvider() override; |
| 39 |
| 40 private: |
| 41 // mojom::AudioOutputStreamProvider implementation. |
| 42 void Acquire(mojom::AudioOutputStreamRequest stream_request, |
| 43 const AudioParameters& params, |
| 44 const AcquireCallback& acquire_callback) override; |
| 45 |
| 46 // The callback for the Acquire() must be stored until the response is ready. |
| 47 AcquireCallback acquire_callback_; |
| 48 |
| 49 base::Optional<MojoAudioOutputStream> audio_output_; |
| 50 mojo::Binding<AudioOutputStreamProvider> binding_; |
| 51 CreateDelegateCallback create_delegate_callback_; |
| 52 base::Closure deleter_callback_; |
| 53 base::ThreadChecker thread_checker_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(MojoAudioOutputStreamProvider); |
| 56 }; |
| 57 |
| 58 } // namespace media |
| 59 |
| 60 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_STREAM_PROVIDER_H_ |
OLD | NEW |