os/mm/mmhais/a3facl/src/audiocodec/logicalaudiocodec.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmhais/a3facl/src/audiocodec/logicalaudiocodec.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,307 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +
    1.21 +#include "logicalaudiocodec.h"
    1.22 +#include <a3f/audioprocessingunittypeuids.h>
    1.23 +
    1.24 +#include <ecom/implementationproxy.h> // For making it ECom plugin
    1.25 +// Map the interface implementation UIDs to implementation factory functions
    1.26 +const TImplementationProxy ImplementationTable[] =
    1.27 +	{
    1.28 +	IMPLEMENTATION_PROXY_ENTRY(KAudioDecoderUid,  CLogicalAudioCodec::NewL),
    1.29 +	IMPLEMENTATION_PROXY_ENTRY(KAudioEncoderUid,  CLogicalAudioCodec::NewL),
    1.30 +	};
    1.31 +
    1.32 +// Exported proxy for instantiation method resolution.
    1.33 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
    1.34 +	{
    1.35 +	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
    1.36 +	return ImplementationTable;
    1.37 +	}
    1.38 +
    1.39 +// ---------------------------------------------------------------------------
    1.40 +// Constructor
    1.41 +// ---------------------------------------------------------------------------
    1.42 +CLogicalAudioCodec* CLogicalAudioCodec::NewL(TAny* aParam)
    1.43 +	{
    1.44 +	DP_STATIC_CONTEXT(CLogicalAudioCodec::NewL *CD0*, CtxDevSound, DPLOCAL);
    1.45 +	DP_IN();
    1.46 +	CLogicalAudioCodec* self = new(ELeave)CLogicalAudioCodec(aParam);
    1.47 +	CleanupStack::PushL(self);
    1.48 +	self->ConstructL();
    1.49 +	CleanupStack::Pop(self);
    1.50 +	DP0_RET(self, "0x%x");
    1.51 +	}
    1.52 +
    1.53 +// ---------------------------------------------------------------------------
    1.54 +// Constructor
    1.55 +// ---------------------------------------------------------------------------
    1.56 +
    1.57 +CLogicalAudioCodec::CLogicalAudioCodec(TAny* aParam) : CAudioProcessingUnit(aParam)
    1.58 +	{
    1.59 +	TRACE_CREATE();
    1.60 +	DP_CONTEXT(CLogicalAudioCodec::CLogicalAudioCodec *CD1*, CtxDevSound, DPLOCAL);
    1.61 +	DP_IN();
    1.62 +	if(iSettingsObserver)
    1.63 +		{
    1.64 +		iSettingsObserver->ReceiveComponentSettingsChange(iType, ERegisterCodecObserver);
    1.65 +		}
    1.66 +	DP_OUT();
    1.67 +	}
    1.68 +
    1.69 +// ---------------------------------------------------------------------------
    1.70 +// Second phase constructor
    1.71 +// ---------------------------------------------------------------------------
    1.72 +void CLogicalAudioCodec::ConstructL()
    1.73 +	{
    1.74 +	DP_CONTEXT(CLogicalAudioCodec::ConstructL *CD1*, CtxDevSound, DPLOCAL);
    1.75 +	DP_IN();
    1.76 +	DP_OUT();
    1.77 +	}
    1.78 +
    1.79 +// ---------------------------------------------------------------------------
    1.80 +// Destructor
    1.81 +// ---------------------------------------------------------------------------
    1.82 +CLogicalAudioCodec::~CLogicalAudioCodec()
    1.83 +	{
    1.84 +	DP_CONTEXT(CLogicalAudioCodec::~CLogicalAudioCodec *CD1*, CtxDevSound, DPLOCAL);
    1.85 +	DP_IN();
    1.86 +	iAudioCodecObserver.Close();
    1.87 +	DP_OUT();
    1.88 +	}
    1.89 +
    1.90 +// ---------------------------------------------------------------------------
    1.91 +// from class MAudioCodec
    1.92 +// CLogicalAudioCodec::SetFormat
    1.93 +// ---------------------------------------------------------------------------
    1.94 +TInt CLogicalAudioCodec::SetFormat(TUid aFormat)
    1.95 +	{
    1.96 +	DP_CONTEXT(CLogicalAudioCodec::SetFormat *CD1*, CtxDevSound, DPLOCAL);
    1.97 +	DP_IN();
    1.98 +	iFormat = aFormat;
    1.99 +	if(iSettingsObserver)
   1.100 +		{
   1.101 +		iSettingsObserver->ReceiveComponentSettingsChange(iType, EComponentAlterationCodec);
   1.102 +		}
   1.103 +	DP0_RET(KErrNone, "%d");
   1.104 +	}
   1.105 +
   1.106 +// ---------------------------------------------------------------------------
   1.107 +// from class MAudioCodec
   1.108 +// CLogicalAudioCodec::SetSampleRate
   1.109 +// ---------------------------------------------------------------------------
   1.110 +TInt CLogicalAudioCodec::SetSampleRate(TInt aSampleRate)
   1.111 +	{
   1.112 +	DP_CONTEXT(CLogicalAudioCodec::SetSampleRate *CD1*, CtxDevSound, DPLOCAL);
   1.113 +	DP_IN();
   1.114 +	iSampleRateConfig = aSampleRate;
   1.115 +	if(iSettingsObserver)
   1.116 +		{
   1.117 +		iSettingsObserver->ReceiveComponentSettingsChange(iType, EComponentAlterationCodec);
   1.118 +		}
   1.119 +	DP0_RET(KErrNone, "%d");
   1.120 +	}
   1.121 +
   1.122 +// ---------------------------------------------------------------------------
   1.123 +// from class MAudioCodec
   1.124 +// CLogicalAudioCodec::SetMode
   1.125 +// ---------------------------------------------------------------------------
   1.126 +TInt CLogicalAudioCodec::SetMode(TUid aMode)
   1.127 +	{
   1.128 +	DP_CONTEXT(CLogicalAudioCodec::SetMode *CD1*, CtxDevSound, DPLOCAL);
   1.129 +	DP_IN();
   1.130 +	iModeConfig = aMode;
   1.131 +	if(iSettingsObserver)
   1.132 +		{
   1.133 +		iSettingsObserver->ReceiveComponentSettingsChange(iType, EComponentAlterationCodec);
   1.134 +		}
   1.135 +	DP0_RET(KErrNone, "%d");
   1.136 +	}
   1.137 +
   1.138 +// ---------------------------------------------------------------------------
   1.139 +// from class MAudioCodec
   1.140 +// CLogicalAudioCodec::GetSupportedSamplesRates
   1.141 +// ---------------------------------------------------------------------------
   1.142 +TInt CLogicalAudioCodec::GetSupportedSamplesRates(RArray<TInt>& aSupportedRates)
   1.143 +	{
   1.144 +	DP_CONTEXT(CLogicalAudioCodec::GetSupportedSamplesRates *CD1*, CtxDevSound, DPLOCAL);
   1.145 +	DP_IN();
   1.146 +	TInt err(KErrNone);
   1.147 +	if(iAdaptationStream)
   1.148 +		{
   1.149 +		err = iAdaptationStream->GetSupportedSampleRates(aSupportedRates);
   1.150 +		}
   1.151 +	else
   1.152 +		{
   1.153 +		err = KErrNotFound;
   1.154 +		}
   1.155 +	DP0_RET(err, "%d");
   1.156 +	}
   1.157 +
   1.158 +// ---------------------------------------------------------------------------
   1.159 +// from class MAudioCodec
   1.160 +// CLogicalAudioCodec::GetSupportedMode
   1.161 +// ---------------------------------------------------------------------------
   1.162 +TInt CLogicalAudioCodec::GetSupportedModes(RArray<TUid>& aSupportedModes)
   1.163 +	{
   1.164 +	DP_CONTEXT(CLogicalAudioCodec::GetSupportedModes *CD1*, CtxDevSound, DPLOCAL);
   1.165 +	DP_IN();
   1.166 +	TInt err(KErrNone);
   1.167 +	if(iAdaptationStream)
   1.168 +		{
   1.169 +		err = iAdaptationStream->GetSupportedModes(aSupportedModes);
   1.170 +		}
   1.171 +	else
   1.172 +		{
   1.173 +		err = KErrNotFound;
   1.174 +		}
   1.175 +	DP0_RET(err, "%d");
   1.176 +	}
   1.177 +// ---------------------------------------------------------------------------
   1.178 +// from class MAudioProcessingUnit
   1.179 +// CLogicalAudioCodec::IsTypeOf
   1.180 +// ---------------------------------------------------------------------------
   1.181 +TBool CLogicalAudioCodec::IsTypeOf(TUid aTypeId) const
   1.182 +	{
   1.183 +	DP_CONTEXT(CLogicalAudioCodec::IsTypeOf *CD1*, CtxDevSound, DPLOCAL);
   1.184 +	DP_IN();
   1.185 +	TBool result = EFalse;
   1.186 +	if ( iType == aTypeId || aTypeId == KUidAudioCodec)
   1.187 +		{
   1.188 +		result = ETrue;
   1.189 +		}
   1.190 +	DP0_RET(result, "%d");
   1.191 +	}
   1.192 +
   1.193 +// ---------------------------------------------------------------------------
   1.194 +// from class MAudioProcessingUnit
   1.195 +// CLogicalAudioCodec::Interface
   1.196 +// ---------------------------------------------------------------------------
   1.197 +//
   1.198 +TAny* CLogicalAudioCodec::Interface(TUid aType)
   1.199 +	{
   1.200 +	DP_CONTEXT(CLogicalAudioCodec::Interface *CD1*, CtxDevSound, DPLOCAL);
   1.201 +	DP_IN();
   1.202 +	
   1.203 +	TAny* interface = NULL;
   1.204 +	if (aType == KUidAudioCodec)
   1.205 +		{
   1.206 +		interface = static_cast<MAudioCodec*>(this);
   1.207 +		}
   1.208 +	else if (aType == KUidAudioCodecAdaptationObserver)
   1.209 +		{
   1.210 +		interface = static_cast<MAudioCodecAdaptationObserver*>(this);
   1.211 +		}
   1.212 +	DP0_RET(interface, "0x%08x");
   1.213 +	}
   1.214 +
   1.215 +// ---------------------------------------------------------------------------
   1.216 +// from class MAudioCodecAdaptationObserver
   1.217 +// CLogicalAudioCodec::AllBuffersProcessed
   1.218 +// ---------------------------------------------------------------------------
   1.219 +void CLogicalAudioCodec::AllBuffersProcessed()
   1.220 +	{
   1.221 +	DP_CONTEXT(CLogicalAudioCodec::AllBuffersProcessed *CD1*, CtxDevSound, DPLOCAL);
   1.222 +	DP_IN();
   1.223 +	DP_OUT();
   1.224 +	}
   1.225 +
   1.226 +// ---------------------------------------------------------------------------
   1.227 +// from class MAudioCodecAdaptationObserver
   1.228 +// CLogicalAudioCodec::GetSupportedConfigurationComplete
   1.229 +// ---------------------------------------------------------------------------
   1.230 +void CLogicalAudioCodec::GetSupportedAModesComplete(TInt aError)
   1.231 +	{
   1.232 +	DP_CONTEXT(CLogicalAudioCodec::GetSupportedModesComplete *CD1*, CtxDevSound, DPLOCAL);
   1.233 +	DP_IN();
   1.234 +	TUint count = iAudioCodecObserver.Count();
   1.235 +	for ( TUint idx(0); idx < count; idx++ )
   1.236 +		{
   1.237 +		iAudioCodecObserver[idx]->GetSupportedModesComplete(aError);
   1.238 +		}
   1.239 +	DP_OUT();
   1.240 +	}
   1.241 +	
   1.242 +// ---------------------------------------------------------------------------
   1.243 +// from class MAudioCodecAdaptationObserver
   1.244 +// CLogicalAudioCodec::GetSupportedConfigurationComplete
   1.245 +// ---------------------------------------------------------------------------
   1.246 +void CLogicalAudioCodec::GetSupportedARatesComplete(TInt aError)
   1.247 +	{
   1.248 +	DP_CONTEXT(CLogicalAudioCodec::GetSupportedRatesComplete *CD1*, CtxDevSound, DPLOCAL);
   1.249 +	DP_IN();
   1.250 +	TUint count = iAudioCodecObserver.Count();
   1.251 +	for ( TUint idx(0); idx < count; idx++ )
   1.252 +		{
   1.253 +		iAudioCodecObserver[idx]->GetSupportedSampleRatesComplete(aError);
   1.254 +		}
   1.255 +	DP_OUT();
   1.256 +	}
   1.257 +
   1.258 +// ---------------------------------------------------------------------------
   1.259 +// from class MAudioCodecAdaptationObserver
   1.260 +// CLogicalAudioCodec::ProcessingUnitError
   1.261 +// ---------------------------------------------------------------------------
   1.262 +void CLogicalAudioCodec::ProcessingUnitError(TInt aError)
   1.263 +	{
   1.264 +	DP_CONTEXT(CLogicalAudioCodec::ProcessingUnitError *CD1*, CtxDevSound, DPLOCAL);
   1.265 +	DP_IN();
   1.266 +
   1.267 +	TUint count = iAudioProcessingUnitObservers.Count();
   1.268 +	MAudioProcessingUnit* pUnit = static_cast<MAudioProcessingUnit*>(this);
   1.269 +	for(TUint index=0; index < count; index++)
   1.270 +		{
   1.271 +		iAudioProcessingUnitObservers[index]->ProcessingUnitError(pUnit, aError);
   1.272 +		}
   1.273 +	DP_OUT();
   1.274 +	}
   1.275 +
   1.276 +// ---------------------------------------------------------------------------
   1.277 +// CLogicalAudioCodec::RegisterAudioCodecObserver
   1.278 +// ---------------------------------------------------------------------------
   1.279 +TInt CLogicalAudioCodec::RegisterAudioCodecObserver(MAudioCodecObserver& aObserver)
   1.280 +	{
   1.281 +	DP_CONTEXT(CLogicalAudioCodec::RegisterAudioCodecObserver *CD1*, CtxDevSound, DPLOCAL);
   1.282 +	DP_IN();
   1.283 +	TInt err = iAudioCodecObserver.Find(&aObserver);
   1.284 +	if(err == KErrNotFound)
   1.285 +		{
   1.286 +		err = iAudioCodecObserver.Append(&aObserver);
   1.287 +		}
   1.288 +	else
   1.289 +		{
   1.290 +		err = KErrAlreadyExists;
   1.291 +		}
   1.292 +	DP0_RET(err, "%d");
   1.293 +	}
   1.294 +
   1.295 +// ---------------------------------------------------------------------------
   1.296 +// CLogicalAudioCodec::UnregisterAudioCodecObserver
   1.297 +// ---------------------------------------------------------------------------
   1.298 +void CLogicalAudioCodec::UnregisterAudioCodecObserver(MAudioCodecObserver& aObserver)
   1.299 +	{
   1.300 +	DP_CONTEXT(CLogicalAudioCodec::UnregisterAudioCodecObserver *CD1*, CtxDevSound, DPLOCAL);
   1.301 +	DP_IN();
   1.302 +	TInt idxOrErr = iAudioCodecObserver.Find(&aObserver);
   1.303 +	if( idxOrErr != KErrNotFound )
   1.304 +		{
   1.305 +		iAudioCodecObserver.Remove(idxOrErr);
   1.306 +		}
   1.307 +	DP_OUT();
   1.308 +	}
   1.309 +
   1.310 +// End of file