|
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: Implementation of the audio buffer write request active object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #ifdef _DEBUG |
|
22 #include <e32svr.h> |
|
23 #endif |
|
24 |
|
25 #include "S60StreamingSourceCustomCommands.h" |
|
26 #include "WriteRequest.h" |
|
27 #include "S60SourceEventDispatcher.h" |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CWriteRequest::CWriteRequest |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CWriteRequest::CWriteRequest( |
|
39 TMMFMessageDestinationPckg aMessageHandler, |
|
40 RMMFController& aController, |
|
41 CS60SourceEventDispatcher& aCallback ) |
|
42 : CActive(CActive::EPriorityStandard), |
|
43 iController(aController), |
|
44 iMessageHandler(aMessageHandler), |
|
45 iCallback(aCallback), |
|
46 iClientBuffer(NULL), |
|
47 iProcessed(EFalse), |
|
48 iFree(ETrue) |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CWriteRequest::ConstructL |
|
54 // Symbian 2nd phase constructor can leave. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CWriteRequest::ConstructL() |
|
58 { |
|
59 CActiveScheduler::Add(this); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CWriteRequest::NewL |
|
64 // Two-phased constructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CWriteRequest* CWriteRequest::NewL( |
|
68 TMMFMessageDestinationPckg aMessageHandler, |
|
69 RMMFController& aController, |
|
70 CS60SourceEventDispatcher& aCallback ) |
|
71 { |
|
72 CWriteRequest* self = new(ELeave) CWriteRequest(aMessageHandler, aController, aCallback); |
|
73 CleanupStack::PushL(self); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop(self); |
|
76 return self; |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CWriteRequest::~CWriteRequest |
|
82 // Destructor |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CWriteRequest::~CWriteRequest() |
|
86 { |
|
87 #ifdef _DEBUG |
|
88 RDebug::Print(_L("CWriteRequest::~CWriteRequest()\n")); |
|
89 #endif |
|
90 Cancel(); |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CWriteRequest::WriteAudioData |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CWriteRequest::WriteAudioData(CClientAudioBuffer& aBuffer) |
|
98 { |
|
99 if( !IsActive() ) |
|
100 { |
|
101 if( aBuffer.IsLastBuffer() ) |
|
102 iLastBufferPckg() = 1; |
|
103 else |
|
104 iLastBufferPckg() = 0; |
|
105 |
|
106 iClientBuffer = &aBuffer; |
|
107 iController.CustomCommandAsync(iMessageHandler, (TInt)EProcessBuffer, iClientBuffer->GetBufferPtr(), iLastBufferPckg, iStatus); |
|
108 iProcessed = EFalse; |
|
109 iFree = EFalse; |
|
110 SetActive(); |
|
111 } |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CWriteRequest::IsFree |
|
116 // Destructor |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 TBool CWriteRequest::IsFree() |
|
120 { |
|
121 return iFree; |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CWriteRequest::RunL |
|
126 // Invoke by the active scheduler when a request completes -- the buffer has been |
|
127 // processed. |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CWriteRequest::RunL() |
|
131 { |
|
132 #ifdef _DEBUG |
|
133 RDebug::Print(_L("CWriteRequest::RunL()\n")); |
|
134 #endif |
|
135 |
|
136 if( iStatus == KErrNone ) |
|
137 { |
|
138 iCallback.BufferProcessed(*iClientBuffer, KErrNone); |
|
139 iClientBuffer = NULL; |
|
140 iFree = ETrue; |
|
141 } |
|
142 if( iStatus == KErrCancel ) |
|
143 { |
|
144 iCallback.BufferProcessed(*iClientBuffer, KErrCancel); |
|
145 iClientBuffer = NULL; |
|
146 iFree = ETrue; |
|
147 } |
|
148 |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CWriteRequest::DoCancel |
|
153 // Cancels the current and any on going requests/tasks. |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CWriteRequest::DoCancel() |
|
157 { |
|
158 #ifdef _DEBUG |
|
159 RDebug::Print(_L("CWriteRequest::DoCancel()\n")); |
|
160 #endif |
|
161 TRequestStatus* s = &iStatus; |
|
162 |
|
163 User::RequestComplete(s, KErrCancel); |
|
164 } |
|
165 |
|
166 // End of file |
|
167 |