|
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: Base class definition of the S60 Audio Stream Player aysnc callback |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32svr.h> |
|
19 #include "S60SourceEventDispatcher.h" |
|
20 |
|
21 |
|
22 CS60SourceEventDispatcher* CS60SourceEventDispatcher::NewL(MS60AudioStreamSourceObserver& aObserver) |
|
23 { |
|
24 return new(ELeave) CS60SourceEventDispatcher(aObserver); |
|
25 } |
|
26 |
|
27 CS60SourceEventDispatcher::CS60SourceEventDispatcher(MS60AudioStreamSourceObserver& aObserver) : |
|
28 CActive(CActive::EPriorityHigh), |
|
29 iObserver(aObserver) |
|
30 { |
|
31 CActiveScheduler::Add(this); |
|
32 } |
|
33 |
|
34 CS60SourceEventDispatcher::~CS60SourceEventDispatcher() |
|
35 { |
|
36 #ifdef _DEBUG |
|
37 RDebug::Print(_L("CS60SourceEventDispatcher::~CS60SourceEventDispatcher")); |
|
38 #endif |
|
39 Cancel(); |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CPlayerEventDispatcher::SeekSupportChanged |
|
44 // Seek Support changed Callback from the Source |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 void CS60SourceEventDispatcher::SeekSupportChanged() |
|
48 { |
|
49 iSourceEvent = ESeekSupportChanged; |
|
50 if (!IsActive()) |
|
51 { |
|
52 TRequestStatus* s = &iStatus; |
|
53 SetActive(); |
|
54 User::RequestComplete(s, KErrNone); |
|
55 } |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CPlayerEventDispatcher::BufferProcessed |
|
60 // BufferProcessed Callback from the Source |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CS60SourceEventDispatcher::BufferProcessed(CClientAudioBuffer& aBuffer, TInt aBufferStatus) |
|
64 { |
|
65 iSourceEvent = EBufferProcessed; |
|
66 iBuffer = &aBuffer; |
|
67 iBufferStatus = aBufferStatus; |
|
68 if (!IsActive()) |
|
69 { |
|
70 TRequestStatus* s = &iStatus; |
|
71 SetActive(); |
|
72 User::RequestComplete(s, KErrNone); |
|
73 } |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CPlayerEventDispatcher::RunL |
|
78 // BufferProcessed Callback from the Source |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CS60SourceEventDispatcher::RunL() |
|
82 { |
|
83 switch (iSourceEvent) |
|
84 { |
|
85 case ESeekSupportChanged: |
|
86 iObserver.SeekSupportChanged(); |
|
87 break; |
|
88 case EBufferProcessed: |
|
89 iObserver.BufferProcessed(*iBuffer, iBufferStatus); |
|
90 break; |
|
91 |
|
92 } |
|
93 } |
|
94 |
|
95 void CS60SourceEventDispatcher::DoCancel() |
|
96 { |
|
97 // Nothing to cancel |
|
98 } |