Chromium Code Reviews| Index: media/mojo/services/mojo_audio_output_provider.h |
| diff --git a/media/mojo/services/mojo_audio_output_provider.h b/media/mojo/services/mojo_audio_output_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..40a460b371a4887b2aa2a4876603d7529daffea1 |
| --- /dev/null |
| +++ b/media/mojo/services/mojo_audio_output_provider.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_PROVIDER_H_ |
| +#define MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_PROVIDER_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +// Provides a single AudioOutput, given the audio parameters to use. |
| + |
| +#include "base/threading/thread_checker.h" |
| +#include "media/audio/audio_output_delegate.h" |
| +#include "media/mojo/interfaces/audio_output.mojom.h" |
| +#include "media/mojo/services/media_mojo_export.h" |
| +#include "media/mojo/services/mojo_audio_output.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| + |
| +namespace media { |
| + |
| +class MEDIA_MOJO_EXPORT MojoAudioOutputProvider |
| + : public mojom::AudioOutputProvider { |
| + public: |
| + using CreateDelegateCallback = |
| + base::OnceCallback<std::unique_ptr<AudioOutputDelegate>( |
| + const AudioParameters& params, |
| + AudioOutputDelegate::EventHandler*)>; |
| + using DeleterCallback = base::OnceCallback<void(mojom::AudioOutputProvider*)>; |
| + |
| + // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the |
| + // AudioOutput when it's initialized and |deleter_callback| is called when |
| + // this class should be removed (stream ended/error). |deleter_callback| is |
| + // required to destroy |this| synchronously. |
| + MojoAudioOutputProvider(AudioOutputProviderRequest request, |
| + CreateDelegateCallback create_delegate_callback, |
| + DeleterCallback deleter_callback); |
| + |
| + ~MojoAudioOutputProvider() override; |
| + |
| + private: |
| + // mojom::AudioOutput implementation. |
| + void Acquire(AudioParameters params, |
| + AcquireCallback acquire_callback) override; |
| + |
| + // The callback for the Acquire() must be stored until the response is ready. |
| + AcquireCallback acquire_callback_; |
| + |
| + base::Optional<AudioOutput> audio_output_; |
| + mojo::Binding<AudioOutputProvider*> binding_; |
|
o1ka
2017/03/07 00:49:24
How will delete AudioOutputProvider if a connectio
Max Morin
2017/03/07 11:23:17
I fixed this (added connection error handler to bi
|
| + DeleterCallback deleter_callback_; |
| + base::ThreadChecker thread_checker_; |
|
o1ka
2017/03/07 00:49:24
Not used?
Max Morin
2017/03/07 11:23:16
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(MojoAudioOutputProvider); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_PROVIDER_H_ |