Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2063)

Side by Side Diff: content/browser/media/audio_output_impl.h

Issue 1930393002: Switch stream creation and closing in Chrome audio rendering from IPC to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use wrap Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "base/sync_socket.h"
10 #include "content/browser/renderer_host/media/audio_renderer_host.h"
11 #include "media/mojo/interfaces/audio_output.mojom.h"
12 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h"
14
15 namespace base {
16 class SharedMemory;
17 }
18
19 namespace content {
20
21 class AudioOutputStreamImpl;
22
23 // This class implements AudioOutput Mojo interface. It will be used
nasko 2016/05/25 20:50:42 nit: "will" or "is"?
rchtara 2016/05/27 15:24:39 Done.
24 // by the AudioOutputClient to perform operations on audio output streams.
25 // AudioOutputClient is going to perform operations remotely and Mojo will
nasko 2016/05/25 20:50:42 In general, you should avoid using future tense in
rchtara 2016/05/27 15:24:38 Done.
26 // transfer them to AudioOutputImpl.
27 // This class must always be accessed from the creation thread.
28 class CONTENT_EXPORT AudioOutputImpl
29 : NON_EXPORTED_BASE(public media::mojom::AudioOutput) {
30 public:
31 explicit AudioOutputImpl(RenderProcessHost* process_,
32 int render_frame_id,
33 media::mojom::AudioOutputRequest request);
34
35 ~AudioOutputImpl() override;
36
37 // Creates a Mojo service.
38 static void CreateService(RenderProcessHost* process_,
39 int render_frame_id,
40 media::mojom::AudioOutputRequest request);
41 // Initialized Mojo service on the IO thread. The service is bound to the
nasko 2016/05/25 20:50:42 Empty line before comment.
rchtara 2016/05/27 15:24:39 Done.
42 // IO thread so future Mojo calls performed by the AudioOutputClient to the
43 // AudioOutput interface will be run on that thread.
44 // There are a lot of dependencies used in audio output that require to be
45 // called on the IO thread, this is why we initialize Mojo service on this
46 // thread. There is a plan to enable these dependencies to run on another
nasko 2016/05/25 20:50:42 nit: Put this plan on a new line with TODO(): pref
47 // thread and move the Mojo service to this thread as IO thread is very
nasko 2016/05/25 20:50:42 nit: Overuse of the word "thread" and the comment
48 // performance sensitive and we want to move stuff off it.
49 static void CreateServiceOnIOThread(RenderProcessHost* process_,
nasko 2016/05/25 20:50:42 No underscores on parameters, those are reserved f
rchtara 2016/05/27 15:24:39 Done.
50 int render_frame_id,
51 media::mojom::AudioOutputRequest request);
52
53 // Called by AudioRendererHost::DoCompleteCreation to create the streams.
54 virtual void CreateStreamFactory(
55 int stream_id,
56 base::SharedMemory* shared_memory,
57 base::SyncSocket::TransitDescriptor socket_descriptor);
58
59 virtual bool CloseStream(int stream_id);
60 // Send an error message to the renderer, then close the stream.
nasko 2016/05/25 20:50:42 Empty line before comment.
rchtara 2016/05/27 15:24:39 Done.
61 virtual void ReportErrorAndCloseStream(int stream_id);
62
63 private:
64 friend class AudioOutputImplTest;
65 friend class MockAudioOutputImpl;
66 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, CreateStream);
67 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, StreamFactory);
68 FRIEND_TEST_ALL_PREFIXES(AudioOutputImplTest, RemoveStream);
69
70 static void Disconnect(int process_id, int render_frame_id);
nasko 2016/05/25 20:50:42 Add comment describing what the method does.
rchtara 2016/05/27 16:25:22 Done.
71
72 // AudioOutput interface implementation.
73 void CreateStream(int stream_id,
74 const media::AudioParameters& params,
75 const CreateStreamCallback& callback) override;
76
77 RenderProcessHost* process_;
78 int render_frame_id_;
nasko 2016/05/25 20:50:42 Instead of these two variables, why not keep a poi
rchtara 2016/05/27 15:24:39 Done.
79 mojo::Binding<AudioOutput> binding_;
80 std::map<int, std::unique_ptr<AudioOutputStreamImpl>> stream_impls_;
81 std::map<int, media::mojom::AudioOutput::CreateStreamCallback>
82 create_stream_callbacks_;
83
84 DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl);
85 };
86
87 } // namespace content
88
89 #endif // CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698