OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_ | |
6 #define CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "content/browser/renderer_host/media/audio_renderer_host.h" | |
10 #include "media/mojo/interfaces/audio_output.mojom.h" | |
11 #include "mojo/public/cpp/bindings/interface_request.h" | |
12 #include "mojo/public/cpp/bindings/strong_binding.h" | |
13 | |
14 namespace content { | |
15 class AudioOutputStreamImpl; | |
16 | |
17 // This class implements AudioOutput Mojo interface. It will be used | |
18 // by the AudioOutputClient to perform operations on audio output streams. | |
Henrik Grunell
2016/05/20 13:35:40
This isn't really correct. AudioOutputClient doesn
rchtara
2016/05/27 15:24:37
Done.
| |
19 // AudioOutputClient is going to perform operations remotely and Mojo will | |
20 // transfer them to AudioOutputImpl. | |
21 // This class must always be accessed from the creation thread. | |
22 class CONTENT_EXPORT AudioOutputImpl | |
23 : NON_EXPORTED_BASE(public media::mojom::AudioOutput) { | |
24 public: | |
25 explicit AudioOutputImpl(RenderProcessHost* process_, | |
Henrik Grunell
2016/05/20 13:35:40
No trailing _
rchtara
2016/05/27 15:24:37
Done.
| |
26 int render_frame_id, | |
27 media::mojom::AudioOutputRequest request); | |
28 | |
29 ~AudioOutputImpl() override; | |
30 | |
31 // Creates a Mojo service. | |
32 static void CreateService( | |
33 RenderProcessHost* process_, | |
34 int render_frame_id, | |
35 media::mojom::AudioOutputRequest request); | |
36 // Initialized Mojo service on the IO thread. The service is bound to the | |
tommi (sloooow) - chröme
2016/05/20 13:26:12
add an empty line above this one.
Should the firs
Henrik Grunell
2016/05/20 13:35:40
Empty line before comment.
rchtara
2016/05/27 15:24:36
Done.
rchtara
2016/05/27 15:24:37
It doesn't return anything. it just initialize ser
| |
37 // IO thread so future Mojo calls performed by the AudioOutputClient to the | |
38 // AudioOutput interface will be run on that thread. | |
39 // There are a lot of dependencies used in audio output that require to be | |
40 // called on the IO thread, this is why we initialize Mojo service on this | |
41 // thread. There is a plan to enable these dependencies to run on another | |
Henrik Grunell
2016/05/20 13:35:40
I don't think there is a plan for doing that here
rchtara
2016/05/27 15:24:37
Done.
| |
42 // thread and move the Mojo service to this thread as IO thread is very | |
43 // performance sensitive and we want to move stuff off it. | |
44 static void CreateServiceOnIOThread( | |
45 RenderProcessHost* process_, | |
tommi (sloooow) - chröme
2016/05/20 13:26:12
process (no underscore for params)
rchtara
2016/05/27 15:24:37
Done.
| |
46 int render_frame_id, | |
47 media::mojom::AudioOutputRequest request); | |
tommi (sloooow) - chröme
2016/05/20 13:26:12
passed by value on purpose?
rchtara
2016/05/27 15:24:37
yes, it's going to be initialized in RenderFrameHo
| |
48 | |
49 // Called by AudioRendererHost::DoCompleteCreation to create the streams. | |
50 virtual media::mojom::AudioOutputStreamPtr StreamFactory( | |
51 int stream_id, | |
52 int render_frame_id, | |
53 AudioRendererHost* audio_renderer_host); | |
54 | |
55 virtual bool RemoveStream(int stream_id); | |
56 | |
57 private: | |
58 friend class AudioOutputImplTest; | |
59 friend class MockAudioOutputImpl; | |
60 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, CreateStream); | |
61 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, StreamFactory); | |
62 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, RemoveStream); | |
63 // AudioOutput interface implementation. | |
Henrik Grunell
2016/05/20 13:35:39
Empty line before comment.
rchtara
2016/05/27 15:24:37
Done.
| |
64 void CreateStream(int stream_id, | |
65 const media::AudioParameters& params, | |
66 const CreateStreamCallback& callback) override; | |
67 | |
68 RenderProcessHost* process_; | |
69 int render_frame_id_; | |
70 mojo::Binding<AudioOutput> binding_; | |
71 std::map<int, std::unique_ptr<AudioOutputStreamImpl>> stream_impls_; | |
tommi (sloooow) - chröme
2016/05/20 13:26:12
can you add information about this map? (maps from
Henrik Grunell
2016/05/20 13:35:39
Comment on why this is needed. It's just for owner
rchtara
2016/05/27 15:24:36
Done.
| |
72 base::Callback<AudioOutputStreamImpl*( | |
73 media::mojom::AudioOutputStreamRequest request, | |
74 int stream_id, | |
75 int renderer_frame_id, | |
76 AudioRendererHost* audio_renderer_host)> | |
tommi (sloooow) - chröme
2016/05/20 13:26:12
can you create a typedef for this?
rchtara
2016/05/27 15:24:37
Done.
Henrik Grunell
2016/05/30 12:44:56
Or preferable "using".
| |
77 factory_; | |
Henrik Grunell
2016/05/20 13:35:40
Indentation seems odd. Run git cl format.
rchtara
2016/05/27 15:24:37
Done.
| |
78 DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl); | |
Henrik Grunell
2016/05/20 13:35:40
Empty line before.
rchtara
2016/05/27 15:24:36
Done.
| |
79 }; | |
80 | |
81 } // namespace content | |
82 | |
83 #endif // CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_ | |
OLD | NEW |