mmserv/tms/tmsserver/src/tmsrtplayer.cpp
changeset 31 8dfd592727cb
parent 22 128eb6a32b84
child 33 5e8b14bae8c3
child 42 1fa3fb47b1e3
equal deleted inserted replaced
22:128eb6a32b84 31:8dfd592727cb
   592     else
   592     else
   593         {
   593         {
   594         if (!iAudioPlayer)
   594         if (!iAudioPlayer)
   595             {
   595             {
   596             CreateAudioPlayerL();
   596             CreateAudioPlayerL();
   597             if (!iTimer->IsActive())
   597             if (!iTimer->IsRunning())
   598                 {
   598                 {
   599                 // If InitComplete event doesn't occur within permittable time,
   599                 // If InitComplete event doesn't occur within permittable time,
   600                 // this will trigger fallback routine.
   600                 // this will trigger fallback routine.
   601                 iTimer->After(KTMSMaxRingingWaiting, this);
   601                 iTimer->NotifyAfter(KTMSMaxRingingWaiting, *this);
   602                 }
   602                 }
   603             }
   603             }
   604 
   604 
   605         // Start playing.
   605         // Start playing.
   606         if (!iAudioPlayer)
   606         if (!iAudioPlayer)
   607             {
   607             {
   608             iTimer->Cancel();
   608             iTimer->CancelNotify();
   609             PlayDefaultToneL();
   609             PlayDefaultToneL();
   610             }
   610             }
   611         else
   611         else
   612             {
   612             {
   613             iTonePlayingStatus = EAudioTonePlaying;
   613             iTonePlayingStatus = EAudioTonePlaying;
   737         {
   737         {
   738         iTtsDelayIndex = 0;
   738         iTtsDelayIndex = 0;
   739         iTtsDelaysCount = KTMSTtsDelaysCount;
   739         iTtsDelaysCount = KTMSTtsDelaysCount;
   740 
   740 
   741         // Start TTS timer just before RT
   741         // Start TTS timer just before RT
   742         if (!iTtsDelayTimer->IsActive())
   742         if (!iTtsDelayTimer->IsRunning())
   743             {
   743             {
   744             iTtsDelayTimer->After(KTMSTtsDelays[iTtsDelayIndex],
   744             iTtsDelayTimer->NotifyAfter(KTMSTtsDelays[iTtsDelayIndex],
   745                     TCallBack(HandleTtsDelayTimeout, this));
   745                     TCallBack(HandleTtsDelayTimeout, this));
   746             }
   746             }
   747         iTtsVolume = iRtParam.iVolume;
   747         iTtsVolume = iRtParam.iVolume;
   748         iTtsRingingType = iRtParam.iRingingType;
   748         iTtsRingingType = iRtParam.iRingingType;
   749         }
   749         }
   769     if (iBackupPlayer && err == TMS_RESULT_SUCCESS)
   769     if (iBackupPlayer && err == TMS_RESULT_SUCCESS)
   770         {
   770         {
   771         iTonePlayingStatus = EBackupTonePlaying;
   771         iTonePlayingStatus = EBackupTonePlaying;
   772         iTtsToneToBePlayed = EFalse;
   772         iTtsToneToBePlayed = EFalse;
   773         iTTsTimeOutCounter = 0;
   773         iTTsTimeOutCounter = 0;
   774         iTtsDelayTimer->Cancel();
   774         iTtsDelayTimer->CancelNotify();
   775         if (iTtsPlayer)
   775         if (iTtsPlayer)
   776             {
   776             {
   777             iTtsPlayer->StopPlaying();
   777             iTtsPlayer->StopPlaying();
   778             delete iTtsPlayer;
   778             delete iTtsPlayer;
   779             iTtsPlayer = NULL;
   779             iTtsPlayer = NULL;
   807         }
   807         }
   808 
   808 
   809     if (!iDefaultPlayer)
   809     if (!iDefaultPlayer)
   810         {
   810         {
   811         CreateDefaultRtPlayerL();
   811         CreateDefaultRtPlayerL();
   812         if (!iTimer->IsActive())
   812         if (!iTimer->IsRunning())
   813             {
   813             {
   814             // If InitComplete event doesn't occur within permittable time,
   814             // If InitComplete event doesn't occur within permittable time,
   815             // this will trigger fallback routine.
   815             // this will trigger fallback routine.
   816             iTimer->After(KTMSMaxRingingWaiting, this);
   816             iTimer->NotifyAfter(KTMSMaxRingingWaiting, *this);
   817             }
   817             }
   818         }
   818         }
   819 
   819 
   820     // Start playing.
   820     // Start playing.
   821     if (!iDefaultPlayer)
   821     if (!iDefaultPlayer)
   822         {
   822         {
   823         // Default player not ready, play backup.
   823         // Default player not ready, play backup.
   824         iTimer->Cancel();
   824         iTimer->CancelNotify();
   825         PlayBackupToneL();
   825         PlayBackupToneL();
   826         }
   826         }
   827     else
   827     else
   828         {
   828         {
   829         iTonePlayingStatus = EDefaultTonePlaying;
   829         iTonePlayingStatus = EDefaultTonePlaying;
   842     {
   842     {
   843     TRACE_PRN_FN_ENT;
   843     TRACE_PRN_FN_ENT;
   844 
   844 
   845     iTtsToneToBePlayed = EFalse;
   845     iTtsToneToBePlayed = EFalse;
   846     iTTsTimeOutCounter = 0;
   846     iTTsTimeOutCounter = 0;
   847     iTtsDelayTimer->Cancel();
   847     iTtsDelayTimer->CancelNotify();
   848     if (iTtsPlayer)
   848     if (iTtsPlayer)
   849         {
   849         {
   850         iTtsPlayer->StopPlaying();
   850         iTtsPlayer->StopPlaying();
   851         delete iTtsPlayer;
   851         delete iTtsPlayer;
   852         iTtsPlayer = NULL;
   852         iTtsPlayer = NULL;
   853         }
   853         }
   854     iTimer->Cancel();
   854     iTimer->CancelNotify();
   855 
   855 
   856     switch (iTonePlayingStatus)
   856     switch (iTonePlayingStatus)
   857         {
   857         {
   858         case EAudioTonePlaying:
   858         case EAudioTonePlaying:
   859             if (iAudioPlayer)
   859             if (iAudioPlayer)
  1238         // Recreate backup player
  1238         // Recreate backup player
  1239         TRAPD(ignore, CreateBkpRtPlayerL());
  1239         TRAPD(ignore, CreateBkpRtPlayerL());
  1240         if (ignore) ;
  1240         if (ignore) ;
  1241         }
  1241         }
  1242 
  1242 
  1243     iTimer->Cancel();
  1243     iTimer->CancelNotify();
  1244     DoHandlePlayerError(!deleteAll, EFalse);
  1244     DoHandlePlayerError(!deleteAll, EFalse);
  1245     iRtObserver.RtPlayerEvent(aEvent, aError);
  1245     iRtObserver.RtPlayerEvent(aEvent, aError);
  1246     }
  1246     }
  1247 
  1247 
  1248 // -----------------------------------------------------------------------------
  1248 // -----------------------------------------------------------------------------
  1254     {
  1254     {
  1255     if ((iTonePlayingStatus == EAudioTonePlaying && aPlayer == EPlayerAudio) ||
  1255     if ((iTonePlayingStatus == EAudioTonePlaying && aPlayer == EPlayerAudio) ||
  1256             (iTonePlayingStatus == EDefaultTonePlaying &&
  1256             (iTonePlayingStatus == EDefaultTonePlaying &&
  1257             aPlayer == EPlayerDefault))
  1257             aPlayer == EPlayerDefault))
  1258         {
  1258         {
  1259         iTimer->Cancel();
  1259         iTimer->CancelNotify();
  1260         }
  1260         }
  1261     else
  1261     else
  1262         {
  1262         {
  1263         iRtObserver.RtPlayerEvent(aEvent, aError);
  1263         iRtObserver.RtPlayerEvent(aEvent, aError);
  1264         }
  1264         }
  1300             {
  1300             {
  1301             // Ringingtype is "Ringing". New TTS iterations are required.
  1301             // Ringingtype is "Ringing". New TTS iterations are required.
  1302             // Need to restart TTS sequence TTS has completed its iterations,
  1302             // Need to restart TTS sequence TTS has completed its iterations,
  1303             // set index to zero.
  1303             // set index to zero.
  1304             iTtsDelayIndex = 0;
  1304             iTtsDelayIndex = 0;
  1305             if (!iTtsDelayTimer->IsActive())
  1305             if (!iTtsDelayTimer->IsRunning())
  1306                 {
  1306                 {
  1307                 // Restart TTS sequence
  1307                 // Restart TTS sequence
  1308                 iTtsDelayTimer->After(KTMSTtsDelays[iTtsDelayIndex],
  1308                 iTtsDelayTimer->NotifyAfter(KTMSTtsDelays[iTtsDelayIndex],
  1309                         TCallBack(HandleTtsDelayTimeout, this));
  1309                         TCallBack(HandleTtsDelayTimeout, this));
  1310                 }
  1310                 }
  1311             }
  1311             }
  1312 
  1312 
  1313         ReStartRingTonePlayer();
  1313         ReStartRingTonePlayer();
  1330         {
  1330         {
  1331         // Resuming after TTS first time
  1331         // Resuming after TTS first time
  1332         // Caller name is said once. Increase tone player volume.
  1332         // Caller name is said once. Increase tone player volume.
  1333         SolveNewVolumeAndRamptime(ESaidOnce);
  1333         SolveNewVolumeAndRamptime(ESaidOnce);
  1334 
  1334 
  1335         if (!iTtsDelayTimer->IsActive())
  1335         if (!iTtsDelayTimer->IsRunning())
  1336             {
  1336             {
  1337             // There are more TTS iterations to be played.
  1337             // There are more TTS iterations to be played.
  1338             iTtsDelayTimer->After(KTMSTtsDelays[iTtsDelayIndex],
  1338             iTtsDelayTimer->NotifyAfter(KTMSTtsDelays[iTtsDelayIndex],
  1339                     TCallBack(HandleTtsDelayTimeout, this));
  1339                     TCallBack(HandleTtsDelayTimeout, this));
  1340             }
  1340             }
  1341         }
  1341         }
  1342     else
  1342     else
  1343         {
  1343         {
  1345         SolveNewVolumeAndRamptime(ESaidTwice);
  1345         SolveNewVolumeAndRamptime(ESaidTwice);
  1346         }
  1346         }
  1347     }
  1347     }
  1348 
  1348 
  1349 // -----------------------------------------------------------------------------
  1349 // -----------------------------------------------------------------------------
  1350 // TMSRingTonePlayer::HandleTimeOutL
  1350 // TMSRingTonePlayer::TimerEvent
  1351 // -----------------------------------------------------------------------------
  1351 // -----------------------------------------------------------------------------
  1352 //
  1352 //
  1353 void TMSRingTonePlayer::HandleTimeOutL()
  1353 void TMSRingTonePlayer::TimerEvent()
  1354     {
  1354     {
  1355     DoHandlePlayerError(ETrue, ETrue);
  1355     DoHandlePlayerError(ETrue, ETrue);
  1356     }
  1356     }
  1357 
  1357 
  1358 // -----------------------------------------------------------------------------
  1358 // -----------------------------------------------------------------------------