|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Telephony Multimedia Service |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <s32mem.h> |
|
19 #include <AudioPreference.h> |
|
20 #include <tmseffectobsrvr.h> |
|
21 #include <tmsglobalroutingobsrvr.h> |
|
22 #include "tmsutility.h" |
|
23 #include "tmsclientserver.h" |
|
24 #include "tmsproxy.h" |
|
25 |
|
26 using namespace TMS; |
|
27 |
|
28 // CONSTANTS |
|
29 const TUint KServerConnectRetries = 2; |
|
30 const TUint KSessionMessageSlots = 10; |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // StartServer |
|
34 // Static function to start the server process thread. |
|
35 // Start the server process/thread which lives in an EPOCEXE object. |
|
36 // Returns: gint: TMS_RESULT_SUCCESS (0) if no error |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 static gint StartServer() |
|
40 { |
|
41 const TUidType serverUid(KNullUid, KNullUid, KTMSServerUid3); |
|
42 |
|
43 // Only one instance of the server is allowed. Attempt of launching |
|
44 // second instance of the server will fail with KErrAlreadyExists. |
|
45 RProcess server; |
|
46 gint r = server.Create(KTMSServerName, KNullDesC, serverUid); |
|
47 |
|
48 if (r != TMS_RESULT_SUCCESS) |
|
49 { |
|
50 return r; |
|
51 } |
|
52 |
|
53 TRequestStatus stat; |
|
54 server.Rendezvous(stat); |
|
55 |
|
56 if (stat != KRequestPending) |
|
57 { |
|
58 server.Kill(0); // abort startup |
|
59 } |
|
60 else |
|
61 { |
|
62 server.Resume(); // logon OK - start the server |
|
63 } |
|
64 |
|
65 User::WaitForRequest(stat); // wait for start or death |
|
66 |
|
67 // Panic reason cannot be '0' as it would conflict with TMS_RESULT_SUCCESS |
|
68 r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); |
|
69 server.Close(); |
|
70 return r; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // TMSProxy::TMSProxy |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 EXPORT_C TMSProxy::TMSProxy() |
|
78 { |
|
79 iEffectsObsrvrList.Reset(); |
|
80 iEffectsParentList.Reset(); |
|
81 iRoutingObsrvrList.Reset(); |
|
82 iRoutingParentList.Reset(); |
|
83 iMsgQHandler = NULL; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // TMSProxy::~TMSProxy |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C TMSProxy::~TMSProxy() |
|
91 { |
|
92 iEffectsObsrvrList.Reset(); |
|
93 iEffectsParentList.Reset(); |
|
94 iRoutingObsrvrList.Reset(); |
|
95 iRoutingParentList.Reset(); |
|
96 |
|
97 if (iMsgQHandler) |
|
98 { |
|
99 iMsgQHandler->Cancel(); |
|
100 } |
|
101 delete iMsgQHandler; |
|
102 if (iMsgQueue.Handle() > 0) |
|
103 { |
|
104 iMsgQueue.Close(); |
|
105 } |
|
106 if (Handle() > 0) |
|
107 { |
|
108 Close(); |
|
109 } |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // TMSProxy::Connect |
|
114 // Create a client-side session. Start the server if not started already. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C gint TMSProxy::Connect() |
|
118 { |
|
119 TRACE_PRN_FN_ENT; |
|
120 |
|
121 gint retry = KServerConnectRetries; |
|
122 gint err(TMS_RESULT_GENERAL_ERROR); |
|
123 gint numMessageSlots = KSessionMessageSlots; |
|
124 |
|
125 for (;;) |
|
126 { |
|
127 // Try to create a new session with the server |
|
128 err = CreateSession(KTMSServerName, Version(), numMessageSlots); |
|
129 |
|
130 if ((err != KErrNotFound) && (err != KErrServerTerminated)) |
|
131 { |
|
132 TRACE_PRN_N1(_L("[TMS session created; err==%d]"), err); |
|
133 break; // Connected to existing server - ok |
|
134 } |
|
135 |
|
136 if (--retry == 0) |
|
137 { |
|
138 break; // Failed. |
|
139 } |
|
140 |
|
141 // Server not running, try to start it. |
|
142 err = StartServer(); |
|
143 TRACE_PRN_N1(_L("[TMS server started; err==%d]"), err); |
|
144 |
|
145 if ((err != TMS_RESULT_SUCCESS) && (err != KErrAlreadyExists)) |
|
146 { |
|
147 break; // Server not launched - propagate error |
|
148 } |
|
149 } |
|
150 |
|
151 TRACE_PRN_IF_ERR(err); |
|
152 |
|
153 if (err == KErrNone) |
|
154 { |
|
155 err = CreateQueue(KTMSMsgQSlots); |
|
156 } |
|
157 |
|
158 TRACE_PRN_FN_EXT; |
|
159 return TMSRESULT(err); |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // TMSProxy::Version |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 EXPORT_C TVersion TMSProxy::Version() const |
|
167 { |
|
168 return (TVersion(KTMSServMajorVersionNumber, |
|
169 KTMSServMinorVersionNumber, KTMSServBuildVersionNumber)); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // TMSProxy::Close |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 EXPORT_C void TMSProxy::Close() |
|
177 { |
|
178 TRACE_PRN_FN_ENT; |
|
179 RSessionBase::Close(); |
|
180 TRACE_PRN_FN_EXT; |
|
181 } |
|
182 |
|
183 EXPORT_C gint TMSProxy::GetTMSCallSessionHandle() |
|
184 { |
|
185 gint err(TMS_RESULT_SUCCESS); |
|
186 err = SendReceive(ETMSCallSessionHandle); |
|
187 return TMSRESULT(err); |
|
188 } |
|
189 |
|
190 EXPORT_C gint TMSProxy::GetSupportedDecoders(RArray<TUint32>& aDecoders, |
|
191 gint& aFrameSize) |
|
192 { |
|
193 TRACE_PRN_FN_ENT; |
|
194 gint err(TMS_RESULT_SUCCESS); |
|
195 |
|
196 TmsMsgBufPckg pckg1; |
|
197 TIpcArgs args1(&pckg1); |
|
198 err = SendReceive(ETMSGetSupportedDecodersCount, args1); |
|
199 gint count = 0; |
|
200 aFrameSize = 0; |
|
201 |
|
202 if (err == TMS_RESULT_SUCCESS) |
|
203 { |
|
204 count = pckg1().iInt; |
|
205 aFrameSize = pckg1().iUint; //for g711 10/20ms frame detection |
|
206 err = pckg1().iStatus; |
|
207 } |
|
208 |
|
209 if (count > 0 && err == TMS_RESULT_SUCCESS) |
|
210 { |
|
211 TRAP(err, PopulateArrayL(ETMSGetSupportedDecoders, aDecoders, count)); |
|
212 } |
|
213 |
|
214 TRACE_PRN_FN_EXT; |
|
215 return TMSRESULT(err); |
|
216 } |
|
217 |
|
218 EXPORT_C gint TMSProxy::GetSupportedEncoders(RArray<TUint32>& aEncoders, |
|
219 gint& aFrameSize) |
|
220 { |
|
221 TRACE_PRN_FN_ENT; |
|
222 gint err(TMS_RESULT_SUCCESS); |
|
223 |
|
224 TmsMsgBufPckg pckg1; |
|
225 TIpcArgs args1(&pckg1); |
|
226 err = SendReceive(ETMSGetSupportedEncodersCount, args1); |
|
227 gint count = 0; |
|
228 aFrameSize = 0; |
|
229 |
|
230 if (err == TMS_RESULT_SUCCESS) |
|
231 { |
|
232 count = pckg1().iInt; |
|
233 aFrameSize = pckg1().iUint; //for g711 10/20ms frame detection |
|
234 err = pckg1().iStatus; |
|
235 } |
|
236 |
|
237 if (count > 0 && err == TMS_RESULT_SUCCESS) |
|
238 { |
|
239 TRAP(err, PopulateArrayL(ETMSGetSupportedEncoders, aEncoders, count)); |
|
240 } |
|
241 |
|
242 TRACE_PRN_FN_EXT; |
|
243 return TMSRESULT(err); |
|
244 } |
|
245 |
|
246 EXPORT_C gint TMSProxy::SetOutput(TMSAudioOutput output) |
|
247 { |
|
248 TRACE_PRN_FN_ENT; |
|
249 gint status = TMS_RESULT_SUCCESS; |
|
250 if (output == TMS_AUDIO_OUTPUT_NONE) |
|
251 { |
|
252 status = TMS_RESULT_INVALID_ARGUMENT; |
|
253 } |
|
254 else |
|
255 { |
|
256 status = RSessionBase::SendReceive(ETMSSetOutput, TIpcArgs(output)); |
|
257 } |
|
258 TRACE_PRN_FN_EXT; |
|
259 return TMSRESULT(status); |
|
260 } |
|
261 |
|
262 EXPORT_C gint TMSProxy::GetOutput(TMSAudioOutput& output) |
|
263 { |
|
264 TRACE_PRN_FN_ENT; |
|
265 TPckgBuf<guint> pckg; |
|
266 TIpcArgs args(&pckg); |
|
267 gint status = RSessionBase::SendReceive(ETMSGetOutput, args); |
|
268 if (status == TMS_RESULT_SUCCESS) |
|
269 { |
|
270 output = pckg(); |
|
271 } |
|
272 TRACE_PRN_FN_EXT; |
|
273 return TMSRESULT(status); |
|
274 } |
|
275 |
|
276 EXPORT_C gint TMSProxy::GetPreviousOutput(TMSAudioOutput& output) |
|
277 { |
|
278 TRACE_PRN_FN_ENT; |
|
279 TPckgBuf<guint> pckg; |
|
280 TIpcArgs args(&pckg); |
|
281 gint status = RSessionBase::SendReceive(ETMSGetPreviousOutput, args); |
|
282 if (status == TMS_RESULT_SUCCESS) |
|
283 { |
|
284 output = pckg(); |
|
285 } |
|
286 TRACE_PRN_FN_EXT; |
|
287 return TMSRESULT(status); |
|
288 } |
|
289 |
|
290 EXPORT_C gint TMSProxy::GetAvailableOutputs(OutputVector& outputs) |
|
291 { |
|
292 gint status(TMS_RESULT_DOES_NOT_EXIST); |
|
293 TRAP(status, GetAvailableOutputsL(outputs)); |
|
294 return TMSRESULT(status); |
|
295 } |
|
296 |
|
297 void TMSProxy::GetAvailableOutputsL(OutputVector& outputs) |
|
298 { |
|
299 HBufC8* buf = HBufC8::NewLC(10 * sizeof(TUint32)); |
|
300 TPtr8 ptr = buf->Des(); |
|
301 TPckgBuf<gint> countpkg; |
|
302 TIpcArgs args; |
|
303 args.Set(0, &countpkg); |
|
304 args.Set(1, &ptr); |
|
305 gint status = SendReceive(ETMSGetAvailableOutputs, args); |
|
306 outputs.clear(); |
|
307 if (status != TMS_RESULT_SUCCESS) |
|
308 { |
|
309 User::Leave(status); |
|
310 } |
|
311 else |
|
312 { |
|
313 RDesReadStream stream(ptr); |
|
314 CleanupClosePushL(stream); |
|
315 |
|
316 for (gint i = 0; i < countpkg(); i++) |
|
317 { |
|
318 TMSAudioOutput output = stream.ReadUint32L(); |
|
319 if (output != TMS_AUDIO_OUTPUT_NONE) |
|
320 { |
|
321 outputs.push_back(output); |
|
322 } |
|
323 //TRACE_PRN_N1(_L("TMS->TMSProxy: outputs: [%d]"), stream.ReadUint32L()); |
|
324 } |
|
325 |
|
326 CleanupStack::PopAndDestroy(&stream); |
|
327 } |
|
328 CleanupStack::PopAndDestroy(buf); |
|
329 } |
|
330 |
|
331 EXPORT_C gint TMSProxy::GetLevel(guint& level) |
|
332 { |
|
333 TRACE_PRN_FN_ENT; |
|
334 TPckgBuf<guint> pckg; |
|
335 TIpcArgs args(&pckg); |
|
336 gint status = RSessionBase::SendReceive(ETMSGetGlobalVol, args); |
|
337 if (status == TMS_RESULT_SUCCESS) |
|
338 { |
|
339 level = pckg(); |
|
340 } |
|
341 TRACE_PRN_FN_EXT; |
|
342 return TMSRESULT(status); |
|
343 } |
|
344 |
|
345 EXPORT_C gint TMSProxy::GetMaxLevel(guint& level) |
|
346 { |
|
347 TRACE_PRN_FN_ENT; |
|
348 TPckgBuf<guint> pckg; |
|
349 TIpcArgs args(&pckg); |
|
350 gint status = RSessionBase::SendReceive(ETMSGetMaxGlobalVol, args); |
|
351 if (status == TMS_RESULT_SUCCESS) |
|
352 { |
|
353 level = pckg(); |
|
354 } |
|
355 TRACE_PRN_FN_EXT; |
|
356 return TMSRESULT(status); |
|
357 } |
|
358 |
|
359 EXPORT_C gint TMSProxy::SetLevel(guint level) |
|
360 { |
|
361 TRACE_PRN_FN_ENT; |
|
362 gint status = RSessionBase::SendReceive(ETMSSetGlobalVol, TIpcArgs(level)); |
|
363 TRACE_PRN_FN_EXT; |
|
364 return TMSRESULT(status); |
|
365 } |
|
366 |
|
367 EXPORT_C gint TMSProxy::GetGain(guint& level) |
|
368 { |
|
369 TRACE_PRN_FN_ENT; |
|
370 TPckgBuf<guint> pckg; |
|
371 TIpcArgs args(&pckg); |
|
372 gint status = RSessionBase::SendReceive(ETMSGetGlobalGain, args); |
|
373 if (status == TMS_RESULT_SUCCESS) |
|
374 { |
|
375 level = pckg(); |
|
376 } |
|
377 TRACE_PRN_FN_EXT; |
|
378 return TMSRESULT(status); |
|
379 } |
|
380 |
|
381 EXPORT_C gint TMSProxy::GetMaxGain(guint& level) |
|
382 { |
|
383 TRACE_PRN_FN_ENT; |
|
384 TPckgBuf<guint> pckg; |
|
385 TIpcArgs args(&pckg); |
|
386 gint status = RSessionBase::SendReceive(ETMSGetMaxGlobalGain, args); |
|
387 if (status == TMS_RESULT_SUCCESS) |
|
388 { |
|
389 level = pckg(); |
|
390 } |
|
391 TRACE_PRN_FN_EXT; |
|
392 return TMSRESULT(status); |
|
393 } |
|
394 |
|
395 EXPORT_C gint TMSProxy::SetGain(guint level) |
|
396 { |
|
397 TRACE_PRN_FN_ENT; |
|
398 gint status = RSessionBase::SendReceive(ETMSSetGlobalGain, |
|
399 TIpcArgs(level)); |
|
400 TRACE_PRN_FN_EXT; |
|
401 return TMSRESULT(status); |
|
402 } |
|
403 |
|
404 EXPORT_C gint TMSProxy::StartGlobalEffectNotifier() |
|
405 { |
|
406 gint status(TMS_RESULT_SUCCESS); |
|
407 RSessionBase::SendReceive(ETMSStartGlobalEffectNotifier); //CenRepHandler |
|
408 return TMSRESULT(status); |
|
409 } |
|
410 |
|
411 EXPORT_C gint TMSProxy::CancelGlobalEffectNotifier() |
|
412 { |
|
413 gint status(TMS_RESULT_SUCCESS); |
|
414 status = RSessionBase::SendReceive(ETMSCancelGlobalEffectNotifier); |
|
415 return TMSRESULT(status); |
|
416 } |
|
417 |
|
418 EXPORT_C gint TMSProxy::StartRoutingNotifier() |
|
419 { |
|
420 gint status(TMS_RESULT_SUCCESS); |
|
421 status = RSessionBase::SendReceive(ETMSStartRoutingNotifier); //TAR |
|
422 return TMSRESULT(status); |
|
423 } |
|
424 |
|
425 EXPORT_C gint TMSProxy::CancelRoutingNotifier() |
|
426 { |
|
427 gint status(TMS_RESULT_SUCCESS); |
|
428 status = RSessionBase::SendReceive(ETMSCancelRoutingNotifier); |
|
429 return TMSRESULT(status); |
|
430 } |
|
431 |
|
432 // --------------------------------------------------------------------------- |
|
433 // TMSProxy::SetMsgQueueNotifier |
|
434 // --------------------------------------------------------------------------- |
|
435 // |
|
436 EXPORT_C gint TMSProxy::SetMsgQueueNotifier(TMSMsgQueueNotifierType type, |
|
437 gpointer obsrv, gpointer parent, gint clientid) |
|
438 { |
|
439 gint status(TMS_RESULT_SUCCESS); |
|
440 switch (type) |
|
441 { |
|
442 case EMsgQueueGlobalVolumeType: |
|
443 case EMsgQueueGlobalGainType: |
|
444 status = AddGlobalEffectObserver((*(TMSEffectObserver*) obsrv), |
|
445 (*(TMSEffect*)parent), clientid); |
|
446 break; |
|
447 case EMsgQueueGlobalRoutingType: |
|
448 status = AddRoutingObserver((*(TMSGlobalRoutingObserver*) obsrv), |
|
449 (*(TMSGlobalRouting*)parent), clientid); |
|
450 break; |
|
451 default: |
|
452 status = TMS_RESULT_INVALID_ARGUMENT; |
|
453 break; |
|
454 } |
|
455 return TMSRESULT(status); |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // TMSProxy::RemoveMsgQueueNotifier |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 EXPORT_C gint TMSProxy::RemoveMsgQueueNotifier(TMSMsgQueueNotifierType type, |
|
463 gpointer obsrv) |
|
464 { |
|
465 gint status(TMS_RESULT_SUCCESS); |
|
466 |
|
467 switch (type) |
|
468 { |
|
469 case EMsgQueueGlobalVolumeType: |
|
470 case EMsgQueueGlobalGainType: |
|
471 status = RemoveGlobalEffectObserver((*(TMSEffectObserver*) obsrv)); |
|
472 break; |
|
473 case EMsgQueueGlobalRoutingType: |
|
474 status = RemoveRoutingObserver((*(TMSGlobalRoutingObserver*) obsrv)); |
|
475 break; |
|
476 default: |
|
477 status = TMS_RESULT_INVALID_ARGUMENT; |
|
478 break; |
|
479 } |
|
480 return TMSRESULT(status); |
|
481 } |
|
482 |
|
483 void TMSProxy::PopulateArrayL(TMSClientServerRequest aRequest, |
|
484 RArray<TUint32>& aDecoders, gint aCount) |
|
485 { |
|
486 HBufC8* buf = HBufC8::NewLC(aCount * sizeof(TUint32)); |
|
487 TPtr8 ptr = buf->Des(); |
|
488 TIpcArgs args; |
|
489 args.Set(0, &ptr); |
|
490 gint err = SendReceive(aRequest, args); |
|
491 |
|
492 if (err == TMS_RESULT_SUCCESS) |
|
493 { |
|
494 RDesReadStream stream(ptr); |
|
495 CleanupClosePushL(stream); |
|
496 aDecoders.Reset(); |
|
497 |
|
498 for (gint i = 0; i < aCount; i++) |
|
499 { |
|
500 aDecoders.Append(stream.ReadUint32L()); |
|
501 } |
|
502 CleanupStack::PopAndDestroy(&stream); |
|
503 } |
|
504 CleanupStack::PopAndDestroy(buf); |
|
505 } |
|
506 |
|
507 gint TMSProxy::AddGlobalEffectObserver(TMSEffectObserver& obsrv, |
|
508 TMSEffect& parent, gint /*clientid*/) |
|
509 { |
|
510 gint status = iEffectsObsrvrList.Find(&obsrv); |
|
511 if (status == KErrNotFound) |
|
512 { |
|
513 status = iEffectsObsrvrList.Append(&obsrv); |
|
514 status = iEffectsParentList.Append(&parent); |
|
515 //status = iClientList.Append(clientid); |
|
516 } |
|
517 else |
|
518 { |
|
519 status = TMS_RESULT_ALREADY_EXIST; |
|
520 } |
|
521 return TMSRESULT(status); |
|
522 } |
|
523 |
|
524 gint TMSProxy::RemoveGlobalEffectObserver(TMSEffectObserver& obsrv) |
|
525 { |
|
526 gint status(TMS_RESULT_SUCCESS); |
|
527 gint index = iEffectsObsrvrList.Find(&obsrv); |
|
528 if (index >= 0) |
|
529 { |
|
530 iEffectsObsrvrList.Remove(index); |
|
531 iEffectsParentList.Remove(index); |
|
532 //iClientList.Remove(index); |
|
533 } |
|
534 else |
|
535 { |
|
536 status = TMS_RESULT_DOES_NOT_EXIST; |
|
537 } |
|
538 return TMSRESULT(status); |
|
539 } |
|
540 |
|
541 gint TMSProxy::AddRoutingObserver(TMSGlobalRoutingObserver& obsrv, |
|
542 TMSGlobalRouting& parent, gint /*clientid*/) |
|
543 { |
|
544 gint status = iRoutingObsrvrList.Find(&obsrv); |
|
545 if (status == KErrNotFound) |
|
546 { |
|
547 status = iRoutingObsrvrList.Append(&obsrv); |
|
548 status = iRoutingParentList.Append(&parent); |
|
549 //status = iClientList.Append(clientid); |
|
550 } |
|
551 else |
|
552 { |
|
553 status = TMS_RESULT_ALREADY_EXIST; |
|
554 } |
|
555 return TMSRESULT(status); |
|
556 } |
|
557 |
|
558 gint TMSProxy::RemoveRoutingObserver(TMSGlobalRoutingObserver& obsrv) |
|
559 { |
|
560 gint status(TMS_RESULT_SUCCESS); |
|
561 gint index = iRoutingObsrvrList.Find(&obsrv); |
|
562 if (index >= 0) |
|
563 { |
|
564 iRoutingObsrvrList.Remove(index); |
|
565 iRoutingParentList.Remove(index); |
|
566 //iClientList.Remove(index); |
|
567 } |
|
568 else |
|
569 { |
|
570 status = TMS_RESULT_DOES_NOT_EXIST; |
|
571 } |
|
572 return TMSRESULT(status); |
|
573 } |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // TMSProxy::CreateQueue |
|
577 // --------------------------------------------------------------------------- |
|
578 // |
|
579 gint TMSProxy::CreateQueue(const gint aNumSlots) |
|
580 { |
|
581 gint status(TMS_RESULT_INVALID_ARGUMENT); |
|
582 |
|
583 if (iMsgQueue.Handle() <= 0) |
|
584 { |
|
585 status = iMsgQueue.CreateGlobal(KNullDesC, aNumSlots); |
|
586 if (status == TMS_RESULT_SUCCESS) |
|
587 { |
|
588 TRAP(status, ReceiveMsgQHandlerEventsL()); |
|
589 if (status == TMS_RESULT_SUCCESS) |
|
590 { |
|
591 TIpcArgs args; |
|
592 args.Set(0, iMsgQueue); |
|
593 status = RSessionBase::SendReceive(ETMSSetMsgQueueHandle, |
|
594 args); |
|
595 } |
|
596 } |
|
597 } |
|
598 return TMSRESULT(status); |
|
599 } |
|
600 |
|
601 // --------------------------------------------------------------------------- |
|
602 // TMSProxy::ReceiveMsgQHandlerEventsL |
|
603 // Starts message queue handler (A/O) to monitor communication and transfer |
|
604 // buffer events between client and the server. |
|
605 // --------------------------------------------------------------------------- |
|
606 // |
|
607 void TMSProxy::ReceiveMsgQHandlerEventsL() |
|
608 { |
|
609 if (iMsgQHandler) |
|
610 { |
|
611 iMsgQHandler->Cancel(); |
|
612 } |
|
613 else |
|
614 { |
|
615 iMsgQHandler = CQueueHandler::NewL(&iMsgQueue, NULL); |
|
616 iMsgQHandler->AddObserver(*this, -1); |
|
617 } |
|
618 iMsgQHandler->Start(); |
|
619 } |
|
620 |
|
621 // --------------------------------------------------------------------------- |
|
622 // TMSProxy::QueueEvent |
|
623 // Call from QueueHandler as a result of TMS Server callback. |
|
624 // --------------------------------------------------------------------------- |
|
625 // |
|
626 void TMSProxy::QueueEvent(gint aEventType, gint aError, void* user_data) |
|
627 { |
|
628 TMSSignalEvent event; |
|
629 event.type = aEventType; |
|
630 event.reason = aError; |
|
631 event.user_data = user_data; |
|
632 |
|
633 switch (aEventType) |
|
634 { |
|
635 case TMS_EVENT_EFFECT_VOL_CHANGED: |
|
636 case TMS_EVENT_EFFECT_GAIN_CHANGED: |
|
637 { |
|
638 for (gint i = 0; i < iEffectsObsrvrList.Count(); i++) |
|
639 { |
|
640 iEffectsObsrvrList[i]->EffectsEvent(iEffectsParentList[i], |
|
641 event); |
|
642 } |
|
643 break; |
|
644 } |
|
645 case TMS_EVENT_ROUTING_AVAIL_OUTPUTS_CHANGED: |
|
646 case TMS_EVENT_ROUTING_OUTPUT_CHANGED: |
|
647 case TMS_EVENT_ROUTING_SET_OUTPUT_COMPLETE: |
|
648 { |
|
649 guint output(0); |
|
650 if (user_data != NULL) |
|
651 { |
|
652 output = *((guint*) user_data); |
|
653 } |
|
654 for (gint i = 0; i < iRoutingObsrvrList.Count(); i++) |
|
655 { |
|
656 iRoutingObsrvrList[i]->GlobalRoutingEvent(iRoutingParentList[i], |
|
657 event, output); |
|
658 } |
|
659 break; |
|
660 } |
|
661 default: |
|
662 break; |
|
663 } |
|
664 } |
|
665 |
|
666 // End of file |