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_H_ | |
6 #define MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 | |
11 // This class handles IPC for single audio output stream by delegating method | |
DaleCurtis
2017/03/06 17:56:12
Comments go on the class not between includes.
Max Morin
2017/03/07 11:23:16
Done.
| |
12 // calls to its AudioOutputDelegate. | |
13 | |
14 #include "base/threading/thread_checker.h" | |
15 #include "media/audio/audio_output_delegate.h" | |
16 #include "media/mojo/interfaces/audio_output.mojom.h" | |
17 #include "media/mojo/services/media_mojo_export.h" | |
18 #include "mojo/public/cpp/bindings/binding.h" | |
19 | |
20 namespace media { | |
21 | |
22 class MEDIA_MOJO_EXPORT MojoAudioOutput | |
23 : public mojom::AudioOutput, | |
24 public AudioOutputDelegate::EventHandler { | |
25 public: | |
26 using StreamCreatedCallback = mojom::AudioOutputProvider::AcquireCallback; | |
27 using CreateDelegateCallback = | |
28 base::OnceCallback<std::unique_ptr<AudioOutputDelegate>( | |
29 AudioOutputDelegate::EventHandler*)>; | |
30 | |
31 // |create_delegate_callback| is used to obtain an AudioOutputDelegate for the | |
32 // stream in the constructor. |stream_created_callback| is called when the | |
33 // stream has been initialized. |deleter_callback| is called when this class | |
34 // should be removed (stream ended/error). |deleter_callback| is required to | |
35 // destroy |this| synchronously. | |
36 MojoAudioOutput(mojom::AudioOutputRequest request, | |
37 CreateDelegateCallback create_delegate_callback, | |
38 StreamCreatedCallback stream_created_callback, | |
39 base::OnceClosure deleter_callback); | |
40 | |
41 ~MojoAudioOutput() override; | |
42 | |
43 private: | |
44 // mojom::AudioOutput implementation. | |
45 void Play() override; | |
46 void Pause() override; | |
47 void SetVolume(double volume) override; | |
48 | |
49 // AudioOutputDelegate::EventHandler implementation. | |
50 void OnStreamCreated(int stream_id, | |
51 base::SharedMemory* shared_memory, | |
52 base::CancelableSyncSocket* foreign_socket) override; | |
53 void OnStreamError(int stream_id) override; | |
54 | |
55 // Closes connection to client and notifies owner. | |
56 void OnError(); | |
57 | |
58 StreamCreatedCallback stream_created_callback_; | |
59 base::OnceClosure deleter_callback_; | |
60 mojo::Binding<AudioOutput> binding_; | |
61 base::ThreadChecker thread_checker_; | |
62 const std::unique_ptr<AudioOutputDelegate> delegate_; | |
63 | |
64 DISALLOW_COPY_AND_ASSIGN(MojoAudioOutput); | |
65 }; | |
66 | |
67 } // namespace media | |
68 | |
69 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_OUTPUT_H_ | |
OLD | NEW |