mpx/playbackframework/playbackengine/src/mpxplaybackengine.cpp
changeset 20 b1fb57be53fe
parent 3 b425f12f328d
child 15 d240f0a77280
child 21 a05c44bc3c61
equal deleted inserted replaced
4:d45095c2f4f3 20:b1fb57be53fe
    45 
    45 
    46 // CONSTANTS
    46 // CONSTANTS
    47 const TInt KMPXSmallVolumeIncrement = 5;
    47 const TInt KMPXSmallVolumeIncrement = 5;
    48 const TInt KMPXLargeVolumeIncrement = 10;
    48 const TInt KMPXLargeVolumeIncrement = 10;
    49 const TInt KPercentMultiplier = 100;
    49 const TInt KPercentMultiplier = 100;
       
    50 const TInt KMPXSyncMsgTimer = 3000000; // 3 seconds
    50 _LIT(KWmaExtension, ".wma");
    51 _LIT(KWmaExtension, ".wma");
    51 _LIT(KRaExtension, ".ra");
    52 _LIT(KRaExtension, ".ra");
    52 
    53 
    53 
    54 
    54 // ============================ MEMBER FUNCTIONS ==============================
    55 // ============================ MEMBER FUNCTIONS ==============================
   184     iInitVolume = ETrue;
   185     iInitVolume = ETrue;
   185 #if defined(__HIGH_RESOLUTION_VOLUME)
   186 #if defined(__HIGH_RESOLUTION_VOLUME)
   186     iVolRoundedUp = EFalse;
   187     iVolRoundedUp = EFalse;
   187 #endif
   188 #endif
   188     iPluginHandler->Plugin()->PropertyL( EPbPropertyVolume );
   189     iPluginHandler->Plugin()->PropertyL( EPbPropertyVolume );
       
   190     iSyncMsgTimer = CPeriodic::NewL( CActive::EPriorityIdle ); 
       
   191     iSyncMsgWait = new (ELeave) CActiveSchedulerWait; 
   189     }
   192     }
   190 
   193 
   191 // ----------------------------------------------------------------------------
   194 // ----------------------------------------------------------------------------
   192 // Destructor
   195 // Destructor
   193 // ----------------------------------------------------------------------------
   196 // ----------------------------------------------------------------------------
   230     delete iMediaHelper;
   233     delete iMediaHelper;
   231     delete iDummyMediaObserver;
   234     delete iDummyMediaObserver;
   232 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   235 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   233     iFile64.Close();
   236     iFile64.Close();
   234 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
   237 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   238     delete iSyncMsgTimer;
       
   239     if (iSyncMsgWait && iSyncMsgWait->IsStarted() )
       
   240             {
       
   241             iSyncMsgWait->AsyncStop();
       
   242             }
       
   243     delete iSyncMsgWait; 
   235     }
   244     }
   236 
   245 
   237 // ----------------------------------------------------------------------------
   246 // ----------------------------------------------------------------------------
   238 // Initialises from collection
   247 // Initialises from collection
   239 // ----------------------------------------------------------------------------
   248 // ----------------------------------------------------------------------------
  2173         case EPbCmdSetAutoResume:
  2182         case EPbCmdSetAutoResume:
  2174             {
  2183             {
  2175             iAutoResumeHandler->SetAutoResume( aData );
  2184             iAutoResumeHandler->SetAutoResume( aData );
  2176             break;
  2185             break;
  2177             }
  2186             }
       
  2187         case EPbCmdSyncMsgComplete:
       
  2188             {
       
  2189             StopWaitLoop();
       
  2190             break;
       
  2191             }
  2178         default:
  2192         default:
  2179             ASSERT(0);
  2193             ASSERT(0);
  2180         }
  2194         }
  2181     MPX_DEBUG1("CMPXPlaybackEngine::HandleCommandL() exiting");
  2195     MPX_DEBUG1("CMPXPlaybackEngine::HandleCommandL() exiting");
  2182     }
  2196     }
  3857         User::Leave( KErrNotFound );
  3871         User::Leave( KErrNotFound );
  3858         }
  3872         }
  3859     }
  3873     }
  3860 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  3874 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
  3861 
  3875 
       
  3876 // ----------------------------------------------------------------------------
       
  3877 // Cancel timer. 
       
  3878 // ----------------------------------------------------------------------------
       
  3879 void CMPXPlaybackEngine::CancelSyncMsgTimer()
       
  3880     {
       
  3881     MPX_FUNC("CMPXPlaybackEngine::CancelSyncMsgTimer()");
       
  3882     // Cancel timer.
       
  3883     if ( iSyncMsgTimer && iSyncMsgTimer->IsActive() )
       
  3884         {
       
  3885         MPX_DEBUG1("CMPXPlaybackEngine::CancelSyncMsgTimer(): Timer active, cancelling");
       
  3886         iSyncMsgTimer->Cancel();
       
  3887         }
       
  3888     }
       
  3889 // ----------------------------------------------------------------------------
       
  3890 // Callback for timer.
       
  3891 // ----------------------------------------------------------------------------
       
  3892 TInt CMPXPlaybackEngine::SyncMsgTimerCallback(TAny* aPtr)
       
  3893     {
       
  3894     MPX_FUNC("CMPXPlaybackEngine::SyncMsgTimerCallback()");
       
  3895     CMPXPlaybackEngine* ptr =
       
  3896         static_cast<CMPXPlaybackEngine*>(aPtr);
       
  3897     ptr->StopWaitLoop();
       
  3898     return KErrNone;
       
  3899     }
       
  3900 // ----------------------------------------------------------------------------
       
  3901 // Handle a synchronous message
       
  3902 // ----------------------------------------------------------------------------
       
  3903 //
       
  3904 TInt CMPXPlaybackEngine::HandlePlaybackSyncMessage (const CMPXMessage& aMsg)
       
  3905     {    
       
  3906     MPX_FUNC("CMPXPlaybackEngine::HandlePlaybackSyncMessage()");    
       
  3907     TInt err = iClientList->SendSyncMsg(&aMsg);
       
  3908     if (err != KErrNone)
       
  3909         {
       
  3910         return err;
       
  3911         }
       
  3912     // Cancel timer.
       
  3913     CancelSyncMsgTimer();
       
  3914     // Start timer in case there is no callback from primary client. 
       
  3915     iSyncMsgTimer->Start(
       
  3916         KMPXSyncMsgTimer,
       
  3917         KMPXSyncMsgTimer,
       
  3918         TCallBack(SyncMsgTimerCallback, this ));
       
  3919             
       
  3920     // Start wait loop until we get a callback from primary client
       
  3921     if ( !iSyncMsgWait->IsStarted() )
       
  3922         {
       
  3923         iSyncMsgWait->Start();
       
  3924         }
       
  3925     return KErrNone;
       
  3926     }
       
  3927 // ----------------------------------------------------------------------------
       
  3928 // Stop the wait loop.
       
  3929 // ----------------------------------------------------------------------------
       
  3930 void CMPXPlaybackEngine::StopWaitLoop()
       
  3931     {
       
  3932     MPX_FUNC("CMPXPlaybackEngine::StopWaitLoop()");
       
  3933     // Cancel timer
       
  3934     CancelSyncMsgTimer();
       
  3935     
       
  3936     // Stop wait loop to unblock.
       
  3937     if ( iSyncMsgWait->IsStarted() )
       
  3938         {
       
  3939         MPX_DEBUG1("CMPXPlaybackEngine::StopWaitLoop(): Stopping the wait loop.");
       
  3940         iSyncMsgWait->AsyncStop();
       
  3941         }
       
  3942     }
  3862 // End of file
  3943 // End of file