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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/mojo/media/audio_server.mojom.dart

Issue 1509323002: Mojom updates for Motown. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: sync with master Created 5 years 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 library gpu_mojom; 5 library audio_server_mojom;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:mojo/bindings.dart' as bindings; 9 import 'package:mojo/bindings.dart' as bindings;
10 import 'package:mojo/core.dart' as core; 10 import 'package:mojo/core.dart' as core;
11 import 'package:mojo_services/mojo/command_buffer.mojom.dart' as command_buffer_ mojom; 11 import 'package:mojo_services/mojo/media/audio_track.mojom.dart' as audio_track_ mojom;
12 12
13 13
14 14
15 class GpuCreateOffscreenGleS2ContextParams extends bindings.Struct { 15 class AudioServerCreateTrackParams extends bindings.Struct {
16 static const List<bindings.StructDataHeader> kVersions = const [ 16 static const List<bindings.StructDataHeader> kVersions = const [
17 const bindings.StructDataHeader(16, 0) 17 const bindings.StructDataHeader(16, 0)
18 ]; 18 ];
19 Object gles2Client = null; 19 Object track = null;
20 20
21 GpuCreateOffscreenGleS2ContextParams() : super(kVersions.last.size); 21 AudioServerCreateTrackParams() : super(kVersions.last.size);
22 22
23 static GpuCreateOffscreenGleS2ContextParams deserialize(bindings.Message messa ge) { 23 static AudioServerCreateTrackParams deserialize(bindings.Message message) {
24 var decoder = new bindings.Decoder(message); 24 var decoder = new bindings.Decoder(message);
25 var result = decode(decoder); 25 var result = decode(decoder);
26 if (decoder.excessHandles != null) { 26 if (decoder.excessHandles != null) {
27 decoder.excessHandles.forEach((h) => h.close()); 27 decoder.excessHandles.forEach((h) => h.close());
28 } 28 }
29 return result; 29 return result;
30 } 30 }
31 31
32 static GpuCreateOffscreenGleS2ContextParams decode(bindings.Decoder decoder0) { 32 static AudioServerCreateTrackParams decode(bindings.Decoder decoder0) {
33 if (decoder0 == null) { 33 if (decoder0 == null) {
34 return null; 34 return null;
35 } 35 }
36 GpuCreateOffscreenGleS2ContextParams result = new GpuCreateOffscreenGleS2Con textParams(); 36 AudioServerCreateTrackParams result = new AudioServerCreateTrackParams();
37 37
38 var mainDataHeader = decoder0.decodeStructDataHeader(); 38 var mainDataHeader = decoder0.decodeStructDataHeader();
39 if (mainDataHeader.version <= kVersions.last.version) { 39 if (mainDataHeader.version <= kVersions.last.version) {
40 // Scan in reverse order to optimize for more recent versions. 40 // Scan in reverse order to optimize for more recent versions.
41 for (int i = kVersions.length - 1; i >= 0; --i) { 41 for (int i = kVersions.length - 1; i >= 0; --i) {
42 if (mainDataHeader.version >= kVersions[i].version) { 42 if (mainDataHeader.version >= kVersions[i].version) {
43 if (mainDataHeader.size == kVersions[i].size) { 43 if (mainDataHeader.size == kVersions[i].size) {
44 // Found a match. 44 // Found a match.
45 break; 45 break;
46 } 46 }
47 throw new bindings.MojoCodecError( 47 throw new bindings.MojoCodecError(
48 'Header size doesn\'t correspond to known version size.'); 48 'Header size doesn\'t correspond to known version size.');
49 } 49 }
50 } 50 }
51 } else if (mainDataHeader.size < kVersions.last.size) { 51 } else if (mainDataHeader.size < kVersions.last.size) {
52 throw new bindings.MojoCodecError( 52 throw new bindings.MojoCodecError(
53 'Message newer than the last known version cannot be shorter than ' 53 'Message newer than the last known version cannot be shorter than '
54 'required by the last known version.'); 54 'required by the last known version.');
55 } 55 }
56 if (mainDataHeader.version >= 0) { 56 if (mainDataHeader.version >= 0) {
57 57
58 result.gles2Client = decoder0.decodeInterfaceRequest(8, false, command_buf fer_mojom.CommandBufferStub.newFromEndpoint); 58 result.track = decoder0.decodeInterfaceRequest(8, false, audio_track_mojom .AudioTrackStub.newFromEndpoint);
59 } 59 }
60 return result; 60 return result;
61 } 61 }
62 62
63 void encode(bindings.Encoder encoder) { 63 void encode(bindings.Encoder encoder) {
64 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); 64 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last);
65 65
66 encoder0.encodeInterfaceRequest(gles2Client, 8, false); 66 encoder0.encodeInterfaceRequest(track, 8, false);
67 } 67 }
68 68
69 String toString() { 69 String toString() {
70 return "GpuCreateOffscreenGleS2ContextParams(" 70 return "AudioServerCreateTrackParams("
71 "gles2Client: $gles2Client" ")"; 71 "track: $track" ")";
72 } 72 }
73 73
74 Map toJson() { 74 Map toJson() {
75 throw new bindings.MojoCodecError( 75 throw new bindings.MojoCodecError(
76 'Object containing handles cannot be encoded to JSON.'); 76 'Object containing handles cannot be encoded to JSON.');
77 } 77 }
78 } 78 }
79 79
80 const int kGpu_createOffscreenGleS2Context_name = 0; 80 const int kAudioServer_createTrack_name = 0;
81 const String GpuName = "mojo::Gpu"; 81 const String AudioServerName = "mojo::media::AudioServer";
82 82
83 abstract class Gpu { 83 abstract class AudioServer {
84 void createOffscreenGleS2Context(Object gles2Client); 84 void createTrack(Object track);
85 85
86 } 86 }
87 87
88 88
89 class GpuProxyImpl extends bindings.Proxy { 89 class AudioServerProxyImpl extends bindings.Proxy {
90 GpuProxyImpl.fromEndpoint( 90 AudioServerProxyImpl.fromEndpoint(
91 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 91 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
92 92
93 GpuProxyImpl.fromHandle(core.MojoHandle handle) : 93 AudioServerProxyImpl.fromHandle(core.MojoHandle handle) :
94 super.fromHandle(handle); 94 super.fromHandle(handle);
95 95
96 GpuProxyImpl.unbound() : super.unbound(); 96 AudioServerProxyImpl.unbound() : super.unbound();
97 97
98 static GpuProxyImpl newFromEndpoint( 98 static AudioServerProxyImpl newFromEndpoint(
99 core.MojoMessagePipeEndpoint endpoint) { 99 core.MojoMessagePipeEndpoint endpoint) {
100 assert(endpoint.setDescription("For GpuProxyImpl")); 100 assert(endpoint.setDescription("For AudioServerProxyImpl"));
101 return new GpuProxyImpl.fromEndpoint(endpoint); 101 return new AudioServerProxyImpl.fromEndpoint(endpoint);
102 } 102 }
103 103
104 String get name => GpuName; 104 String get name => AudioServerName;
105 105
106 void handleResponse(bindings.ServiceMessage message) { 106 void handleResponse(bindings.ServiceMessage message) {
107 switch (message.header.type) { 107 switch (message.header.type) {
108 default: 108 default:
109 proxyError("Unexpected message type: ${message.header.type}"); 109 proxyError("Unexpected message type: ${message.header.type}");
110 close(immediate: true); 110 close(immediate: true);
111 break; 111 break;
112 } 112 }
113 } 113 }
114 114
115 String toString() { 115 String toString() {
116 var superString = super.toString(); 116 var superString = super.toString();
117 return "GpuProxyImpl($superString)"; 117 return "AudioServerProxyImpl($superString)";
118 } 118 }
119 } 119 }
120 120
121 121
122 class _GpuProxyCalls implements Gpu { 122 class _AudioServerProxyCalls implements AudioServer {
123 GpuProxyImpl _proxyImpl; 123 AudioServerProxyImpl _proxyImpl;
124 124
125 _GpuProxyCalls(this._proxyImpl); 125 _AudioServerProxyCalls(this._proxyImpl);
126 void createOffscreenGleS2Context(Object gles2Client) { 126 void createTrack(Object track) {
127 if (!_proxyImpl.isBound) { 127 if (!_proxyImpl.isBound) {
128 _proxyImpl.proxyError("The Proxy is closed."); 128 _proxyImpl.proxyError("The Proxy is closed.");
129 return; 129 return;
130 } 130 }
131 var params = new GpuCreateOffscreenGleS2ContextParams(); 131 var params = new AudioServerCreateTrackParams();
132 params.gles2Client = gles2Client; 132 params.track = track;
133 _proxyImpl.sendMessage(params, kGpu_createOffscreenGleS2Context_name); 133 _proxyImpl.sendMessage(params, kAudioServer_createTrack_name);
134 } 134 }
135 135
136 } 136 }
137 137
138 138
139 class GpuProxy implements bindings.ProxyBase { 139 class AudioServerProxy implements bindings.ProxyBase {
140 final bindings.Proxy impl; 140 final bindings.Proxy impl;
141 Gpu ptr; 141 AudioServer ptr;
142 final String name = GpuName; 142 final String name = AudioServerName;
143 143
144 GpuProxy(GpuProxyImpl proxyImpl) : 144 AudioServerProxy(AudioServerProxyImpl proxyImpl) :
145 impl = proxyImpl, 145 impl = proxyImpl,
146 ptr = new _GpuProxyCalls(proxyImpl); 146 ptr = new _AudioServerProxyCalls(proxyImpl);
147 147
148 GpuProxy.fromEndpoint( 148 AudioServerProxy.fromEndpoint(
149 core.MojoMessagePipeEndpoint endpoint) : 149 core.MojoMessagePipeEndpoint endpoint) :
150 impl = new GpuProxyImpl.fromEndpoint(endpoint) { 150 impl = new AudioServerProxyImpl.fromEndpoint(endpoint) {
151 ptr = new _GpuProxyCalls(impl); 151 ptr = new _AudioServerProxyCalls(impl);
152 } 152 }
153 153
154 GpuProxy.fromHandle(core.MojoHandle handle) : 154 AudioServerProxy.fromHandle(core.MojoHandle handle) :
155 impl = new GpuProxyImpl.fromHandle(handle) { 155 impl = new AudioServerProxyImpl.fromHandle(handle) {
156 ptr = new _GpuProxyCalls(impl); 156 ptr = new _AudioServerProxyCalls(impl);
157 } 157 }
158 158
159 GpuProxy.unbound() : 159 AudioServerProxy.unbound() :
160 impl = new GpuProxyImpl.unbound() { 160 impl = new AudioServerProxyImpl.unbound() {
161 ptr = new _GpuProxyCalls(impl); 161 ptr = new _AudioServerProxyCalls(impl);
162 } 162 }
163 163
164 factory GpuProxy.connectToService( 164 factory AudioServerProxy.connectToService(
165 bindings.ServiceConnector s, String url, [String serviceName]) { 165 bindings.ServiceConnector s, String url) {
166 GpuProxy p = new GpuProxy.unbound(); 166 AudioServerProxy p = new AudioServerProxy.unbound();
167 s.connectToService(url, p, serviceName); 167 s.connectToService(url, p);
168 return p; 168 return p;
169 } 169 }
170 170
171 static GpuProxy newFromEndpoint( 171 static AudioServerProxy newFromEndpoint(
172 core.MojoMessagePipeEndpoint endpoint) { 172 core.MojoMessagePipeEndpoint endpoint) {
173 assert(endpoint.setDescription("For GpuProxy")); 173 assert(endpoint.setDescription("For AudioServerProxy"));
174 return new GpuProxy.fromEndpoint(endpoint); 174 return new AudioServerProxy.fromEndpoint(endpoint);
175 } 175 }
176 176
177 Future close({bool immediate: false}) => impl.close(immediate: immediate); 177 Future close({bool immediate: false}) => impl.close(immediate: immediate);
178 178
179 Future responseOrError(Future f) => impl.responseOrError(f); 179 Future responseOrError(Future f) => impl.responseOrError(f);
180 180
181 Future get errorFuture => impl.errorFuture; 181 Future get errorFuture => impl.errorFuture;
182 182
183 int get version => impl.version; 183 int get version => impl.version;
184 184
185 Future<int> queryVersion() => impl.queryVersion(); 185 Future<int> queryVersion() => impl.queryVersion();
186 186
187 void requireVersion(int requiredVersion) { 187 void requireVersion(int requiredVersion) {
188 impl.requireVersion(requiredVersion); 188 impl.requireVersion(requiredVersion);
189 } 189 }
190 190
191 String toString() { 191 String toString() {
192 return "GpuProxy($impl)"; 192 return "AudioServerProxy($impl)";
193 } 193 }
194 } 194 }
195 195
196 196
197 class GpuStub extends bindings.Stub { 197 class AudioServerStub extends bindings.Stub {
198 Gpu _impl = null; 198 AudioServer _impl = null;
199 199
200 GpuStub.fromEndpoint( 200 AudioServerStub.fromEndpoint(
201 core.MojoMessagePipeEndpoint endpoint, [this._impl]) 201 core.MojoMessagePipeEndpoint endpoint, [this._impl])
202 : super.fromEndpoint(endpoint); 202 : super.fromEndpoint(endpoint);
203 203
204 GpuStub.fromHandle(core.MojoHandle handle, [this._impl]) 204 AudioServerStub.fromHandle(core.MojoHandle handle, [this._impl])
205 : super.fromHandle(handle); 205 : super.fromHandle(handle);
206 206
207 GpuStub.unbound() : super.unbound(); 207 AudioServerStub.unbound() : super.unbound();
208 208
209 static GpuStub newFromEndpoint( 209 static AudioServerStub newFromEndpoint(
210 core.MojoMessagePipeEndpoint endpoint) { 210 core.MojoMessagePipeEndpoint endpoint) {
211 assert(endpoint.setDescription("For GpuStub")); 211 assert(endpoint.setDescription("For AudioServerStub"));
212 return new GpuStub.fromEndpoint(endpoint); 212 return new AudioServerStub.fromEndpoint(endpoint);
213 } 213 }
214 214
215 static const String name = GpuName; 215 static const String name = AudioServerName;
216 216
217 217
218 218
219 dynamic handleMessage(bindings.ServiceMessage message) { 219 dynamic handleMessage(bindings.ServiceMessage message) {
220 if (bindings.ControlMessageHandler.isControlMessage(message)) { 220 if (bindings.ControlMessageHandler.isControlMessage(message)) {
221 return bindings.ControlMessageHandler.handleMessage(this, 221 return bindings.ControlMessageHandler.handleMessage(this,
222 0, 222 0,
223 message); 223 message);
224 } 224 }
225 assert(_impl != null); 225 assert(_impl != null);
226 switch (message.header.type) { 226 switch (message.header.type) {
227 case kGpu_createOffscreenGleS2Context_name: 227 case kAudioServer_createTrack_name:
228 var params = GpuCreateOffscreenGleS2ContextParams.deserialize( 228 var params = AudioServerCreateTrackParams.deserialize(
229 message.payload); 229 message.payload);
230 _impl.createOffscreenGleS2Context(params.gles2Client); 230 _impl.createTrack(params.track);
231 break; 231 break;
232 default: 232 default:
233 throw new bindings.MojoCodecError("Unexpected message name"); 233 throw new bindings.MojoCodecError("Unexpected message name");
234 break; 234 break;
235 } 235 }
236 return null; 236 return null;
237 } 237 }
238 238
239 Gpu get impl => _impl; 239 AudioServer get impl => _impl;
240 set impl(Gpu d) { 240 set impl(AudioServer d) {
241 assert(_impl == null); 241 assert(_impl == null);
242 _impl = d; 242 _impl = d;
243 } 243 }
244 244
245 String toString() { 245 String toString() {
246 var superString = super.toString(); 246 var superString = super.toString();
247 return "GpuStub($superString)"; 247 return "AudioServerStub($superString)";
248 } 248 }
249 249
250 int get version => 0; 250 int get version => 0;
251 } 251 }
252 252
253 253
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698