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

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

Issue 1896883002: Mojo interfaces needed for switching audio rendering stream creation and closing from IPC to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: All grunell comments resolved Created 4 years, 8 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/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "content/browser/renderer_host/media/audio_renderer_host.h"
12 #include "content/common/content_export.h"
13 #include "media/mojo/interfaces/audio_output.mojom.h"
14 #include "mojo/public/cpp/bindings/interface_request.h"
15 #include "mojo/public/cpp/bindings/strong_binding.h"
16
17 namespace base {
18 class FilePath;
19 }
20
21 namespace content {
22
23 class CONTENT_EXPORT AudioOutputStreamImpl : public mojom::AudioOutputStream {
24 // All the instance of this class are going to be owned by AudioOutputImpl.
Henrik Grunell 2016/04/22 08:23:03 Put comment before the "class" line.
Henrik Grunell 2016/04/22 08:23:04 Add a brief general description of the class. Then
rchtara 2016/04/29 12:54:44 Done.
rchtara 2016/04/29 12:54:46 Done.
25 public:
26 explicit AudioOutputStreamImpl(
xhwang 2016/04/26 22:54:42 no explicit
rchtara 2016/04/29 12:54:45 Done.
27 mojo::InterfaceRequest<mojom::AudioOutputStream> request,
tommi (sloooow) - chröme 2016/04/26 15:29:53 Niklas - can you recommend someone to remove this
28 int stream_id,
29 AudioRendererHost* audio_renderer_host);
tommi (sloooow) - chröme 2016/04/26 15:29:53 document ownership/lifetime of raw pointers
rchtara 2016/04/29 12:54:45 I have done that while describing |audio_renderer_
30
31 // AudioOutputStream interface implementation.
32 void Close() override;
tommi (sloooow) - chröme 2016/04/26 15:29:53 make this private? (assuming callers of this metho
rchtara 2016/04/29 12:54:45 Done.
33
34 ~AudioOutputStreamImpl() override;
tommi (sloooow) - chröme 2016/04/26 15:29:52 dtor follows ctor(s) in class layout
rchtara 2016/04/29 12:54:45 Done.
35
36 private:
37 mojo::StrongBinding<mojom::AudioOutputStream> binding_;
38 int stream_id_;
39 // |audio_renderer_host_| is scoped_refptr in AudioOutputImpl. And because all
Henrik Grunell 2016/04/22 08:23:03 You could put it as: "AudioRendererHost is ref cou
rchtara 2016/04/29 12:54:45 Done.
40 // AudioOutputStreamImpl instances are going to be owned by AudioOutputImpl
Henrik Grunell 2016/04/22 08:23:03 "going to be" means that it will happen in the fut
rchtara 2016/04/29 12:54:46 Done.
41 // too, it's safe to access |audio_renderer_host| from AudioOutputStreamImpl.
42 // The only issue that could happen is during AudioOutputStreamImpl
43 // destructor. |audio_renderer_host| cannot access from there.
44 AudioRendererHost* audio_renderer_host_;
45 };
46
47 // This class must always be accessed from the creation thread.
48 class CONTENT_EXPORT AudioOutputImpl
49 : NON_EXPORTED_BASE(public mojom::AudioOutput) {
50 public:
51 AudioOutputImpl(mojom::AudioOutputRequest request);
xhwang 2016/04/26 22:54:42 explicit
rchtara 2016/04/29 12:54:45 Done.
52
53 ~AudioOutputImpl() override;
54
55 // Create a Mojo service.
56 static void CreateService(
57 scoped_refptr<AudioRendererHost> audio_renderer_host,
58 mojom::AudioOutputRequest request);
tommi (sloooow) - chröme 2016/04/26 15:29:52 passed by value on purpose?
rchtara 2016/04/29 12:54:45 yes it's a mojo::InterfaceRequest<mojom::AudioOutp
59
60 // Initialize Mojo on the BrowserThread::IO. Mojo is going to be bound to
Henrik Grunell 2016/04/22 08:23:03 Does it create or only initialize? Both the commen
rchtara 2016/04/29 12:54:45 Done.
61 // BrowserThread::IO so future Mojo calls are going to be run on
62 // that thread.
xhwang 2016/04/26 22:54:41 Could you please explain more why this service has
rchtara 2016/04/29 12:54:45 Done.
63 static void CreateServiceOnIOThread(
64 scoped_refptr<AudioRendererHost> audio_renderer_host,
65 mojo::InterfaceRequest<mojom::AudioOutput> request);
xhwang 2016/04/26 22:54:42 You can use mojom::AudioOutputRequest now I believ
rchtara 2016/04/29 12:54:45 Done.
66
67 // Called by AudioRendererHost::DoCompleteCreation to create the streams.
68 mojom::AudioOutputStreamPtr* StreamFactory(
69 int stream_id,
70 AudioRendererHost* audio_renderer_host);
71
72 private:
73
tommi (sloooow) - chröme 2016/04/26 15:29:52 remove this empty line
rchtara 2016/04/29 12:54:45 Done.
74 // AudioOutput interface implementation.
75 void CreateStream(int stream_id,
76 int render_frame_id,
77 media::interfaces::AudioOutputStreamParametersPtr params,
tommi (sloooow) - chröme 2016/04/26 15:29:52 intentionally by value?
rchtara 2016/04/29 12:54:45 AudioOutputStreamParametersPtr is just a smart poi
78 const CreateStreamCallback& callback) override;
79
80 // Mojo connection error callback.
81 void OnDisconnect(AudioOutputImpl* impl);
82
83 scoped_refptr<AudioRendererHost> audio_renderer_host_;
84 mojo::StrongBinding<AudioOutput> binding_;
85 std::map<int, std::unique_ptr<AudioOutputStreamImpl>> stream_impls_;
tommi (sloooow) - chröme 2016/04/26 15:29:53 since there's no lock in this class, can we use a
rchtara 2016/04/29 12:54:45 Done.
86 DISALLOW_COPY_AND_ASSIGN(AudioOutputImpl);
87 };
88
89 } // namespace content
90
91 #endif // CONTENT_BROWSER_MEDIA_AUDIO_OUTPUT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698