|
1 /* |
|
2 * Copyright (c) 2005 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: S60 Audio Event Monitor implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "S60AudioPlayer.h" |
|
21 #include "S60PlayerEventDispatcher.h" |
|
22 |
|
23 |
|
24 CPlayerEventDispatcher::~CPlayerEventDispatcher() |
|
25 { |
|
26 #ifdef _DEBUG |
|
27 RDebug::Print(_L("CPlayerEventDispatcher::~CPlayerEventDispatcher")); |
|
28 #endif |
|
29 } |
|
30 |
|
31 CPlayerEventDispatcher::CPlayerEventDispatcher( |
|
32 MS60AudioPlayerObserver& aObserver ) : |
|
33 CActive(CActive::EPriorityStandard), |
|
34 iObserver(&aObserver) |
|
35 { |
|
36 #ifdef _DEBUG |
|
37 RDebug::Print(_L("CPlayerEventDispatcher::CPlayerEventDispatcher")); |
|
38 #endif |
|
39 CActiveScheduler::Add(this); |
|
40 } |
|
41 |
|
42 CPlayerEventDispatcher* CPlayerEventDispatcher::NewL(MS60AudioPlayerObserver& aObserver) |
|
43 { |
|
44 #ifdef _DEBUG |
|
45 RDebug::Print(_L("CPlayerEventDispatcher::NewL")); |
|
46 #endif |
|
47 |
|
48 CPlayerEventDispatcher* self = new(ELeave) CPlayerEventDispatcher(aObserver); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop(self); |
|
52 return self; |
|
53 } |
|
54 |
|
55 void CPlayerEventDispatcher::ConstructL() |
|
56 { |
|
57 #ifdef _DEBUG |
|
58 RDebug::Print(_L("CPlayerEventDispatcher::ConstructL")); |
|
59 #endif |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CPlayerEventDispatcher::AddSourceComplete |
|
64 // AddSource complete Callback from the AudioPlayer |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 |
|
68 void CPlayerEventDispatcher::AddSourceComplete(TInt aError) |
|
69 { |
|
70 #ifdef _DEBUG |
|
71 RDebug::Print(_L("CPlayerEventDispatcher::AddSourceComplete")); |
|
72 #endif |
|
73 iError = aError; |
|
74 iPlayerEvent = EAddSourceComplete; |
|
75 if (!IsActive()) |
|
76 { |
|
77 TRequestStatus* s = &iStatus; |
|
78 SetActive(); |
|
79 User::RequestComplete(s, KErrNone); |
|
80 } |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CPlayerEventDispatcher::StateChanged |
|
85 // State changed Callback from the AudioPlayer |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 |
|
89 void CPlayerEventDispatcher::StateChanged( |
|
90 TPlayerState aState, |
|
91 TInt aError ) |
|
92 { |
|
93 iPlayerState = aState; |
|
94 iPlayerEvent = EStateChanged; |
|
95 iError = aError; |
|
96 if (!IsActive()) |
|
97 { |
|
98 TRequestStatus* s = &iStatus; |
|
99 SetActive(); |
|
100 User::RequestComplete(s, iError); |
|
101 } |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CPlayerEventDispatcher::FastForwardSupportChanged |
|
106 // FastForward Support changed Callback from the AudioPlayer |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 |
|
110 void CPlayerEventDispatcher::FastForwardSupportChanged() |
|
111 { |
|
112 iPlayerEvent = EFastForwardSupportChanged; |
|
113 if (!IsActive()) |
|
114 { |
|
115 TRequestStatus* s = &iStatus; |
|
116 SetActive(); |
|
117 User::RequestComplete(s, KErrNone); |
|
118 } |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CPlayerEventDispatcher::RewindSupportChanged |
|
123 // Rewind Support changed Callback from the AudioPlayer |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 |
|
127 void CPlayerEventDispatcher::RewindSupportChanged() |
|
128 { |
|
129 iPlayerEvent = ERewindSupportChanged; |
|
130 if (!IsActive()) |
|
131 { |
|
132 TRequestStatus* s = &iStatus; |
|
133 SetActive(); |
|
134 User::RequestComplete(s, KErrNone); |
|
135 } |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CPlayerEventDispatcher::DurationChanged |
|
140 // Duration changed Callback from the AudioPlayer |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 void CPlayerEventDispatcher::DurationChanged(const TTimeIntervalMicroSeconds& aDuration) |
|
144 { |
|
145 iDuration = aDuration; |
|
146 iPlayerEvent = EDurationChanged; |
|
147 if (!IsActive()) |
|
148 { |
|
149 TRequestStatus* s = &iStatus; |
|
150 SetActive(); |
|
151 User::RequestComplete(s, KErrNone); |
|
152 } |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CPlayerEventDispatcher::RunL |
|
157 // RunL for the PlayerEvent Dispatcher |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 |
|
161 void CPlayerEventDispatcher::RunL() |
|
162 { |
|
163 switch (iPlayerEvent) |
|
164 { |
|
165 case EAddSourceComplete: |
|
166 iObserver->AddSourceComplete(iError); |
|
167 break; |
|
168 case EStateChanged: |
|
169 iObserver->StateChanged(iPlayerState, iError); |
|
170 break; |
|
171 case ERewindSupportChanged: |
|
172 iObserver->RewindSupportChanged(); |
|
173 break; |
|
174 case EFastForwardSupportChanged: |
|
175 iObserver->FastForwardSupportChanged(); |
|
176 break; |
|
177 case EDurationChanged: |
|
178 iObserver->DurationChanged(iDuration); |
|
179 break; |
|
180 } |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CPlayerEventDispatcher::DoCancel |
|
185 // Duration changed Callback from the AudioPlayer |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 void CPlayerEventDispatcher::DoCancel() |
|
189 { |
|
190 // Nothing to cancel |
|
191 } |
|
192 |
|
193 |
|
194 |
|
195 |