|
1 /* |
|
2 * Copyright (c) 2002 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: mmftsplay test component |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "MediaEvent.h" |
|
19 |
|
20 //void CMediaEvent::hi() {} |
|
21 |
|
22 CMediaEvent* CMediaEvent::NewL(CTestModuleIf &aTestModuleIf , CStifLogger &aLogger, |
|
23 TTimeIntervalMicroSeconds32 aDelay , TTimeIntervalMicroSeconds32 aInterval, |
|
24 MEventTarget *aTarget , CParameters *aParameters , TInt aPriority) |
|
25 { |
|
26 CMediaEvent *__self = CMediaEvent::NewLC(aTestModuleIf , aLogger, |
|
27 aDelay , aInterval , aTarget, |
|
28 aParameters, aPriority); |
|
29 CleanupStack::Pop(__self); |
|
30 return __self; |
|
31 } |
|
32 |
|
33 CMediaEvent* CMediaEvent::NewLC(CTestModuleIf &aTestModuleIf , CStifLogger &aLogger, |
|
34 TTimeIntervalMicroSeconds32 aDelay , TTimeIntervalMicroSeconds32 aInterval, |
|
35 MEventTarget *aTarget, CParameters *aParameters , TInt aPriority) |
|
36 { |
|
37 CMediaEvent *__self = new(ELeave) CMediaEvent(aTestModuleIf , aLogger , aDelay , aInterval , aTarget , aParameters); |
|
38 CleanupStack::PushL(__self); |
|
39 __self->ConstructL(aPriority); |
|
40 return __self; |
|
41 } |
|
42 |
|
43 CMediaEvent::CMediaEvent (CTestModuleIf &aTestModuleIf , CStifLogger &aLogger, |
|
44 TTimeIntervalMicroSeconds32 aDelay, TTimeIntervalMicroSeconds32 aInterval, |
|
45 MEventTarget *aTarget , CParameters *aParameters) |
|
46 : iTestModuleIf(aTestModuleIf), iLogger(aLogger), |
|
47 iDelay(aDelay) , iInterval(aInterval) , iEventTarget(aTarget), |
|
48 iParameters(aParameters) , iCount(0) |
|
49 {} |
|
50 |
|
51 void CMediaEvent::ConstructL(TInt aPriority=CActive::EPriorityStandard) |
|
52 { |
|
53 iLogger.Log(_L("Creating event with priority (%d)") , aPriority); |
|
54 iPeriodic=CPeriodic::NewL(aPriority); |
|
55 iPeriodic->Start(iDelay , iInterval , TCallBack(Tick, this)); |
|
56 } |
|
57 |
|
58 CMediaEvent::~CMediaEvent () |
|
59 { |
|
60 iPeriodic->Cancel(); |
|
61 delete iPeriodic; |
|
62 delete iParameters; |
|
63 } |
|
64 |
|
65 TInt CMediaEvent::Tick(TAny *aObject) |
|
66 { |
|
67 return (static_cast<CMediaEvent*>(aObject) )->DoTick(); // cast, and call non-static function |
|
68 } |
|
69 |
|
70 TInt CMediaEvent::DoTick() |
|
71 { |
|
72 iCount++; |
|
73 if (! iEventTarget->ExecuteL(iParameters)) { |
|
74 iPeriodic->Cancel(); |
|
75 } |
|
76 return 0; |
|
77 } |
|
78 |
|
79 TInt CMediaEvent::GetCount() const |
|
80 { |
|
81 return iCount; |
|
82 } |