sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "logicalaudiocodec.h"
|
sl@0
|
19 |
#include <a3f/audioprocessingunittypeuids.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
#include <ecom/implementationproxy.h> // For making it ECom plugin
|
sl@0
|
22 |
// Map the interface implementation UIDs to implementation factory functions
|
sl@0
|
23 |
const TImplementationProxy ImplementationTable[] =
|
sl@0
|
24 |
{
|
sl@0
|
25 |
IMPLEMENTATION_PROXY_ENTRY(KAudioDecoderUid, CLogicalAudioCodec::NewL),
|
sl@0
|
26 |
IMPLEMENTATION_PROXY_ENTRY(KAudioEncoderUid, CLogicalAudioCodec::NewL),
|
sl@0
|
27 |
};
|
sl@0
|
28 |
|
sl@0
|
29 |
// Exported proxy for instantiation method resolution.
|
sl@0
|
30 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
|
sl@0
|
31 |
{
|
sl@0
|
32 |
aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
|
sl@0
|
33 |
return ImplementationTable;
|
sl@0
|
34 |
}
|
sl@0
|
35 |
|
sl@0
|
36 |
// ---------------------------------------------------------------------------
|
sl@0
|
37 |
// Constructor
|
sl@0
|
38 |
// ---------------------------------------------------------------------------
|
sl@0
|
39 |
CLogicalAudioCodec* CLogicalAudioCodec::NewL(TAny* aParam)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
DP_STATIC_CONTEXT(CLogicalAudioCodec::NewL *CD0*, CtxDevSound, DPLOCAL);
|
sl@0
|
42 |
DP_IN();
|
sl@0
|
43 |
CLogicalAudioCodec* self = new(ELeave)CLogicalAudioCodec(aParam);
|
sl@0
|
44 |
CleanupStack::PushL(self);
|
sl@0
|
45 |
self->ConstructL();
|
sl@0
|
46 |
CleanupStack::Pop(self);
|
sl@0
|
47 |
DP0_RET(self, "0x%x");
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
// ---------------------------------------------------------------------------
|
sl@0
|
51 |
// Constructor
|
sl@0
|
52 |
// ---------------------------------------------------------------------------
|
sl@0
|
53 |
|
sl@0
|
54 |
CLogicalAudioCodec::CLogicalAudioCodec(TAny* aParam) : CAudioProcessingUnit(aParam)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
TRACE_CREATE();
|
sl@0
|
57 |
DP_CONTEXT(CLogicalAudioCodec::CLogicalAudioCodec *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
58 |
DP_IN();
|
sl@0
|
59 |
if(iSettingsObserver)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
iSettingsObserver->ReceiveComponentSettingsChange(iType, ERegisterCodecObserver);
|
sl@0
|
62 |
}
|
sl@0
|
63 |
DP_OUT();
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
// ---------------------------------------------------------------------------
|
sl@0
|
67 |
// Second phase constructor
|
sl@0
|
68 |
// ---------------------------------------------------------------------------
|
sl@0
|
69 |
void CLogicalAudioCodec::ConstructL()
|
sl@0
|
70 |
{
|
sl@0
|
71 |
DP_CONTEXT(CLogicalAudioCodec::ConstructL *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
72 |
DP_IN();
|
sl@0
|
73 |
DP_OUT();
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
// ---------------------------------------------------------------------------
|
sl@0
|
77 |
// Destructor
|
sl@0
|
78 |
// ---------------------------------------------------------------------------
|
sl@0
|
79 |
CLogicalAudioCodec::~CLogicalAudioCodec()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
DP_CONTEXT(CLogicalAudioCodec::~CLogicalAudioCodec *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
82 |
DP_IN();
|
sl@0
|
83 |
iAudioCodecObserver.Close();
|
sl@0
|
84 |
DP_OUT();
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
// ---------------------------------------------------------------------------
|
sl@0
|
88 |
// from class MAudioCodec
|
sl@0
|
89 |
// CLogicalAudioCodec::SetFormat
|
sl@0
|
90 |
// ---------------------------------------------------------------------------
|
sl@0
|
91 |
TInt CLogicalAudioCodec::SetFormat(TUid aFormat)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
DP_CONTEXT(CLogicalAudioCodec::SetFormat *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
94 |
DP_IN();
|
sl@0
|
95 |
iFormat = aFormat;
|
sl@0
|
96 |
if(iSettingsObserver)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
iSettingsObserver->ReceiveComponentSettingsChange(iType, EComponentAlterationCodec);
|
sl@0
|
99 |
}
|
sl@0
|
100 |
DP0_RET(KErrNone, "%d");
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
// ---------------------------------------------------------------------------
|
sl@0
|
104 |
// from class MAudioCodec
|
sl@0
|
105 |
// CLogicalAudioCodec::SetSampleRate
|
sl@0
|
106 |
// ---------------------------------------------------------------------------
|
sl@0
|
107 |
TInt CLogicalAudioCodec::SetSampleRate(TInt aSampleRate)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
DP_CONTEXT(CLogicalAudioCodec::SetSampleRate *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
110 |
DP_IN();
|
sl@0
|
111 |
iSampleRateConfig = aSampleRate;
|
sl@0
|
112 |
if(iSettingsObserver)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
iSettingsObserver->ReceiveComponentSettingsChange(iType, EComponentAlterationCodec);
|
sl@0
|
115 |
}
|
sl@0
|
116 |
DP0_RET(KErrNone, "%d");
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
// ---------------------------------------------------------------------------
|
sl@0
|
120 |
// from class MAudioCodec
|
sl@0
|
121 |
// CLogicalAudioCodec::SetMode
|
sl@0
|
122 |
// ---------------------------------------------------------------------------
|
sl@0
|
123 |
TInt CLogicalAudioCodec::SetMode(TUid aMode)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
DP_CONTEXT(CLogicalAudioCodec::SetMode *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
126 |
DP_IN();
|
sl@0
|
127 |
iModeConfig = aMode;
|
sl@0
|
128 |
if(iSettingsObserver)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
iSettingsObserver->ReceiveComponentSettingsChange(iType, EComponentAlterationCodec);
|
sl@0
|
131 |
}
|
sl@0
|
132 |
DP0_RET(KErrNone, "%d");
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
// ---------------------------------------------------------------------------
|
sl@0
|
136 |
// from class MAudioCodec
|
sl@0
|
137 |
// CLogicalAudioCodec::GetSupportedSamplesRates
|
sl@0
|
138 |
// ---------------------------------------------------------------------------
|
sl@0
|
139 |
TInt CLogicalAudioCodec::GetSupportedSamplesRates(RArray<TInt>& aSupportedRates)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
DP_CONTEXT(CLogicalAudioCodec::GetSupportedSamplesRates *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
142 |
DP_IN();
|
sl@0
|
143 |
TInt err(KErrNone);
|
sl@0
|
144 |
if(iAdaptationStream)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
err = iAdaptationStream->GetSupportedSampleRates(aSupportedRates);
|
sl@0
|
147 |
}
|
sl@0
|
148 |
else
|
sl@0
|
149 |
{
|
sl@0
|
150 |
err = KErrNotFound;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
DP0_RET(err, "%d");
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
// ---------------------------------------------------------------------------
|
sl@0
|
156 |
// from class MAudioCodec
|
sl@0
|
157 |
// CLogicalAudioCodec::GetSupportedMode
|
sl@0
|
158 |
// ---------------------------------------------------------------------------
|
sl@0
|
159 |
TInt CLogicalAudioCodec::GetSupportedModes(RArray<TUid>& aSupportedModes)
|
sl@0
|
160 |
{
|
sl@0
|
161 |
DP_CONTEXT(CLogicalAudioCodec::GetSupportedModes *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
162 |
DP_IN();
|
sl@0
|
163 |
TInt err(KErrNone);
|
sl@0
|
164 |
if(iAdaptationStream)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
err = iAdaptationStream->GetSupportedModes(aSupportedModes);
|
sl@0
|
167 |
}
|
sl@0
|
168 |
else
|
sl@0
|
169 |
{
|
sl@0
|
170 |
err = KErrNotFound;
|
sl@0
|
171 |
}
|
sl@0
|
172 |
DP0_RET(err, "%d");
|
sl@0
|
173 |
}
|
sl@0
|
174 |
// ---------------------------------------------------------------------------
|
sl@0
|
175 |
// from class MAudioProcessingUnit
|
sl@0
|
176 |
// CLogicalAudioCodec::IsTypeOf
|
sl@0
|
177 |
// ---------------------------------------------------------------------------
|
sl@0
|
178 |
TBool CLogicalAudioCodec::IsTypeOf(TUid aTypeId) const
|
sl@0
|
179 |
{
|
sl@0
|
180 |
DP_CONTEXT(CLogicalAudioCodec::IsTypeOf *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
181 |
DP_IN();
|
sl@0
|
182 |
TBool result = EFalse;
|
sl@0
|
183 |
if ( iType == aTypeId || aTypeId == KUidAudioCodec)
|
sl@0
|
184 |
{
|
sl@0
|
185 |
result = ETrue;
|
sl@0
|
186 |
}
|
sl@0
|
187 |
DP0_RET(result, "%d");
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
// ---------------------------------------------------------------------------
|
sl@0
|
191 |
// from class MAudioProcessingUnit
|
sl@0
|
192 |
// CLogicalAudioCodec::Interface
|
sl@0
|
193 |
// ---------------------------------------------------------------------------
|
sl@0
|
194 |
//
|
sl@0
|
195 |
TAny* CLogicalAudioCodec::Interface(TUid aType)
|
sl@0
|
196 |
{
|
sl@0
|
197 |
DP_CONTEXT(CLogicalAudioCodec::Interface *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
198 |
DP_IN();
|
sl@0
|
199 |
|
sl@0
|
200 |
TAny* interface = NULL;
|
sl@0
|
201 |
if (aType == KUidAudioCodec)
|
sl@0
|
202 |
{
|
sl@0
|
203 |
interface = static_cast<MAudioCodec*>(this);
|
sl@0
|
204 |
}
|
sl@0
|
205 |
else if (aType == KUidAudioCodecAdaptationObserver)
|
sl@0
|
206 |
{
|
sl@0
|
207 |
interface = static_cast<MAudioCodecAdaptationObserver*>(this);
|
sl@0
|
208 |
}
|
sl@0
|
209 |
DP0_RET(interface, "0x%08x");
|
sl@0
|
210 |
}
|
sl@0
|
211 |
|
sl@0
|
212 |
// ---------------------------------------------------------------------------
|
sl@0
|
213 |
// from class MAudioCodecAdaptationObserver
|
sl@0
|
214 |
// CLogicalAudioCodec::AllBuffersProcessed
|
sl@0
|
215 |
// ---------------------------------------------------------------------------
|
sl@0
|
216 |
void CLogicalAudioCodec::AllBuffersProcessed()
|
sl@0
|
217 |
{
|
sl@0
|
218 |
DP_CONTEXT(CLogicalAudioCodec::AllBuffersProcessed *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
219 |
DP_IN();
|
sl@0
|
220 |
DP_OUT();
|
sl@0
|
221 |
}
|
sl@0
|
222 |
|
sl@0
|
223 |
// ---------------------------------------------------------------------------
|
sl@0
|
224 |
// from class MAudioCodecAdaptationObserver
|
sl@0
|
225 |
// CLogicalAudioCodec::GetSupportedConfigurationComplete
|
sl@0
|
226 |
// ---------------------------------------------------------------------------
|
sl@0
|
227 |
void CLogicalAudioCodec::GetSupportedAModesComplete(TInt aError)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
DP_CONTEXT(CLogicalAudioCodec::GetSupportedModesComplete *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
230 |
DP_IN();
|
sl@0
|
231 |
TUint count = iAudioCodecObserver.Count();
|
sl@0
|
232 |
for ( TUint idx(0); idx < count; idx++ )
|
sl@0
|
233 |
{
|
sl@0
|
234 |
iAudioCodecObserver[idx]->GetSupportedModesComplete(aError);
|
sl@0
|
235 |
}
|
sl@0
|
236 |
DP_OUT();
|
sl@0
|
237 |
}
|
sl@0
|
238 |
|
sl@0
|
239 |
// ---------------------------------------------------------------------------
|
sl@0
|
240 |
// from class MAudioCodecAdaptationObserver
|
sl@0
|
241 |
// CLogicalAudioCodec::GetSupportedConfigurationComplete
|
sl@0
|
242 |
// ---------------------------------------------------------------------------
|
sl@0
|
243 |
void CLogicalAudioCodec::GetSupportedARatesComplete(TInt aError)
|
sl@0
|
244 |
{
|
sl@0
|
245 |
DP_CONTEXT(CLogicalAudioCodec::GetSupportedRatesComplete *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
246 |
DP_IN();
|
sl@0
|
247 |
TUint count = iAudioCodecObserver.Count();
|
sl@0
|
248 |
for ( TUint idx(0); idx < count; idx++ )
|
sl@0
|
249 |
{
|
sl@0
|
250 |
iAudioCodecObserver[idx]->GetSupportedSampleRatesComplete(aError);
|
sl@0
|
251 |
}
|
sl@0
|
252 |
DP_OUT();
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
// ---------------------------------------------------------------------------
|
sl@0
|
256 |
// from class MAudioCodecAdaptationObserver
|
sl@0
|
257 |
// CLogicalAudioCodec::ProcessingUnitError
|
sl@0
|
258 |
// ---------------------------------------------------------------------------
|
sl@0
|
259 |
void CLogicalAudioCodec::ProcessingUnitError(TInt aError)
|
sl@0
|
260 |
{
|
sl@0
|
261 |
DP_CONTEXT(CLogicalAudioCodec::ProcessingUnitError *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
262 |
DP_IN();
|
sl@0
|
263 |
|
sl@0
|
264 |
TUint count = iAudioProcessingUnitObservers.Count();
|
sl@0
|
265 |
MAudioProcessingUnit* pUnit = static_cast<MAudioProcessingUnit*>(this);
|
sl@0
|
266 |
for(TUint index=0; index < count; index++)
|
sl@0
|
267 |
{
|
sl@0
|
268 |
iAudioProcessingUnitObservers[index]->ProcessingUnitError(pUnit, aError);
|
sl@0
|
269 |
}
|
sl@0
|
270 |
DP_OUT();
|
sl@0
|
271 |
}
|
sl@0
|
272 |
|
sl@0
|
273 |
// ---------------------------------------------------------------------------
|
sl@0
|
274 |
// CLogicalAudioCodec::RegisterAudioCodecObserver
|
sl@0
|
275 |
// ---------------------------------------------------------------------------
|
sl@0
|
276 |
TInt CLogicalAudioCodec::RegisterAudioCodecObserver(MAudioCodecObserver& aObserver)
|
sl@0
|
277 |
{
|
sl@0
|
278 |
DP_CONTEXT(CLogicalAudioCodec::RegisterAudioCodecObserver *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
279 |
DP_IN();
|
sl@0
|
280 |
TInt err = iAudioCodecObserver.Find(&aObserver);
|
sl@0
|
281 |
if(err == KErrNotFound)
|
sl@0
|
282 |
{
|
sl@0
|
283 |
err = iAudioCodecObserver.Append(&aObserver);
|
sl@0
|
284 |
}
|
sl@0
|
285 |
else
|
sl@0
|
286 |
{
|
sl@0
|
287 |
err = KErrAlreadyExists;
|
sl@0
|
288 |
}
|
sl@0
|
289 |
DP0_RET(err, "%d");
|
sl@0
|
290 |
}
|
sl@0
|
291 |
|
sl@0
|
292 |
// ---------------------------------------------------------------------------
|
sl@0
|
293 |
// CLogicalAudioCodec::UnregisterAudioCodecObserver
|
sl@0
|
294 |
// ---------------------------------------------------------------------------
|
sl@0
|
295 |
void CLogicalAudioCodec::UnregisterAudioCodecObserver(MAudioCodecObserver& aObserver)
|
sl@0
|
296 |
{
|
sl@0
|
297 |
DP_CONTEXT(CLogicalAudioCodec::UnregisterAudioCodecObserver *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
298 |
DP_IN();
|
sl@0
|
299 |
TInt idxOrErr = iAudioCodecObserver.Find(&aObserver);
|
sl@0
|
300 |
if( idxOrErr != KErrNotFound )
|
sl@0
|
301 |
{
|
sl@0
|
302 |
iAudioCodecObserver.Remove(idxOrErr);
|
sl@0
|
303 |
}
|
sl@0
|
304 |
DP_OUT();
|
sl@0
|
305 |
}
|
sl@0
|
306 |
|
sl@0
|
307 |
// End of file
|