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

Side by Side Diff: content/renderer/media/audio_output_client.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: Created 4 years, 7 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_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_
6 #define CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_
7
8 #include <map>
9
10 #include "base/files/file.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/shared_memory_handle.h"
15 #include "base/sync_socket.h"
16 #include "base/threading/thread_checker.h"
17 #include "content/common/content_export.h"
18 #include "media/mojo/interfaces/audio_output.mojom.h"
19 #include "mojo/edk/embedder/embedder.h"
20 #include "mojo/public/c/system/buffer.h"
21 #include "mojo/public/cpp/bindings/binding.h"
22 #include "mojo/public/cpp/bindings/binding.h"
23 #include "mojo/public/cpp/bindings/interface_request.h"
24 #include "mojo/public/cpp/system/handle.h"
25
26 namespace base {
27 class SingleThreadTaskRunner;
28 }
29
30 namespace media {
31 class AudioParameters;
32 }
33
34 namespace content {
35
36 class AudioMessageFilter;
37 class ServiceRegistry;
38
39 class CONTENT_EXPORT AudioOutputClient {
mcasas 2016/04/29 18:29:01 Please add class comments, including the threading
40 public:
41 typedef std::map<int,
42 std::unique_ptr<media::interfaces::AudioOutputStreamPtr>>
43 ScopedAudioOutputStreamPtrMap;
mcasas 2016/04/29 18:29:01 using ScopedAudioOutputStreamPtrMap = ... ?
rchtara 2016/05/23 16:38:18 Done.
44
45 // Create a Mojo Audio Output Client. It's going to be created by
mcasas 2016/04/29 18:29:01 Method documentation are descriptive: s/Create/Cre
46 // RenderThreadImpl::init and be bound to RenderThread. This means that all
mcasas 2016/04/29 18:29:01 init()
rchtara 2016/05/23 16:38:18 Done.
47 // future Mojo service calls and all Mojo callbacks are going to be
48 // performed on the RenderThread.
49 explicit AudioOutputClient(
50 ServiceRegistry* service_registry,
51 scoped_refptr<AudioMessageFilter> audio_message_filter);
52
53 ~AudioOutputClient();
54
55 // Create stream by calling the AudioOutput.CreateStream Mojo interface
56 // function using the Mojo service. This function could be called on any
57 // thread and is going to call CreateStreamOnMainThread in the RenderThread.
58 void CreateStream(int stream_id,
59 int render_frame_id,
60 const media::AudioParameters& params);
61
62 // Create stream by calling the AudioOutput.CreateStream Mojo interface
63 // function using the Mojo service. This function could be called on just
64 // the RenderThread.
65 void CreateStreamOnMainThread(int stream_id,
66 int render_frame_id,
67 const media::AudioParameters& params);
68
69 // Callback for AudioOutput.CreateStream which contains information about
70 // the new created stream. Called on RenderThread. This function is going to
71 // notify the |audio_message_filter_| of the stream creation by calling
72 // StreamCreated. StreamCreated could only be ran on |io_task_runner_| and
73 // this is why CreateStreamOnIOThread is going to be used to do that.
74 void CreateStreamCallback(int stream_id,
75 media::interfaces::AudioOutputStreamPtr stream,
76 mojo::ScopedSharedBufferHandle shared_buffer,
77 mojo::ScopedHandle socket_descriptor);
78
79 // Notify the |audio_message_filter_| of the stream creation. Can only be
80 // called on |io_task_runner_|.
81 void CreateStreamOnIOThread(
82 media::interfaces::AudioOutputStreamPtr* const stream,
83 base::SharedMemoryHandle handle,
84 base::SyncSocket::TransitDescriptor socket_descriptor,
85 uint32_t length);
86
87 // Close stream by calling the AudioOutputStream.Close Mojo interface
88 // function using the Mojo service. This function could be called on any
89 // thread and is going to call CloseStreamOnMainThread in the RenderThread.
90 void CloseStream(int stream_id);
91
92 // Close stream by calling the AudioOutputStream.Close Mojo interface
93 // function using the Mojo service. This function could be called on just the
94 // RenderThread.
95 void CloseStreamOnMainThread(int stream_id);
96
97 // Called when there is an error with AudioOutputStream Mojo interface in
98 // the renderer. This function is going to call ReportErrorOnIOThread in the
99 // RenderThread.
100 void OnStreamError(int stream_id);
mcasas 2016/04/29 18:29:01 Can be private I believe. Check the other methods
rchtara 2016/05/23 16:38:18 Done.
101
102 // Notify the |audio_message_filter_| of a stream error. Can only be called
103 // on |io_task_runner_|.
104 void ReportErrorOnIOThread(int stream_id);
105
106 private:
107 // Mojo connection error handler.
108 void OnConnectionError();
109
110 scoped_refptr<AudioMessageFilter> audio_message_filter_;
111 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
mcasas 2016/04/29 18:29:01 const. Leave a blank line before the next comment
rchtara 2016/05/23 16:38:19 Done.
112 // The Mojo service.
113 media::interfaces::AudioOutputPtr service_;
114 ScopedAudioOutputStreamPtrMap streams_;
115 DISALLOW_COPY_AND_ASSIGN(AudioOutputClient);
116 };
117
118 } // namespace content
119
120 #endif // CONTENT_RENDERER_MEDIA_AUDIO_OUTPUT_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698