|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Speech synthesis session |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 |
|
21 #include "speechsynthesissession.h" |
|
22 #include "speechsynthesisserver.h" |
|
23 #include "speechsynthesisclientserver.h" |
|
24 #include "rubydebug.h" |
|
25 |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 const TInt KMinVolume = 0; |
|
30 const TInt KMinSpeakingRate = 1; |
|
31 |
|
32 // ---------------------------------------------------------------------------- |
|
33 // CSpeechSynthesisSession::CSpeechSynthesisSession |
|
34 // Constructor |
|
35 // ---------------------------------------------------------------------------- |
|
36 // |
|
37 CSpeechSynthesisSession::CSpeechSynthesisSession(): |
|
38 iSessionState( ESessionIdle ) |
|
39 { |
|
40 RUBY_DEBUG0( "CSpeechSynthesisSession::CSpeechSynthesisSession" ); |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CSpeechSynthesisSession::CreateL |
|
45 // 2nd phase construct for sessions - called by the CServer framework |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 void CSpeechSynthesisSession::CreateL() |
|
49 { |
|
50 RUBY_DEBUG_BLOCK( "CSpeechSynthesisSession::CreateL" ); |
|
51 |
|
52 Server().GetDefaultSettingsL( iCurrentVoice, |
|
53 iSpeakingRate, iMaxSpeakingRate, |
|
54 iVolume, iMaxVolume, |
|
55 iAudioPriority, iAudioPreference, |
|
56 iAudioOutput ); |
|
57 |
|
58 iTmpAudioOutput = iAudioOutput; |
|
59 iTmpVolume = iVolume; |
|
60 |
|
61 Server().AddSession(); |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // CSpeechSynthesisSession::~CSpeechSynthesisSession |
|
66 // Destructor |
|
67 // ---------------------------------------------------------------------------- |
|
68 // |
|
69 CSpeechSynthesisSession::~CSpeechSynthesisSession() |
|
70 { |
|
71 RUBY_DEBUG0( "CSpeechSynthesisSession::~CSpeechSynthesisSession" ); |
|
72 |
|
73 iLanguages.Close(); |
|
74 iVoices.Close(); |
|
75 iCustomCommands.Close(); |
|
76 |
|
77 Server().Release( this ); |
|
78 Server().DropSession(); |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // CSpeechSynthesisSession::MsssInitComplete |
|
83 // Callback from server |
|
84 // ---------------------------------------------------------------------------- |
|
85 // |
|
86 void CSpeechSynthesisSession::MsssInitComplete( TInt aError, |
|
87 const TTimeIntervalMicroSeconds& aDuration ) |
|
88 { |
|
89 RUBY_DEBUG1( "CSpeechSynthesisSession::MsssInitComplete [%d]", aError ); |
|
90 |
|
91 if ( aError ) |
|
92 { |
|
93 iSessionState = ESessionIdle; |
|
94 iFileOutputActivated = EFalse; |
|
95 |
|
96 iDuration = 0; |
|
97 iFile.Close(); |
|
98 |
|
99 Server().Release( this ); |
|
100 } |
|
101 else |
|
102 { |
|
103 iSessionState = ESessionPrimed; |
|
104 |
|
105 iDuration = aDuration; |
|
106 } |
|
107 |
|
108 if ( iStoredMessage.IsNull() ) |
|
109 { |
|
110 RUBY_ERROR0( "iStoredMessage.IsNull() == ETrue" ); |
|
111 } |
|
112 else |
|
113 { |
|
114 iStoredMessage.Complete( aError ); |
|
115 RUBY_DEBUG0( "Message completed" ); |
|
116 } |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CSpeechSynthesisSession::MsssPlayComplete |
|
121 // Callback from server |
|
122 // ---------------------------------------------------------------------------- |
|
123 // |
|
124 void CSpeechSynthesisSession::MsssPlayComplete( TInt aError ) |
|
125 { |
|
126 RUBY_DEBUG1( "CSpeechSynthesisSession::MsssPlayComplete [%d]", aError ); |
|
127 |
|
128 iSessionState = ESessionIdle; |
|
129 iFileOutputActivated = EFalse; |
|
130 |
|
131 iDuration = 0; |
|
132 iFile.Close(); |
|
133 |
|
134 Server().Release( this ); |
|
135 |
|
136 if ( iStoredMessage.IsNull() ) |
|
137 { |
|
138 RUBY_ERROR0( "iStoredMessage.IsNull() == ETrue" ); |
|
139 } |
|
140 else |
|
141 { |
|
142 iStoredMessage.Complete( aError ); |
|
143 RUBY_DEBUG0( "Message completed" ); |
|
144 } |
|
145 } |
|
146 |
|
147 // ---------------------------------------------------------------------------- |
|
148 // CSpeechSynthesisSession::MsssOperationAborted |
|
149 // Callback from server |
|
150 // ---------------------------------------------------------------------------- |
|
151 // |
|
152 void CSpeechSynthesisSession::MsssOperationAborted() |
|
153 { |
|
154 RUBY_DEBUG0( "CSpeechSynthesisSession::MsssOperationAborted" ); |
|
155 |
|
156 iSessionState = ESessionIdle; |
|
157 iFileOutputActivated = EFalse; |
|
158 |
|
159 iDuration = 0; |
|
160 iFile.Close(); |
|
161 |
|
162 if ( !iStoredMessage.IsNull() ) |
|
163 { |
|
164 RUBY_DEBUG0( "Completing message with KErrDied" ); |
|
165 iStoredMessage.Complete( KErrDied ); |
|
166 } |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CSpeechSynthesisSession::Server |
|
171 // |
|
172 // ---------------------------------------------------------------------------- |
|
173 // |
|
174 inline CSpeechSynthesisServer& CSpeechSynthesisSession::Server() |
|
175 { |
|
176 return *static_cast<CSpeechSynthesisServer*>( |
|
177 const_cast<CServer2*>( CSession2::Server() ) ); |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CSpeechSynthesisSession::ServiceL |
|
182 // Handle a client request. |
|
183 // Leaving is handled by CSpeechSynthesisSession::ServiceError() which reports |
|
184 // the error code to the client |
|
185 // ---------------------------------------------------------------------------- |
|
186 // |
|
187 void CSpeechSynthesisSession::ServiceL( const RMessage2& aMessage ) |
|
188 { |
|
189 RUBY_DEBUG_BLOCK( "CSpeechSynthesisSession::ServiceL" ); |
|
190 RUBY_DEBUG1( "aMessage.Function(): %d", aMessage.Function() ); |
|
191 |
|
192 TInt message( aMessage.Function() ); |
|
193 |
|
194 if ( message == EPrime || message == EPrimeFileOutput || |
|
195 message == EPrimeStreamOutput || message == ESynthesise ) |
|
196 { |
|
197 Server().ReserveL( this, iAudioPriority ); |
|
198 |
|
199 TRAPD( error, DoAsyncServiceL( aMessage ) ); |
|
200 if( error ) |
|
201 { |
|
202 Server().Release( this ); |
|
203 User::Leave( error ); |
|
204 } |
|
205 } |
|
206 else |
|
207 { |
|
208 DoSyncServiceL( aMessage ); |
|
209 } |
|
210 } |
|
211 |
|
212 // ---------------------------------------------------------------------------- |
|
213 // CSpeechSynthesisSession::DoAsyncServiceL |
|
214 // |
|
215 // ---------------------------------------------------------------------------- |
|
216 // |
|
217 void CSpeechSynthesisSession::DoAsyncServiceL( const RMessage2& aMessage ) |
|
218 { |
|
219 RUBY_DEBUG_BLOCK( "CSpeechSynthesisSession::DoAsyncServiceL" ); |
|
220 |
|
221 TInt function( aMessage.Function() ); |
|
222 |
|
223 if ( function == ESynthesise ) |
|
224 { |
|
225 if ( iSessionState == ESessionPrimed ) |
|
226 { |
|
227 if ( !iFileOutputActivated ) |
|
228 { // Values may be changed when synthesis is paused. |
|
229 if ( iTmpVolume != iVolume ) |
|
230 { |
|
231 Server().SetVolume( iVolume ); |
|
232 iTmpVolume = iVolume; |
|
233 } |
|
234 |
|
235 if ( iTmpAudioOutput != iAudioOutput ) |
|
236 { |
|
237 Server().SetAudioOutputL( iAudioOutput ); |
|
238 iTmpAudioOutput = iAudioOutput; |
|
239 } |
|
240 } |
|
241 |
|
242 Server().Synthesize(); |
|
243 } |
|
244 else |
|
245 { |
|
246 User::Leave( KErrNotReady ); |
|
247 } |
|
248 } |
|
249 else if ( function == EPrimeStreamOutput ) |
|
250 { |
|
251 User::Leave( KErrNotSupported ); |
|
252 } |
|
253 else // Prime or EPrimeFileOutput |
|
254 { |
|
255 iSessionState = ESessionIdle; |
|
256 Server().Stop(); |
|
257 |
|
258 if ( iClosePlugin || Server().PreviousSession() != this ) |
|
259 { |
|
260 iClosePlugin = EFalse; |
|
261 |
|
262 Server().ClosePlugin(); |
|
263 Server().SetVoiceL( iCurrentVoice, iSpeakingRate ); |
|
264 |
|
265 // Set custom commands, plugin ingnores commands if the state |
|
266 // is incorrect for some command |
|
267 for ( TInt i( 0 ); i < iCustomCommands.Count(); i++ ) |
|
268 { |
|
269 Server().CustomCommand( iCustomCommands[i].iCommand, iCustomCommands[i].iValue ); |
|
270 } |
|
271 } |
|
272 else |
|
273 { |
|
274 Server().SetVoiceL( iCurrentVoice, iSpeakingRate ); |
|
275 } |
|
276 |
|
277 // Fetch text to be synthesised |
|
278 HBufC* text = HBufC::NewLC( aMessage.GetDesLengthL( 0 ) ); |
|
279 TPtr ptr = text->Des(); |
|
280 aMessage.ReadL( 0, ptr ); |
|
281 |
|
282 if ( function == EPrime ) |
|
283 { |
|
284 Server().SetAudioPriorityL( iAudioPriority, iAudioPreference ); |
|
285 |
|
286 Server().SetVolume( iVolume ); |
|
287 iTmpVolume = iVolume; |
|
288 |
|
289 Server().SetAudioOutputL( iAudioOutput ); |
|
290 iTmpAudioOutput = iAudioOutput; |
|
291 |
|
292 Server().PrimeL( ptr ); |
|
293 |
|
294 // Set custom commands, plugin ingnores commands if the state |
|
295 // is incorrect for some command |
|
296 for ( TInt i( 0 ); i < iCustomCommands.Count(); i++ ) |
|
297 { |
|
298 Server().CustomCommand( iCustomCommands[i].iCommand, iCustomCommands[i].iValue ); |
|
299 } |
|
300 |
|
301 iFileOutputActivated = EFalse; |
|
302 } |
|
303 else |
|
304 { |
|
305 Server().PrimeL( ptr, iFile ); |
|
306 |
|
307 iFileOutputActivated = ETrue; |
|
308 } |
|
309 |
|
310 CleanupStack::PopAndDestroy( text ); |
|
311 } |
|
312 |
|
313 iStoredMessage = aMessage; |
|
314 } |
|
315 |
|
316 // ---------------------------------------------------------------------------- |
|
317 // CSpeechSynthesisSession::DoSyncServiceL |
|
318 // |
|
319 // ---------------------------------------------------------------------------- |
|
320 // |
|
321 void CSpeechSynthesisSession::DoSyncServiceL( const RMessage2& aMessage ) |
|
322 { |
|
323 RUBY_DEBUG_BLOCK( "CSpeechSynthesisSession::DoSyncServiceL" ); |
|
324 |
|
325 switch ( aMessage.Function() ) |
|
326 { |
|
327 case ETransferFileHandle: |
|
328 |
|
329 User::LeaveIfError( iFile.AdoptFromClient( aMessage, |
|
330 KFsHandleIndex, |
|
331 KFileHandleIndex ) ); |
|
332 |
|
333 break; |
|
334 |
|
335 case EStopSynthesis: |
|
336 |
|
337 DoStopSynthesisL(); |
|
338 |
|
339 break; |
|
340 |
|
341 case EPauseSynthesis: |
|
342 |
|
343 DoPauseSynthesisL(); |
|
344 |
|
345 break; |
|
346 |
|
347 case EGetDuration: |
|
348 |
|
349 DoGetDurationL( aMessage ); |
|
350 |
|
351 break; |
|
352 |
|
353 case EGetLanguages: |
|
354 |
|
355 DoGetLanguagesL( aMessage ); |
|
356 |
|
357 break; |
|
358 |
|
359 case EGetLanguageCount: |
|
360 |
|
361 DoGetLanguageCountL( aMessage ); |
|
362 |
|
363 break; |
|
364 |
|
365 case EGetVoices: |
|
366 |
|
367 DoGetVoicesL( aMessage ); |
|
368 |
|
369 break; |
|
370 |
|
371 case EGetVoiceCount: |
|
372 |
|
373 DoGetVoiceCountL( aMessage ); |
|
374 |
|
375 break; |
|
376 |
|
377 case EVoice: |
|
378 |
|
379 DoVoiceL( aMessage ); |
|
380 |
|
381 break; |
|
382 |
|
383 case ESetVoice: |
|
384 |
|
385 DoSetVoiceL( aMessage ); |
|
386 |
|
387 break; |
|
388 |
|
389 case EMaxSpeakingRate: |
|
390 |
|
391 DoMaxSpeakingRateL( aMessage ); |
|
392 |
|
393 break; |
|
394 |
|
395 case ESpeakingRate: |
|
396 |
|
397 DoSpeakingRateL( aMessage ); |
|
398 |
|
399 break; |
|
400 |
|
401 case ESetSpeakingRate: |
|
402 |
|
403 DoSetSpeakingRateL( aMessage ); |
|
404 |
|
405 break; |
|
406 |
|
407 case EMaxVolume: |
|
408 |
|
409 DoMaxVolumeL( aMessage ); |
|
410 |
|
411 break; |
|
412 |
|
413 case EVolume: |
|
414 |
|
415 DoVolumeL( aMessage ); |
|
416 |
|
417 break; |
|
418 |
|
419 case ESetVolume: |
|
420 |
|
421 DoSetVolumeL( aMessage ); |
|
422 |
|
423 break; |
|
424 |
|
425 case ESetAudioPriority: |
|
426 |
|
427 DoSetAudioPriority( aMessage ); |
|
428 |
|
429 break; |
|
430 |
|
431 case ESetAudioOutput: |
|
432 |
|
433 DoSetAudioOutputL( aMessage ); |
|
434 |
|
435 break; |
|
436 |
|
437 case ECustomCommand: |
|
438 |
|
439 DoCustomCommandL( aMessage ); |
|
440 |
|
441 break; |
|
442 |
|
443 default: |
|
444 |
|
445 RUBY_ERROR1( "CSpeechSynthesisSession::ServiceL - %d", |
|
446 aMessage.Function() ); |
|
447 |
|
448 PanicClient( aMessage, EPanicIllegalFunction ); |
|
449 |
|
450 break; |
|
451 } |
|
452 |
|
453 aMessage.Complete( KErrNone ); |
|
454 } |
|
455 |
|
456 // ---------------------------------------------------------------------------- |
|
457 // CSpeechSynthesisSession::DoStopSynthesisL |
|
458 // |
|
459 // ---------------------------------------------------------------------------- |
|
460 // |
|
461 void CSpeechSynthesisSession::DoStopSynthesisL() |
|
462 { |
|
463 RUBY_DEBUG_BLOCK( "" ); |
|
464 |
|
465 // Check we have permission to use server. |
|
466 Server().ReserveL( this ); |
|
467 |
|
468 // Synthesis is ongoing |
|
469 Server().Stop(); |
|
470 |
|
471 iSessionState = ESessionIdle; |
|
472 |
|
473 iDuration = 0; |
|
474 iFile.Close(); |
|
475 |
|
476 // Release server and complete the previous message |
|
477 Server().Release( this ); |
|
478 |
|
479 if ( !iStoredMessage.IsNull() ) |
|
480 { |
|
481 iStoredMessage.Complete( KErrAbort ); |
|
482 } |
|
483 } |
|
484 |
|
485 // ---------------------------------------------------------------------------- |
|
486 // CSpeechSynthesisSession::DoPauseSynthesisL |
|
487 // |
|
488 // ---------------------------------------------------------------------------- |
|
489 // |
|
490 void CSpeechSynthesisSession::DoPauseSynthesisL() |
|
491 { |
|
492 RUBY_DEBUG_BLOCK( "" ); |
|
493 |
|
494 if ( iSessionState == ESessionPrimed && !iStoredMessage.IsNull() ) |
|
495 { |
|
496 if ( iFileOutputActivated ) |
|
497 { |
|
498 User::Leave( KErrNotSupported ); |
|
499 } |
|
500 |
|
501 // Check we have permission to use server. |
|
502 Server().ReserveL( this ); |
|
503 |
|
504 // Synthesis is ongoing |
|
505 Server().Pause(); |
|
506 |
|
507 iStoredMessage.Complete( KErrCancel ); |
|
508 } |
|
509 else |
|
510 { |
|
511 User::Leave( KErrNotReady ); |
|
512 } |
|
513 } |
|
514 |
|
515 // ---------------------------------------------------------------------------- |
|
516 // CSpeechSynthesisSession::DoGetDurationL |
|
517 // |
|
518 // ---------------------------------------------------------------------------- |
|
519 // |
|
520 void CSpeechSynthesisSession::DoGetDurationL( const RMessage2& aMessage ) |
|
521 { |
|
522 RUBY_DEBUG_BLOCK( "" ); |
|
523 |
|
524 if ( iSessionState != ESessionPrimed ) |
|
525 { |
|
526 User::Leave( KErrNotReady ); |
|
527 } |
|
528 else if ( iDuration.Int64() == 0 ) |
|
529 { |
|
530 User::Leave( KErrNotSupported ); |
|
531 } |
|
532 |
|
533 TPckgBuf<TTimeIntervalMicroSeconds> pkg( iDuration ); |
|
534 aMessage.WriteL( 0, pkg ); |
|
535 } |
|
536 |
|
537 // ---------------------------------------------------------------------------- |
|
538 // CSpeechSynthesisSession::DoGetLanguagesL |
|
539 // |
|
540 // ---------------------------------------------------------------------------- |
|
541 // |
|
542 void CSpeechSynthesisSession::DoGetLanguagesL( const RMessage2& aMessage ) |
|
543 { |
|
544 RUBY_DEBUG_BLOCK( "" ); |
|
545 |
|
546 // DoGetLanguagesL is called immediately after EGetLanguageCount |
|
547 if ( iLanguages.Count() > 0 ) |
|
548 { |
|
549 const TInt dataSize( iLanguages.Count() * sizeof(TLanguage) ); |
|
550 |
|
551 HBufC8* tmp = HBufC8::NewLC( dataSize ); |
|
552 TPtr8 tmp_ptr( tmp->Des() ); |
|
553 |
|
554 tmp_ptr.Append( (TUint8*)&iLanguages[0], dataSize ); |
|
555 |
|
556 aMessage.WriteL( 0, tmp_ptr ); |
|
557 |
|
558 CleanupStack::PopAndDestroy( tmp ); |
|
559 } |
|
560 } |
|
561 |
|
562 // ---------------------------------------------------------------------------- |
|
563 // CSpeechSynthesisSession::DoGetLanguageCountL |
|
564 // |
|
565 // ---------------------------------------------------------------------------- |
|
566 // |
|
567 void CSpeechSynthesisSession::DoGetLanguageCountL( const RMessage2& aMessage ) |
|
568 { |
|
569 RUBY_DEBUG_BLOCK( "" ); |
|
570 |
|
571 iLanguages.Reset(); |
|
572 |
|
573 Server().GetSupportedLanguagesL( iLanguages ); |
|
574 |
|
575 TPckgBuf<TInt> pkg_int( iLanguages.Count() ); |
|
576 aMessage.WriteL( 0, pkg_int ); |
|
577 } |
|
578 |
|
579 // ---------------------------------------------------------------------------- |
|
580 // CSpeechSynthesisSession::DoGetVoicesL |
|
581 // |
|
582 // ---------------------------------------------------------------------------- |
|
583 // |
|
584 void CSpeechSynthesisSession::DoGetVoicesL( const RMessage2& aMessage ) |
|
585 { |
|
586 RUBY_DEBUG_BLOCK( "" ); |
|
587 |
|
588 // DoGetVoicesL is called immediately after EGetVoiceCount |
|
589 if ( iVoices.Count() > 0 ) |
|
590 { |
|
591 TInt dataSize( iVoices.Count() * sizeof(TVoice) ); |
|
592 |
|
593 HBufC8* tmp = HBufC8::NewLC( dataSize ); |
|
594 TPtr8 tmp_ptr( tmp->Des() ); |
|
595 |
|
596 tmp_ptr.Append( (TUint8*)&iVoices[0], dataSize ); |
|
597 |
|
598 aMessage.WriteL( 0, tmp_ptr ); |
|
599 |
|
600 CleanupStack::PopAndDestroy( tmp ); |
|
601 } |
|
602 } |
|
603 |
|
604 // ---------------------------------------------------------------------------- |
|
605 // CSpeechSynthesisSession::DoGetVoiceCountL |
|
606 // |
|
607 // ---------------------------------------------------------------------------- |
|
608 // |
|
609 void CSpeechSynthesisSession::DoGetVoiceCountL( const RMessage2& aMessage ) |
|
610 { |
|
611 RUBY_DEBUG_BLOCK( "" ); |
|
612 |
|
613 iVoices.Reset(); |
|
614 TLanguage language( static_cast<TLanguage> ( aMessage.Int1() ) ); |
|
615 |
|
616 Server().GetSupportedVoicesL( language, iVoices ); |
|
617 |
|
618 TPckgBuf<TInt> pkg_int( iVoices.Count() ); |
|
619 aMessage.WriteL( 0, pkg_int ); |
|
620 } |
|
621 |
|
622 // ---------------------------------------------------------------------------- |
|
623 // CSpeechSynthesisSession::DoVoiceL |
|
624 // |
|
625 // ---------------------------------------------------------------------------- |
|
626 // |
|
627 void CSpeechSynthesisSession::DoVoiceL( const RMessage2& aMessage ) |
|
628 { |
|
629 RUBY_DEBUG_BLOCK( "" ); |
|
630 |
|
631 if ( !Server().IsVoiceValidL( iCurrentVoice ) ) |
|
632 { |
|
633 Server().GetDefaultVoiceL( iCurrentVoice ); |
|
634 } |
|
635 |
|
636 TPckgBuf<TVoice> pkg_voice( iCurrentVoice ); |
|
637 aMessage.WriteL( 0, pkg_voice ); |
|
638 } |
|
639 |
|
640 // ---------------------------------------------------------------------------- |
|
641 // CSpeechSynthesisSession::DoSetVoiceL |
|
642 // |
|
643 // ---------------------------------------------------------------------------- |
|
644 // |
|
645 void CSpeechSynthesisSession::DoSetVoiceL( const RMessage2& aMessage ) |
|
646 { |
|
647 RUBY_DEBUG_BLOCK( "" ); |
|
648 |
|
649 TPckgBuf<TVoice> pkg_voice; |
|
650 aMessage.ReadL( 0, pkg_voice ); |
|
651 |
|
652 TVoice voice( pkg_voice() ); |
|
653 |
|
654 if ( Server().IsVoiceValidL( voice ) ) |
|
655 { |
|
656 iCurrentVoice = voice; |
|
657 |
|
658 // Custom commands are valid until new voice is set |
|
659 iCustomCommands.Close(); |
|
660 } |
|
661 else |
|
662 { |
|
663 User::Leave( KErrArgument ); |
|
664 } |
|
665 } |
|
666 |
|
667 // ---------------------------------------------------------------------------- |
|
668 // CSpeechSynthesisSession::DoMaxSpeakingRateL |
|
669 // |
|
670 // ---------------------------------------------------------------------------- |
|
671 // |
|
672 void CSpeechSynthesisSession::DoMaxSpeakingRateL( const RMessage2& aMessage ) |
|
673 { |
|
674 RUBY_DEBUG_BLOCK( "" ); |
|
675 |
|
676 TPckgBuf<TInt> pkg_int( iMaxSpeakingRate ); |
|
677 aMessage.WriteL( 0, pkg_int ); |
|
678 } |
|
679 |
|
680 // ---------------------------------------------------------------------------- |
|
681 // CSpeechSynthesisSession::DoSpeakingRateL |
|
682 // |
|
683 // ---------------------------------------------------------------------------- |
|
684 // |
|
685 void CSpeechSynthesisSession::DoSpeakingRateL( const RMessage2& aMessage ) |
|
686 { |
|
687 RUBY_DEBUG_BLOCK( "" ); |
|
688 |
|
689 TPckgBuf<TInt> pkg_int( iSpeakingRate ); |
|
690 aMessage.WriteL( 0, pkg_int ); |
|
691 } |
|
692 |
|
693 // ---------------------------------------------------------------------------- |
|
694 // CSpeechSynthesisSession::DoSetSpeakingRateL |
|
695 // |
|
696 // ---------------------------------------------------------------------------- |
|
697 // |
|
698 void CSpeechSynthesisSession::DoSetSpeakingRateL( const RMessage2& aMessage ) |
|
699 { |
|
700 RUBY_DEBUG_BLOCK( "" ); |
|
701 |
|
702 TInt newValue( aMessage.Int0() ); |
|
703 |
|
704 if ( newValue < KMinSpeakingRate || newValue > iMaxSpeakingRate ) |
|
705 { |
|
706 User::Leave( KErrArgument ); |
|
707 } |
|
708 else |
|
709 { |
|
710 iSpeakingRate = newValue; |
|
711 } |
|
712 } |
|
713 |
|
714 // ---------------------------------------------------------------------------- |
|
715 // CSpeechSynthesisSession::DoMaxVolumeL |
|
716 // |
|
717 // ---------------------------------------------------------------------------- |
|
718 // |
|
719 void CSpeechSynthesisSession::DoMaxVolumeL( const RMessage2& aMessage ) |
|
720 { |
|
721 RUBY_DEBUG_BLOCK( "" ); |
|
722 |
|
723 TPckgBuf<TInt> pkg_int( iMaxVolume ); |
|
724 aMessage.WriteL( 0, pkg_int ); |
|
725 } |
|
726 |
|
727 // ---------------------------------------------------------------------------- |
|
728 // CSpeechSynthesisSession::DoVolumeL |
|
729 // |
|
730 // ---------------------------------------------------------------------------- |
|
731 // |
|
732 void CSpeechSynthesisSession::DoVolumeL( const RMessage2& aMessage ) |
|
733 { |
|
734 RUBY_DEBUG_BLOCK( "" ); |
|
735 |
|
736 TPckgBuf<TInt> pkg_int( iVolume ); |
|
737 aMessage.WriteL( 0, pkg_int ); |
|
738 } |
|
739 |
|
740 // ---------------------------------------------------------------------------- |
|
741 // CSpeechSynthesisSession::DoSetVolumeL |
|
742 // |
|
743 // ---------------------------------------------------------------------------- |
|
744 // |
|
745 void CSpeechSynthesisSession::DoSetVolumeL( const RMessage2& aMessage ) |
|
746 { |
|
747 RUBY_DEBUG_BLOCK( "" ); |
|
748 |
|
749 TInt newValue( aMessage.Int0() ); |
|
750 |
|
751 if ( newValue < KMinVolume || newValue > iMaxVolume ) |
|
752 { |
|
753 User::Leave( KErrArgument ); |
|
754 } |
|
755 else |
|
756 { |
|
757 iVolume = newValue; |
|
758 |
|
759 if ( !iStoredMessage.IsNull() ) |
|
760 { |
|
761 // Check first we have permission to use server. |
|
762 TRAP_IGNORE( |
|
763 Server().ReserveL( this ); |
|
764 Server().SetVolume( iVolume ); |
|
765 iTmpVolume = iVolume; |
|
766 ); |
|
767 } |
|
768 } |
|
769 } |
|
770 |
|
771 // ---------------------------------------------------------------------------- |
|
772 // CSpeechSynthesisSession::DoSetAudioPriority |
|
773 // |
|
774 // ---------------------------------------------------------------------------- |
|
775 // |
|
776 void CSpeechSynthesisSession::DoSetAudioPriority( const RMessage2& aMessage ) |
|
777 { |
|
778 RUBY_DEBUG0( "" ); |
|
779 |
|
780 iAudioPriority = aMessage.Int0(); |
|
781 iAudioPreference = aMessage.Int1(); |
|
782 } |
|
783 |
|
784 // ---------------------------------------------------------------------------- |
|
785 // CSpeechSynthesisSession::DoSetAudioOutputL |
|
786 // |
|
787 // ---------------------------------------------------------------------------- |
|
788 // |
|
789 void CSpeechSynthesisSession::DoSetAudioOutputL( const RMessage2& aMessage ) |
|
790 { |
|
791 RUBY_DEBUG_BLOCK( "" ); |
|
792 |
|
793 iAudioOutput = aMessage.Int0(); |
|
794 |
|
795 if ( !iStoredMessage.IsNull() ) |
|
796 { |
|
797 // Check first we have permission to use server. |
|
798 TRAPD( error, Server().ReserveL( this ) ); |
|
799 if ( error == KErrNone ) |
|
800 { |
|
801 Server().SetAudioOutputL( iAudioOutput ); |
|
802 iTmpAudioOutput = iAudioOutput; |
|
803 } |
|
804 } |
|
805 } |
|
806 |
|
807 // ---------------------------------------------------------------------------- |
|
808 // CSpeechSynthesisSession::DoCustomCommandL |
|
809 // |
|
810 // ---------------------------------------------------------------------------- |
|
811 // |
|
812 void CSpeechSynthesisSession::DoCustomCommandL( const RMessage2& aMessage ) |
|
813 { |
|
814 RUBY_DEBUG_BLOCK( "" ); |
|
815 |
|
816 iClosePlugin = ETrue; |
|
817 |
|
818 TInt command( aMessage.Int0() ); |
|
819 TInt value( aMessage.Int1() ); |
|
820 |
|
821 TBool found( EFalse ); |
|
822 TInt count( iCustomCommands.Count() ); |
|
823 |
|
824 for ( TInt i( 0 ); i < count; i++ ) |
|
825 { |
|
826 if ( iCustomCommands[i].iCommand == command ) |
|
827 { |
|
828 iCustomCommands[i].iValue = value; |
|
829 found = ETrue; |
|
830 break; |
|
831 } |
|
832 } |
|
833 |
|
834 if ( !found ) |
|
835 { |
|
836 TCustomCommand newItem; |
|
837 newItem.iCommand = command; |
|
838 newItem.iValue = value; |
|
839 |
|
840 iCustomCommands.AppendL( newItem ); |
|
841 } |
|
842 |
|
843 Server().CustomCommand( command, value ); |
|
844 } |
|
845 |
|
846 // ---------------------------------------------------------------------------- |
|
847 // CSpeechSynthesisSession::ServiceError |
|
848 // Handle an error from CSpeechSynthesisSession::ServiceL() |
|
849 // ---------------------------------------------------------------------------- |
|
850 // |
|
851 void CSpeechSynthesisSession::ServiceError( const RMessage2& aMessage, |
|
852 TInt aError ) |
|
853 { |
|
854 RUBY_DEBUG1( "CSpeechSynthesisSession::ServiceError %d", aError ); |
|
855 |
|
856 CSession2::ServiceError( aMessage, aError ); |
|
857 } |
|
858 |
|
859 // End of file |