upnpmpxplugins/upnpplaybackplugins/src/upnpmusicperiodizer.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2008 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:      Periodic timer support resource
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include "upnpmusicperiodizer.h"
       
    25 
       
    26 const TInt KPlaybackInfoTimeOutEnd = 2000000; // 2s wait check whether 
       
    27     //the playing is ended
       
    28 // ======== MEMBER FUNCTIONS ========
       
    29 
       
    30 // --------------------------------------------------------------------------
       
    31 // CUPnPMusicPeriodizer::NewL
       
    32 // 1st phase constructor.
       
    33 // --------------------------------------------------------------------------
       
    34 //
       
    35 CUPnPMusicPeriodizer* CUPnPMusicPeriodizer::NewL(
       
    36     MUPnPMusicPeriodizerObserver& aObserver,
       
    37     TInt32 aTimerWavelength )
       
    38     {
       
    39     CUPnPMusicPeriodizer* p = CUPnPMusicPeriodizer::NewLC(
       
    40         aObserver, aTimerWavelength );
       
    41     CleanupStack::Pop();
       
    42     return p;    
       
    43     }
       
    44 
       
    45 // --------------------------------------------------------------------------
       
    46 // CUPnPMusicPeriodizer::NewLC
       
    47 // 1st phase constructor.
       
    48 // --------------------------------------------------------------------------
       
    49 //  
       
    50 CUPnPMusicPeriodizer* CUPnPMusicPeriodizer::NewLC(
       
    51     MUPnPMusicPeriodizerObserver& aObserver,
       
    52     TInt32 aTimerWavelength )
       
    53     {
       
    54     
       
    55     CUPnPMusicPeriodizer* p = new(ELeave) CUPnPMusicPeriodizer( aObserver,
       
    56         aTimerWavelength );
       
    57     CleanupStack::PushL( p );
       
    58     p->ConstructL();
       
    59     return p;    
       
    60     }
       
    61 
       
    62 // --------------------------------------------------------------------------
       
    63 // CUPnPMusicPeriodizer::~CUPnPMusicPeriodizer
       
    64 // Desctructor.
       
    65 // --------------------------------------------------------------------------
       
    66 //
       
    67 CUPnPMusicPeriodizer::~CUPnPMusicPeriodizer()
       
    68     {
       
    69     // No implementation required
       
    70     }
       
    71 
       
    72 // --------------------------------------------------------------------------
       
    73 // CUPnPMusicPeriodizer::CUPnPMusicPeriodizer
       
    74 // Default constructor.
       
    75 // --------------------------------------------------------------------------
       
    76 //
       
    77 CUPnPMusicPeriodizer::CUPnPMusicPeriodizer(
       
    78     MUPnPMusicPeriodizerObserver& aObserver,
       
    79     TInt32 aTimerWavelength )
       
    80     :CTimer( EPriorityStandard ),
       
    81     iObserver( aObserver ),
       
    82     iTimerWavelength( aTimerWavelength )
       
    83     {
       
    84     // No implementation required
       
    85     }
       
    86 
       
    87 // --------------------------------------------------------------------------
       
    88 // CUPnPMusicPeriodizer::ConstructL
       
    89 // --------------------------------------------------------------------------
       
    90 //
       
    91 void CUPnPMusicPeriodizer::ConstructL()
       
    92     {
       
    93     CTimer::ConstructL();
       
    94     CActiveScheduler::Add(this);
       
    95     }
       
    96  
       
    97 // --------------------------------------------------------------------------
       
    98 // Periodizer services
       
    99 // --------------------------------------------------------------------------
       
   100 
       
   101 // --------------------------------------------------------------------------
       
   102 // CUPnPMusicPeriodizer::Start
       
   103 // Starts the periodizer.
       
   104 // --------------------------------------------------------------------------
       
   105 //
       
   106 void CUPnPMusicPeriodizer::Start()
       
   107     {
       
   108     if ( !IsActive() )
       
   109         {
       
   110         After( TTimeIntervalMicroSeconds32( iTimerWavelength ) );
       
   111         }
       
   112     }
       
   113 
       
   114 // --------------------------------------------------------------------------
       
   115 // CUPnPMusicPeriodizer::Continue
       
   116 // Continues a next step for the periodizer.
       
   117 // --------------------------------------------------------------------------
       
   118 //
       
   119 void CUPnPMusicPeriodizer::Continue()
       
   120     {
       
   121     After( TTimeIntervalMicroSeconds32( iTimerWavelength ) );
       
   122     }
       
   123 
       
   124 // --------------------------------------------------------------------------
       
   125 // CUPnPMusicPeriodizer::RunL
       
   126 // Receives the timer triggering.
       
   127 // --------------------------------------------------------------------------
       
   128 //
       
   129 void CUPnPMusicPeriodizer::RunL()
       
   130     {
       
   131     // deliver the periodic event to the observer
       
   132     if ( iTimerWavelength == KPlaybackInfoTimeOutEnd )
       
   133         {
       
   134         iObserver.HandlePeriodForEnd();
       
   135         }
       
   136     else
       
   137         {
       
   138         iObserver.HandlePeriod();
       
   139         }
       
   140     }
       
   141     
       
   142 // --------------------------------------------------------------------------
       
   143 // CUPnPMusicPeriodizer::Stop
       
   144 // Stops periodizer.
       
   145 // --------------------------------------------------------------------------
       
   146 //
       
   147 void CUPnPMusicPeriodizer::Stop()
       
   148     {
       
   149     Cancel();
       
   150     }
       
   151 
       
   152 
       
   153