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_PROVIDER_H_ | |
6 #define MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_PROVIDER_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 // Provides a single AudioOutput, given the audio parameters to use. | |
12 | |
13 #include "base/threading/thread_checker.h" | |
14 #include "media/audio/audio_output_delegate.h" | |
15 #include "media/mojo/interfaces/audio_output.mojom.h" | |
16 #include "media/mojo/services/media_mojo_export.h" | |
17 #include "media/mojo/services/mojo_audio_output.h" | |
18 #include "mojo/public/cpp/bindings/binding.h" | |
19 | |
20 namespace media { | |
21 | |
22 class MEDIA_MOJO_EXPORT MojoAudioOutputProvider | |
23 : public mojom::AudioOutputProvider { | |
24 public: | |
25 using CreateDelegateCallback = | |
26 base::OnceCallback<std::unique_ptr<AudioOutputDelegate>( | |
27 const AudioParameters& params, | |
28 AudioOutputDelegate::EventHandler*)>; | |
29 using DeleterCallback = base::OnceCallback<void(mojom::AudioOutputProvider*)>; | |
30 | |
31 // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the | |
32 // AudioOutput when it's initialized and |deleter_callback| is called when | |
33 // this class should be removed (stream ended/error). |deleter_callback| is | |
34 // required to destroy |this| synchronously. | |
35 MojoAudioOutputProvider(AudioOutputProviderRequest request, | |
36 CreateDelegateCallback create_delegate_callback, | |
37 DeleterCallback deleter_callback); | |
38 | |
39 ~MojoAudioOutputProvider() override; | |
40 | |
41 private: | |
42 // mojom::AudioOutput implementation. | |
43 void Acquire(AudioParameters params, | |
44 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<AudioOutput> audio_output_; | |
50 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
| |
51 DeleterCallback deleter_callback_; | |
52 base::ThreadChecker thread_checker_; | |
o1ka
2017/03/07 00:49:24
Not used?
Max Morin
2017/03/07 11:23:16
Done.
| |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(MojoAudioOutputProvider); | |
55 }; | |
56 | |
57 } // namespace media | |
58 | |
59 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_PROVIDER_H_ | |
OLD | NEW |