|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Downlink (playback) datapath |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <mmf/common/mmfcontroller.h> |
|
23 #include "mccdldatapath.h" |
|
24 #include "MccSubcontrollerLogs.h" |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // LOCAL CONSTANTS AND MACROS |
|
35 |
|
36 // MODULE DATA STRUCTURES |
|
37 |
|
38 // LOCAL FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 // ============================= LOCAL FUNCTIONS =============================== |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CMccDlDataPath::CMccDlDataPath |
|
48 // C++ default constructor can NOT contain any code, that |
|
49 // might leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 CMccDlDataPath::CMccDlDataPath( |
|
52 MAsyncEventHandler* aEventHandler, |
|
53 MMccResources* aMccResources, |
|
54 TMediaId aMediaId ) : |
|
55 CMccDataPathBase( aEventHandler, aMccResources, aMediaId ) |
|
56 { |
|
57 |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CMccDlDataPath::ConstructL |
|
62 // Symbian 2nd phase constructor can leave. |
|
63 // ----------------------------------------------------------------------------- |
|
64 void CMccDlDataPath::ConstructL() |
|
65 { |
|
66 __SUBCONTROLLER( "CMccDlDataPath::ConstructL" ) |
|
67 __SUBCONTROLLER( "CMccDlDataPath::ConstructL, exit" ) |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CMccDlDataPath::NewL |
|
72 // Static constructor. |
|
73 // ----------------------------------------------------------------------------- |
|
74 CMccDlDataPath* CMccDlDataPath::NewL( |
|
75 MAsyncEventHandler* aEventHandler, |
|
76 MMccResources* aMccResources, |
|
77 TMediaId aMediaId ) |
|
78 { |
|
79 // __ASSERT_ALWAYS ( aEventHandler, User::Leave(KErrArgument) ); |
|
80 |
|
81 CMccDlDataPath* self = new ( ELeave ) CMccDlDataPath( |
|
82 aEventHandler,aMccResources, aMediaId ); |
|
83 CleanupStack::PushL( self ); |
|
84 self->ConstructL(); |
|
85 CleanupStack::Pop( self ); |
|
86 |
|
87 return self; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CMccDlDataPath::~CMccDlDataPath |
|
92 // Destructor |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 CMccDlDataPath::~CMccDlDataPath() |
|
96 { |
|
97 __SUBCONTROLLER( "CMccDlDataPath::~CMccDlDataPath" ) |
|
98 __SUBCONTROLLER( "CMccDlDataPath::~CMccDlDataPath, exit" ) |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CMccDlDataPath::PrimeL |
|
103 // Primes the datapath |
|
104 // ----------------------------------------------------------------------------- |
|
105 void CMccDlDataPath::PrimeL( TUint32 /*aEndpointId*/ ) |
|
106 { |
|
107 __SUBCONTROLLER( "CMccDlDataPath::PrimeL" ) |
|
108 /* |
|
109 if ( iDataPathCreated && ( EStopped == State() ) ) |
|
110 { |
|
111 __SUBCONTROLLER( "CMccDlDataPath::PrimeL, priming" ) |
|
112 iDataSource->NegotiateSourceL( *iDataSink ); |
|
113 |
|
114 TBool bufferReference; |
|
115 iSourceBuffer = iDataSource->CreateSourceBufferL( iMediaId, bufferReference); |
|
116 __ASSERT_ALWAYS ( iSourceBuffer, User::Leave(KErrGeneral) ); |
|
117 __ASSERT_ALWAYS ( bufferReference, User::Leave(KErrGeneral) ); |
|
118 |
|
119 iDataSource->SourcePrimeL(); |
|
120 iDataSink->SinkPrimeL(); |
|
121 |
|
122 SetStateL( EPrimed ); |
|
123 |
|
124 CreateCompleteCallBackL(); |
|
125 } |
|
126 else if( EPrimed == State() ) |
|
127 { |
|
128 __SUBCONTROLLER( "CMccDlDataPath::PrimeL, already primed" ) |
|
129 } |
|
130 else |
|
131 { |
|
132 __SUBCONTROLLER( "CMccDlDataPath::PrimeL, KErrNotReady" ) |
|
133 User::Leave( KErrNotReady ); |
|
134 } |
|
135 */ |
|
136 __SUBCONTROLLER( "CMccDlDataPath::PrimeL, exit" ) |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CMccDlDataPath::PauseL |
|
141 // Pauses the downlink streaming |
|
142 // ----------------------------------------------------------------------------- |
|
143 void CMccDlDataPath::PauseL( TUint32 /*ndpointId*/ ) |
|
144 { |
|
145 __SUBCONTROLLER( "CMccDlDataPath::PauseL" ) |
|
146 /* |
|
147 if ( ( iDataPathCreated ) && ( EPlaying == State() ) ) |
|
148 { |
|
149 __SUBCONTROLLER( "CMccDlDataPath::PauseL, pausing" ) |
|
150 iDataSource->SourcePauseL(); |
|
151 iDataSink->SinkPauseL(); |
|
152 SetStateL( EPaused ); |
|
153 iSourceBuffer = NULL; |
|
154 Cancel(); |
|
155 } |
|
156 else if( EPrimed == State() ) |
|
157 { |
|
158 __SUBCONTROLLER( "CMccDlDataPath::PauseL, already paused" ) |
|
159 } |
|
160 else |
|
161 { |
|
162 __SUBCONTROLLER( "CMccDlDataPath::PauseL, KErrNotReady" ) |
|
163 User::Leave( KErrNotReady ); |
|
164 } |
|
165 */ |
|
166 __SUBCONTROLLER( "CMccDlDataPath::PauseL, exit" ) |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CMccDlDataPath::PlayL |
|
171 // Starts the downlink playing |
|
172 // ----------------------------------------------------------------------------- |
|
173 void CMccDlDataPath::PlayL( TUint32 /*ndpointId*/ ) |
|
174 { |
|
175 __SUBCONTROLLER( "CMccDlDataPath::PlayL" ) |
|
176 /* |
|
177 if ( iDataPathCreated && ( EPrimed == State() ) ) |
|
178 { |
|
179 __SUBCONTROLLER( "CMccDlDataPath::PlayL, playing" ) |
|
180 SetStateL( EPlaying ); |
|
181 iDataPathCompletedErrorCode = KErrNone; |
|
182 iDataSource->SourcePlayL(); |
|
183 iDataSink->SinkPlayL(); |
|
184 iSourceBuffer->SetStatus( EAvailable ); |
|
185 ChangeDataPathTransferState( ENeedSourceData ); |
|
186 } |
|
187 else if( EPlaying == State() ) |
|
188 { |
|
189 __SUBCONTROLLER( "CMccDlDataPath::PlayL, already playing" ) |
|
190 } |
|
191 else |
|
192 { |
|
193 __SUBCONTROLLER( "CMccDlDataPath::PlayL, KErrNotReady" ) |
|
194 User::Leave( KErrNotReady ); |
|
195 } |
|
196 */ |
|
197 __SUBCONTROLLER( "CMccDlDataPath::PlayL, exit" ) |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CMccDlDataPath::BufferEmptiedL |
|
202 // From MDataSource |
|
203 // ----------------------------------------------------------------------------- |
|
204 void CMccDlDataPath::BufferEmptiedL( CMMFBuffer* /*aBuffer*/ ) |
|
205 { |
|
206 /* |
|
207 // This is the buffer returned by DevSound when it has emptied it |
|
208 // Check the buffer that it is not NULL and it is supported. |
|
209 IsBufferSupportedL( aBuffer ); |
|
210 if( EPlaying == State() ) |
|
211 { |
|
212 __ASSERT_ALWAYS ( aBuffer == iSourceBuffer, User::Leave(KErrArgument) ); |
|
213 |
|
214 iSourceBuffer->SetStatus( EAvailable ); |
|
215 |
|
216 ChangeDataPathTransferState( ENeedSourceData ); |
|
217 } |
|
218 else |
|
219 { |
|
220 // We're not streaming currently, can leave |
|
221 User::Leave( KErrNotReady ); |
|
222 } |
|
223 */ |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CMccDlDataPath::BufferFilledL |
|
228 // From MDataSink |
|
229 // ----------------------------------------------------------------------------- |
|
230 void CMccDlDataPath::BufferFilledL( CMMFBuffer* /*aBuffer*/ ) |
|
231 { |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CMccDlDataPath::FillSourceBufferL |
|
236 // Fill the source buffer |
|
237 // ----------------------------------------------------------------------------- |
|
238 void CMccDlDataPath::FillSourceBufferL() |
|
239 { |
|
240 /* |
|
241 |
|
242 */ |
|
243 |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CMccDlDataPath::EmptySinkBufferL |
|
248 // Empty the sink buffer |
|
249 // ----------------------------------------------------------------------------- |
|
250 void CMccDlDataPath::EmptySinkBufferL() |
|
251 { |
|
252 /* |
|
253 ChangeDataPathTransferState( EWaitSink ); |
|
254 |
|
255 iSourceBuffer->SetStatus( EFull ); |
|
256 TRAPD( error, iDataSink->EmptyBufferL( iSourceBuffer, this, iMediaId ) ); |
|
257 |
|
258 if ( KErrEof == error || KErrOverflow == error || KErrUnderflow == error ) |
|
259 { |
|
260 iDataPathCompletedErrorCode = error; |
|
261 ChangeDataPathTransferState( EEndOfData ); |
|
262 } |
|
263 else |
|
264 { |
|
265 User::LeaveIfError( error ); |
|
266 } |
|
267 */ |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CMccDlDataPath::DoEndOfDataL |
|
272 // Worker function for data ending |
|
273 // ----------------------------------------------------------------------------- |
|
274 void CMccDlDataPath::DoEndOfDataL() |
|
275 { |
|
276 /* |
|
277 if ( KUidMmfAudioOutput != iDataSink->DataSinkType() ) |
|
278 { |
|
279 if ( KErrNone == iDataPathCompletedErrorCode ) |
|
280 { |
|
281 iDataPathCompletedErrorCode = KErrCompletion; |
|
282 } |
|
283 } |
|
284 |
|
285 SignalDataPathCompleteL(iDataPathCompletedErrorCode); |
|
286 |
|
287 SetStateL( EStopped ); |
|
288 */ |
|
289 } |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // CMccDlDataPath::Stop |
|
293 // Stop the datapath |
|
294 // ----------------------------------------------------------------------------- |
|
295 void CMccDlDataPath::StopL( TUint32 /*ndpointId*/ ) |
|
296 { |
|
297 __SUBCONTROLLER( "CMccDlDataPath::PlayL" ) |
|
298 /* |
|
299 if( ( iDataPathCreated ) && ( EStopped != State() ) ) |
|
300 { |
|
301 __SUBCONTROLLER( "CMccDlDataPath::PlayL, stopping" ) |
|
302 iDataSource->SourceStopL(); |
|
303 iDataSink->SinkStopL(); |
|
304 iDataPathCompletedErrorCode = KErrNone; |
|
305 iSourceBuffer = NULL; |
|
306 SetStateL( EStopped ); |
|
307 Cancel(); |
|
308 } |
|
309 else if( EStopped == State() ) |
|
310 { |
|
311 __SUBCONTROLLER( "CMccDlDataPath::PlayL, already stopped" ) |
|
312 } |
|
313 else |
|
314 { |
|
315 __SUBCONTROLLER( "CMccDlDataPath::PlayL, KErrNotReady" ) |
|
316 User::Leave( KErrNotReady ); |
|
317 } |
|
318 */ |
|
319 __SUBCONTROLLER( "CMccDlDataPath::PlayL, exit" ) |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CMccDlDataPath::NegotiateL |
|
324 // Negotiate the source and sink |
|
325 // ----------------------------------------------------------------------------- |
|
326 void CMccDlDataPath::NegotiateL( MDataSource& /*aDataSource*/ ) |
|
327 { |
|
328 __SUBCONTROLLER( "CMccDlDataPath::NegotiateL" ) |
|
329 /* |
|
330 if( iDataSink ) |
|
331 { |
|
332 __SUBCONTROLLER( "CMccDlDataPath::NegotiateL, negotiating" ) |
|
333 ChangeDataPathTransferState( ENegotiate ); |
|
334 iDataSource = &aDataSource; |
|
335 iDataSink->NegotiateL( *iDataSource ); |
|
336 } |
|
337 else |
|
338 { |
|
339 __SUBCONTROLLER( "CMccDlDataPath::NegotiateL, KErrNotReady" ) |
|
340 User::Leave( KErrNotReady ); |
|
341 } |
|
342 */ |
|
343 __SUBCONTROLLER( "CMccDlDataPath::NegotiateL, exit" ) |
|
344 } |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CMccDlDataPath::ResumeL |
|
348 // Resumes pause audio streaming |
|
349 // ----------------------------------------------------------------------------- |
|
350 void CMccDlDataPath::ResumeL( TUint32 /*ndpointId*/ ) |
|
351 { |
|
352 __SUBCONTROLLER( "CMccDlDataPath::ResumeL" ) |
|
353 /* |
|
354 if ( iDataPathCreated && EPaused == State() ) |
|
355 { |
|
356 __SUBCONTROLLER( "CMccDlDataPath::ResumeL, playing" ) |
|
357 SetStateL( EPlaying ); |
|
358 iDataPathCompletedErrorCode = KErrNone; |
|
359 TBool bufferReference; |
|
360 iSourceBuffer = iDataSource->CreateSourceBufferL( iMediaId, bufferReference); |
|
361 __ASSERT_ALWAYS ( iSourceBuffer, User::Leave(KErrGeneral) ); |
|
362 __ASSERT_ALWAYS ( bufferReference, User::Leave(KErrGeneral) ); |
|
363 iDataSource->SourcePlayL(); |
|
364 iDataSink->SinkPlayL(); |
|
365 iSourceBuffer->SetStatus( EAvailable ); |
|
366 ChangeDataPathTransferState( ENeedSourceData ); |
|
367 } |
|
368 else if( EPlaying == State() ) |
|
369 { |
|
370 __SUBCONTROLLER( "CMccDlDataPath::ResumeL, already playing" ) |
|
371 } |
|
372 else |
|
373 { |
|
374 __SUBCONTROLLER( "CMccDlDataPath::ResumeL, KErrNotReady" ) |
|
375 User::Leave( KErrNotReady ); |
|
376 } |
|
377 */ |
|
378 __SUBCONTROLLER( "CMccDlDataPath::ResumeL, exit" ) |
|
379 } |
|
380 |
|
381 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
382 |
|
383 // End of File |