1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmhais/a3facl/src/audiostream/logicalaudiostream.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1327 @@
1.4 +// Copyright (c) 2004-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 "logicalaudiogaincontrol.h"
1.22 +#include "logicalaudiocodec.h"
1.23 +#include "logicalbuffersource.h"
1.24 +#include "logicalbuffersink.h"
1.25 +#include "logicalaudiodevicesink.h"
1.26 +#include "logicalaudiodevicesource.h"
1.27 +#include "logicalaudiostream.h"
1.28 +
1.29 +#include <mmf/server/sounddevice.h>
1.30 +#include <a3f/audioprocessingunittypeuids.h>
1.31 +#include <a3f/maudiocodec.h>
1.32 +#include <a3f/maudiocontext.h>
1.33 +#include "audiocontext.h"
1.34 +
1.35 +// TODO: Remove when the MMRC Extension mechanism is ready
1.36 +#include "mstreampositioncontrol.h"
1.37 +#include "mstreampositioncontrol.h"
1.38 +#include "audioprocessingunit.h"
1.39 +
1.40 +#include <ecom/implementationproxy.h> // For making it ECom plugin
1.41 +
1.42 +
1.43 +// Exported proxy for instantiation method resolution
1.44 +// Define the interface UIDs
1.45 +const TImplementationProxy ImplementationTable[] =
1.46 + {
1.47 + IMPLEMENTATION_PROXY_ENTRY(KAudioStreamUid, CLogicalAudioStream::NewL)
1.48 + };
1.49 +
1.50 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
1.51 + {
1.52 + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
1.53 + return ImplementationTable;
1.54 + }
1.55 +
1.56 +// ---------------------------------------------------------------------------
1.57 +// Constructor
1.58 +// ---------------------------------------------------------------------------
1.59 +//
1.60 +CLogicalAudioStream::CLogicalAudioStream()
1.61 + : CAudioStreamManager(),
1.62 + iCurrentState(EUninitialized),
1.63 + iMessageType(ERegisterStreamObserver)
1.64 + {
1.65 + TRACE_CREATE();
1.66 + DP_CONTEXT(CLogicalAudioStream::CLogicalAudioStream *CD1*, CtxDevSound, DPLOCAL);
1.67 + DP_IN();
1.68 + DP_OUT();
1.69 + }
1.70 +
1.71 +// ---------------------------------------------------------------------------
1.72 +// CLogicalAudioStream::NewL
1.73 +// ---------------------------------------------------------------------------
1.74 +CLogicalAudioStream* CLogicalAudioStream::NewL(TUid /*aTypeId*/)
1.75 + {
1.76 + DP_STATIC_CONTEXT(CLogicalAudioStream::NewL *CD0*, CtxDevSound, DPLOCAL);
1.77 + DP_IN();
1.78 + CLogicalAudioStream* self = new(ELeave)CLogicalAudioStream();
1.79 + CleanupStack::PushL(self);
1.80 + self->ConstructL();
1.81 + CleanupStack::Pop(self);
1.82 + DP0_RET(self, "0x%x");
1.83 + }
1.84 +
1.85 +// ---------------------------------------------------------------------------
1.86 +// Second phase constructor
1.87 +// ---------------------------------------------------------------------------
1.88 +void CLogicalAudioStream::ConstructL()
1.89 + {
1.90 + DP_CONTEXT(CLogicalAudioStream::ConstructL *CD1*, CtxDevSound, DPLOCAL);
1.91 + DP_IN();
1.92 + DP_OUT();
1.93 + }
1.94 +
1.95 +// ---------------------------------------------------------------------------
1.96 +// Destructor
1.97 +// ---------------------------------------------------------------------------
1.98 +//
1.99 + CLogicalAudioStream::~CLogicalAudioStream()
1.100 + {
1.101 + DP_CONTEXT(CLogicalAudioStream::~CLogicalAudioStream *CD1*, CtxDevSound, DPLOCAL);
1.102 + DP_IN();
1.103 + iAudioProcessingUnits.Close();
1.104 + iCISupportObservers.Close();
1.105 + DP_OUT();
1.106 + }
1.107 +
1.108 +
1.109 +// From MAudioStream
1.110 +// ---------------------------------------------------------------------------
1.111 +// CLogicalAudioStream::Uninitialize
1.112 +// ---------------------------------------------------------------------------
1.113 +TInt CLogicalAudioStream::Uninitialize()
1.114 + {
1.115 + DP_CONTEXT(CLogicalAudioStream::Uninitialize *CD1*, CtxDevSound, DPLOCAL);
1.116 + DP_IN();
1.117 + if (iCurrentState != EInitialized)
1.118 + {
1.119 + DP0_RET(KErrNotReady, "%d");
1.120 + }
1.121 +
1.122 + iCurrentState = EUninitialized;
1.123 + DP0_RET(KErrNone, "%d");
1.124 + }
1.125 +
1.126 +// ---------------------------------------------------------------------------
1.127 +// CLogicalAudioStream::Initialize
1.128 +// ---------------------------------------------------------------------------
1.129 +TInt CLogicalAudioStream::Initialize()
1.130 + {
1.131 + DP_CONTEXT(CLogicalAudioStream::Initialize *CD1*, CtxDevSound, DPLOCAL);
1.132 + DP_IN();
1.133 + if (iCurrentState != EUninitialized)
1.134 + {
1.135 + DP0_RET(KErrNotReady, "%d");
1.136 + }
1.137 +
1.138 + //calling commit??
1.139 + iCurrentState = EInitialized;
1.140 + DP0_RET(KErrNone, "%d");
1.141 + }
1.142 +
1.143 +// ---------------------------------------------------------------------------
1.144 +// CLogicalAudioStream::Load
1.145 +// ---------------------------------------------------------------------------
1.146 +TInt CLogicalAudioStream::Load()
1.147 + {
1.148 + DP_CONTEXT(CLogicalAudioStream::Load *CD1*, CtxDevSound, DPLOCAL);
1.149 + DP_IN();
1.150 + if (iCurrentState != EInitialized)
1.151 + {
1.152 + DP0_RET(KErrNotReady, "%d");
1.153 + }
1.154 +
1.155 + iCurrentState = EIdle;
1.156 + ResetStreamTime();
1.157 + DP0_RET(KErrNone, "%d");
1.158 + }
1.159 +
1.160 +// ---------------------------------------------------------------------------
1.161 +// CLogicalAudioStream::Stop
1.162 +// ---------------------------------------------------------------------------
1.163 +TInt CLogicalAudioStream::Stop()
1.164 + {
1.165 + DP_CONTEXT(CLogicalAudioStream::Stop *CD1*, CtxDevSound, DPLOCAL);
1.166 + DP_IN();
1.167 + if (iCurrentState != EActive && iCurrentState != EPrimed)
1.168 + {
1.169 + DP0_RET(KErrNotReady, "%d");
1.170 + }
1.171 + iCurrentState = EIdle;
1.172 + DP0_RET(KErrNone, "%d");
1.173 + }
1.174 +
1.175 +// ---------------------------------------------------------------------------
1.176 +// CLogicalAudioStream::Unload
1.177 +// ---------------------------------------------------------------------------
1.178 +TInt CLogicalAudioStream::Unload()
1.179 + {
1.180 + DP_CONTEXT(CLogicalAudioStream::Unload *CD1*, CtxDevSound, DPLOCAL);
1.181 + DP_IN();
1.182 + if (iCurrentState != EIdle)
1.183 + {
1.184 + DP0_RET(KErrNotReady, "%d");
1.185 + }
1.186 +
1.187 + iCurrentState = EInitialized;
1.188 + DP0_RET(KErrNone, "%d");
1.189 + }
1.190 +
1.191 +// ---------------------------------------------------------------------------
1.192 +// CLogicalAudioStream::Prime
1.193 +// ---------------------------------------------------------------------------
1.194 +TInt CLogicalAudioStream::Prime()
1.195 + {
1.196 + DP_CONTEXT(CLogicalAudioStream::Prime *CD1*, CtxDevSound, DPLOCAL);
1.197 + DP_IN();
1.198 + if (iCurrentState != EActive && iCurrentState != EIdle)
1.199 + {
1.200 + DP0_RET(KErrNotReady, "%d");
1.201 + }
1.202 +
1.203 + iCurrentState = EPrimed;
1.204 + DP0_RET(KErrNone, "%d");
1.205 + }
1.206 +
1.207 +// ---------------------------------------------------------------------------
1.208 +// CLogicalAudioStream::Flush
1.209 +// ---------------------------------------------------------------------------
1.210 +TInt CLogicalAudioStream::Flush()
1.211 + {
1.212 + DP_CONTEXT(CLogicalAudioStream::Flush *CD1*, CtxDevSound, DPLOCAL);
1.213 + DP_IN();
1.214 + if (iCurrentState != EIdle && iCurrentState != EPrimed)
1.215 + {
1.216 + DP0_RET(KErrNotReady, "%d");
1.217 + }
1.218 +
1.219 + if(!iStreamBufferControl)
1.220 + {
1.221 + DP0_RET(KErrNotReady, "%d");
1.222 + }
1.223 + //Empty any buffers that have been filled
1.224 + iStreamBufferControl->FlushBuffers();
1.225 +
1.226 + DP0_RET(KErrNone, "%d");
1.227 + }
1.228 +
1.229 +// ---------------------------------------------------------------------------
1.230 +// CLogicalAudioStream::Activate
1.231 +// ---------------------------------------------------------------------------
1.232 +TInt CLogicalAudioStream::Activate()
1.233 + {
1.234 + DP_CONTEXT(CLogicalAudioStream::Activate *CD1*, CtxDevSound, DPLOCAL);
1.235 + DP_IN();
1.236 + if (iCurrentState != EIdle && iCurrentState != EPrimed)
1.237 + {
1.238 + DP0_RET(KErrNotReady, "%d");
1.239 + }
1.240 +
1.241 + //The start-up procedures include requesting permission for audio processing
1.242 + //from audio policy. If permission to start is denied by audio policy, a state
1.243 + //change callback to the current state will occur.
1.244 + iCurrentState = EActive;
1.245 + DP0_RET(KErrNone, "%d");
1.246 + }
1.247 +
1.248 +// ---------------------------------------------------------------------------
1.249 +// CLogicalAudioStream::AddSource
1.250 +// ---------------------------------------------------------------------------
1.251 +TInt CLogicalAudioStream::AddSource(MAudioProcessingUnit* aSource)
1.252 + {
1.253 + DP_CONTEXT(CLogicalAudioStream::AddSource *CD1*, CtxDevSound, DPLOCAL);
1.254 + DP_IN();
1.255 + TInt err;
1.256 + if (aSource->IsTypeOf(KUidMmfBufferSource) || aSource->IsTypeOf(KUidAudioDeviceSource))
1.257 + {
1.258 + if (iCurrentState == EUninitialized)
1.259 + {
1.260 + err = DoAddProcessingUnit(aSource);
1.261 + }
1.262 + else
1.263 + {
1.264 + err = KErrNotReady;
1.265 + }
1.266 + }
1.267 + else
1.268 + {
1.269 + err = KErrNotSupported;
1.270 + }
1.271 + DP0_RET(err, "%d");
1.272 + }
1.273 +
1.274 +
1.275 +// ---------------------------------------------------------------------------
1.276 +// CLogicalAudioStream::AddSink
1.277 +// ---------------------------------------------------------------------------
1.278 +TInt CLogicalAudioStream::AddSink(MAudioProcessingUnit* aSink)
1.279 + {
1.280 + DP_CONTEXT(CLogicalAudioStream::AddSink *CD1*, CtxDevSound, DPLOCAL);
1.281 + DP_IN();
1.282 + TInt err;
1.283 + if (aSink->IsTypeOf(KUidMmfBufferSink) || aSink->IsTypeOf(KUidAudioDeviceSink) )
1.284 + {
1.285 + if (iCurrentState == EUninitialized)
1.286 + {
1.287 + err = DoAddProcessingUnit(aSink);
1.288 + }
1.289 + else
1.290 + {
1.291 + err = KErrNotReady;
1.292 + }
1.293 + }
1.294 + else
1.295 + {
1.296 + err = KErrNotSupported;
1.297 + }
1.298 + DP0_RET(err, "%d");
1.299 + }
1.300 +
1.301 +// ---------------------------------------------------------------------------
1.302 +// CLogicalAudioStream::AddCodec
1.303 +// ---------------------------------------------------------------------------
1.304 +TInt CLogicalAudioStream::AddAudioCodec(MAudioProcessingUnit* aCodec)
1.305 + {
1.306 + DP_CONTEXT(CLogicalAudioStream::AddAudioCodec *CD1*, CtxDevSound, DPLOCAL);
1.307 + DP_IN();
1.308 + TInt err;
1.309 + if (iCodec != NULL)
1.310 + {
1.311 + DP0_RET(KErrInUse, "%d");
1.312 + }
1.313 +
1.314 + if (aCodec->IsTypeOf(KUidAudioCodec))
1.315 + {
1.316 + if (iCurrentState == EUninitialized)
1.317 + {
1.318 + err = DoAddProcessingUnit(aCodec);
1.319 + }
1.320 + else
1.321 + {
1.322 + err = KErrNotReady;
1.323 + }
1.324 + }
1.325 + else
1.326 + {
1.327 + err = KErrNotSupported;
1.328 + }
1.329 + DP0_RET(err, "%d");
1.330 + }
1.331 +
1.332 +// ---------------------------------------------------------------------------
1.333 +// CLogicalAudioStream::AddGainControl
1.334 +// ---------------------------------------------------------------------------
1.335 +TInt CLogicalAudioStream::AddGainControl(MAudioProcessingUnit* aGainControl)
1.336 + {
1.337 + DP_CONTEXT(CLogicalAudioStream::AddGainControl *CD1*, CtxDevSound, DPLOCAL);
1.338 + DP_IN();
1.339 + TInt err(KErrNone);
1.340 +
1.341 + if (iGain != NULL)
1.342 + {
1.343 + DP0_RET(KErrInUse, "%d");
1.344 + }
1.345 +
1.346 + if (aGainControl->IsTypeOf(KUidAudioGainControl))
1.347 + {
1.348 + if (iCurrentState == EUninitialized)
1.349 + {
1.350 + err = DoAddProcessingUnit(aGainControl);
1.351 + }
1.352 + else
1.353 + {
1.354 + err = KErrNotReady;
1.355 + }
1.356 + }
1.357 + else
1.358 + {
1.359 + err = KErrNotSupported;
1.360 + }
1.361 + DP0_RET(err, "%d");
1.362 + }
1.363 +
1.364 +// ---------------------------------------------------------------------------
1.365 +// CLogicalAudioStream::RemoveProcessigUnit
1.366 +// ---------------------------------------------------------------------------
1.367 +TInt CLogicalAudioStream::RemoveProcessingUnit(MAudioProcessingUnit* aProcessingUnit)
1.368 + {
1.369 + DP_CONTEXT(CLogicalAudioStream::RemoveProcessingUnit *CD1*, CtxDevSound, DPLOCAL);
1.370 + DP_IN();
1.371 +
1.372 + if(iCurrentState != EUninitialized)
1.373 + {
1.374 + DP0_RET(KErrNotReady, "%d");
1.375 + }
1.376 +
1.377 + TInt err(KErrNotFound);
1.378 + if (aProcessingUnit != NULL)
1.379 + {
1.380 + TAudioComponentId param = aProcessingUnit->InstanceId();
1.381 + TUint count= iAudioProcessingUnits.Count();
1.382 +
1.383 + if (aProcessingUnit->IsTypeOf(KUidAudioCodec))
1.384 + {
1.385 + iCodec = NULL;
1.386 + }
1.387 + else if (aProcessingUnit->IsTypeOf(KUidAudioGainControl))
1.388 + {
1.389 + iGain = NULL;
1.390 + }
1.391 +
1.392 + for ( TUint i(0); i < count; i++ )
1.393 + {
1.394 + // find and remove component
1.395 + if( iAudioProcessingUnits[i]->InstanceId() == param)
1.396 + {
1.397 + iAudioProcessingUnits.Remove(i);
1.398 + break;
1.399 + }
1.400 + }
1.401 + SetMessageType(EComponentDestruction);
1.402 + err = KErrNone;
1.403 + }
1.404 + DP0_RET(err, "%d");
1.405 + }
1.406 +
1.407 +// ---------------------------------------------------------------------------
1.408 +// CLogicalAudioStream::ResetStreamTime
1.409 +// ---------------------------------------------------------------------------
1.410 +TInt CLogicalAudioStream::ResetStreamTime()
1.411 + {
1.412 + DP_CONTEXT(CLogicalAudioStream::ResetStreamTime *CD1*, CtxDevSound, DPLOCAL);
1.413 + DP_IN();
1.414 + TInt err(KErrNone);
1.415 + if (iCurrentState != EIdle)
1.416 + {
1.417 + DP0_RET(KErrNotReady, "%d");
1.418 + }
1.419 + if(iPositionControl)
1.420 + {
1.421 + iPositionControl->ResetControlPosition();
1.422 + }
1.423 + iTimeProcessed = 0;
1.424 + DP0_RET(err, "%d");
1.425 + }
1.426 +
1.427 +
1.428 +// ---------------------------------------------------------------------------
1.429 +// CLogicalAudioStream::GetStreamTime
1.430 +// ---------------------------------------------------------------------------
1.431 +TInt CLogicalAudioStream::GetStreamTime(TTimeIntervalMicroSeconds& aStreamTime)
1.432 + {
1.433 + DP_CONTEXT(CLogicalAudioStream::GetStreamTime *CD1*, CtxDevSound, DPLOCAL);
1.434 + DP_IN();
1.435 + TInt err(KErrNone);
1.436 +
1.437 + if(iPositionControl)
1.438 + {
1.439 + err = iPositionControl->GetControlPosition(aStreamTime);
1.440 + if(err == KErrNone)
1.441 + {
1.442 + iTimeProcessed = aStreamTime;
1.443 + }
1.444 + }
1.445 + else
1.446 + {
1.447 + aStreamTime = iTimeProcessed;
1.448 + }
1.449 + DP0_RET(err, "%d");
1.450 + }
1.451 +
1.452 +// ---------------------------------------------------------------------------
1.453 +// CLogicalAudioStream::Interface
1.454 +// ---------------------------------------------------------------------------
1.455 +TAny* CLogicalAudioStream::Interface(TUid aType)
1.456 + {
1.457 + DP_CONTEXT(CLogicalAudioStream::Interface *CD1*, CtxDevSound, DPLOCAL);
1.458 + DP_IN();
1.459 + TAny* interface(NULL);
1.460 + if( aType == KUidAudioStream)
1.461 + {
1.462 + interface = static_cast<MAudioStream*>(this);
1.463 + }
1.464 + else if( aType == KUidExtensionInferface)
1.465 + {
1.466 + interface = static_cast<MCustomInterfaceSupport*>(this);
1.467 + }
1.468 + else if (aType == KUidAudioStreamAdaptationObserver)
1.469 + {
1.470 + interface = static_cast<MAudioStreamAdaptationObserver*>(this);
1.471 + DP0_RET(interface, "0x%x");
1.472 + }
1.473 + else if (aType == KUidAudioCodecObserver)
1.474 + {
1.475 + interface = static_cast<MAudioCodecObserver*>(this);
1.476 + DP0_RET(interface, "0x%x");
1.477 + }
1.478 +
1.479 + DP_OUT();
1.480 + return interface;
1.481 + }
1.482 +
1.483 +// ---------------------------------------------------------------------------
1.484 +// From MCustomInterfaceSupport
1.485 +// CAudioStream::RequestCustomInterface
1.486 +// ---------------------------------------------------------------------------
1.487 +TInt CLogicalAudioStream::RequestCustomInterface(TUid aUid, TAny*& aPtr)
1.488 + {
1.489 + DP_CONTEXT(CLogicalAudioStream::RequestCustomInterface *CD1*, CtxDevSound, DPLOCAL);
1.490 + DP_IN();
1.491 + TInt err = KErrNone;
1.492 + if (aUid == KA3FBackdoorAccessIfUid)
1.493 + {
1.494 + MA3FBackdoorAccessIf* self = this;
1.495 + aPtr = self;
1.496 + }
1.497 + else if(iInterfaceProvider)
1.498 + {
1.499 + err = iInterfaceProvider->RequestCustomInterface(aUid, aPtr);
1.500 + if (err != KErrNone)
1.501 + {
1.502 + aPtr = NULL;
1.503 + }
1.504 + }
1.505 + else
1.506 + {
1.507 + err = KErrNotReady;
1.508 + }
1.509 + DP0_RET(err, "%d");
1.510 + }
1.511 +
1.512 +// ---------------------------------------------------------------------------
1.513 +// From MCustomInterfaceSupport
1.514 +// CAudioStream::RegisterObserver
1.515 +// ---------------------------------------------------------------------------
1.516 +TInt CLogicalAudioStream::RegisterObserver(MCustomInterfaceSupportObserver& aObserver)
1.517 + {
1.518 + DP_CONTEXT(CLogicalAudioStream::RegisterObserver *CD1*, CtxDevSound, DPLOCAL);
1.519 + DP_IN();
1.520 + TInt err = KErrNone;
1.521 + err = iCISupportObservers.Find(&aObserver);
1.522 + if( err != KErrNotFound )
1.523 + {
1.524 + err = KErrAlreadyExists;
1.525 + }
1.526 + else
1.527 + {
1.528 + err = iCISupportObservers.Append(&aObserver);
1.529 + }
1.530 + DP0_RET(err, "%d");
1.531 + }
1.532 +
1.533 +// ---------------------------------------------------------------------------
1.534 +// From MCustomInterfaceSupport
1.535 +// CAudioStream::UnRegisterObserver
1.536 +// ---------------------------------------------------------------------------
1.537 +void CLogicalAudioStream::UnRegisterObserver(MCustomInterfaceSupportObserver& aObserver)
1.538 + {
1.539 + DP_CONTEXT(CLogicalAudioStream::UnRegisterObserver *CD1*, CtxDevSound, DPLOCAL);
1.540 + DP_IN();
1.541 + TInt idxOrErr = iCISupportObservers.Find(&aObserver);
1.542 + if( idxOrErr != KErrNotFound )
1.543 + {
1.544 + iCISupportObservers.Remove(idxOrErr);
1.545 + }
1.546 + DP_OUT();
1.547 + }
1.548 +
1.549 +// ---------------------------------------------------------------------------
1.550 +// From MCustomInterfaceSupport
1.551 +// CAudioStream::CustomInterfaceRemoval
1.552 +// ---------------------------------------------------------------------------
1.553 +void CLogicalAudioStream::CustomInterfaceRemoval(TUid aInterfaceUid, TAny* aPtr)
1.554 + {
1.555 + DP_CONTEXT(CLogicalAudioStream::CustomInterfaceRemoval *CD1*, CtxDevSound, DPLOCAL);
1.556 + DP_IN();
1.557 + TUint count = iCISupportObservers.Count();
1.558 + for ( TUint idx(0); idx < count; idx++ )
1.559 + {
1.560 + iCISupportObservers[idx]->CustomInterfaceRemoval(aInterfaceUid, aPtr);
1.561 + }
1.562 + DP_OUT();
1.563 + }
1.564 +
1.565 +// ---------------------------------------------------------------------------
1.566 +// From MAudioStreamAdaptationObserver
1.567 +// CAudioStream::PhysicalAdaptationEvent
1.568 +// ---------------------------------------------------------------------------
1.569 +void CLogicalAudioStream::PhysicalAdaptationEvent(TPhysicalEvent /*aEvent*/, TInt /*aError*/)
1.570 + {
1.571 + DP_CONTEXT(CLogicalAudioStream::PhysicalAdaptationEvent *CD1*, CtxDevSound, DPLOCAL);
1.572 + DP_IN();
1.573 + DP_OUT();
1.574 + }
1.575 +
1.576 +// ---------------------------------------------------------------------------
1.577 +// CAudioStream::StateEvent
1.578 +// ---------------------------------------------------------------------------
1.579 +void CLogicalAudioStream::StateEvent(TInt aReason, TAudioState aNewState)
1.580 + {
1.581 + DP_CONTEXT(CLogicalAudioStream::StateEvent *CD1*, CtxDevSound, DPLOCAL);
1.582 + DP_IN();
1.583 +#ifdef _DEBUG
1.584 + RDebug::Print(_L("CLogicalAudioStream::StateEvent Error %d Stay %d"), aReason, aNewState);
1.585 +#endif
1.586 + TUint count = iAudioStreamObserver.Count();
1.587 + for ( TUint idx(0); idx < count; idx++ )
1.588 + {
1.589 + iAudioStreamObserver[idx]->StateEvent(*this, aReason, aNewState);
1.590 + }
1.591 + iCurrentState = aNewState;
1.592 + DP_OUT();
1.593 + }
1.594 +
1.595 +// ---------------------------------------------------------------------------
1.596 +// CLogicalAudioStream::AddProcessingUnitComplete
1.597 +// ---------------------------------------------------------------------------
1.598 +void CLogicalAudioStream::AddProcessingUnitComplete(TUid aType, TInt aError)
1.599 + {
1.600 + DP_CONTEXT(CLogicalAudioStream::AddProcessingUnitComplete *CD1*, CtxDevSound, DPLOCAL);
1.601 + DP_IN();
1.602 + MAudioProcessingUnit* instance = NULL;
1.603 + MapUidToProcessingUnit(aType, instance);
1.604 + TUint count = iAudioStreamObserver.Count();
1.605 + for ( TUint idx(0); idx < count; idx++ )
1.606 + {
1.607 + iAudioStreamObserver[idx]->AddProcessingUnitComplete(*this, instance, aError);
1.608 + }
1.609 + DP_OUT();
1.610 + }
1.611 +
1.612 +// ---------------------------------------------------------------------------
1.613 +// CLogicalAudioStream::RemoveProcessingUnitComplete
1.614 +// ---------------------------------------------------------------------------
1.615 +void CLogicalAudioStream::RemoveProcessingUnitComplete(TUid aType, TInt aError)
1.616 + {
1.617 + DP_CONTEXT(CLogicalAudioStream::RemoveProcessingUnitComplete *CD1*, CtxDevSound, DPLOCAL);
1.618 + DP_IN();
1.619 + MAudioProcessingUnit* instance = NULL;
1.620 + MapUidToProcessingUnit(aType, instance);
1.621 + TUint count = iAudioStreamObserver.Count();
1.622 + for ( TUint idx(0); idx < count; idx++ )
1.623 + {
1.624 + iAudioStreamObserver[idx]->RemoveProcessingUnitComplete(*this, instance, aError);
1.625 + }
1.626 + DP_OUT();
1.627 + }
1.628 +
1.629 +// ---------------------------------------------------------------------------
1.630 +// From MAudioStreamAdaptationObserver
1.631 +// CLogicalAudioStream::ProcessingFinished
1.632 +// ---------------------------------------------------------------------------
1.633 +void CLogicalAudioStream::ProcessingFinished()
1.634 + {
1.635 + DP_CONTEXT(CLogicalAudioStream::ProcessingFinished *CD1*, CtxDevSound, DPLOCAL);
1.636 + DP_IN();
1.637 + TUint count = iAudioStreamObserver.Count();
1.638 + for ( TUint idx(0); idx < count; idx++ )
1.639 + {
1.640 + iAudioStreamObserver[idx]->ProcessingFinished(*this);
1.641 + }
1.642 + DP_OUT();
1.643 + }
1.644 +
1.645 +// ---------------------------------------------------------------------------
1.646 +// CLogicalAudioStream::FlushComplete
1.647 +// ---------------------------------------------------------------------------
1.648 +void CLogicalAudioStream::FlushComplete(TInt aError)
1.649 + {
1.650 + DP_CONTEXT(CLogicalAudioStream::FlushComplete *CD1*, CtxDevSound, DPLOCAL);
1.651 + DP_IN();
1.652 + TUint count = iAudioStreamObserver.Count();
1.653 + for ( TUint idx(0); idx < count; idx++ )
1.654 + {
1.655 + iAudioStreamObserver[idx]->FlushComplete(*this, aError);
1.656 + }
1.657 + DP_OUT();
1.658 + }
1.659 +
1.660 +
1.661 +// ---------------------------------------------------------------------------
1.662 +// Internal
1.663 +// CLogicalAudioStream::DoAddProcessingUnit
1.664 +// ---------------------------------------------------------------------------
1.665 +TInt CLogicalAudioStream::DoAddProcessingUnit(MAudioProcessingUnit* aProcessingUnit)
1.666 + {
1.667 + DP_CONTEXT(CLogicalAudioStream::DoAddProcessingUnit *CD1*, CtxDevSound, DPLOCAL);
1.668 + DP_IN();
1.669 + TInt err(KErrNone);
1.670 +
1.671 + if (aProcessingUnit->IsTypeOf(KUidAudioCodec) )
1.672 + {
1.673 + // Need for tone handling error
1.674 + CAudioProcessingUnit* pUnit = static_cast<CAudioProcessingUnit*>(aProcessingUnit);
1.675 + iCodec = static_cast<MAudioProcessingUnit*>(pUnit);
1.676 + }
1.677 + else if (aProcessingUnit->IsTypeOf(KUidAudioGainControl) )
1.678 + {
1.679 + CAudioProcessingUnit* pUnit = static_cast<CAudioProcessingUnit*>(aProcessingUnit);
1.680 + iGain = static_cast<MAudioProcessingUnit*>(pUnit);
1.681 + }
1.682 +
1.683 + err = iAudioProcessingUnits.Append(aProcessingUnit);
1.684 + SetMessageType(EComponentCreation);
1.685 +
1.686 + DP0_RET(err, "%d");
1.687 + }
1.688 +
1.689 +// ---------------------------------------------------------------------------
1.690 +// Internal
1.691 +// CLogicalAudioStream::MapUidToProcessingUnit
1.692 +// ---------------------------------------------------------------------------
1.693 +void CLogicalAudioStream::MapUidToProcessingUnit(TUid aType, MAudioProcessingUnit*& aInstance)
1.694 + {
1.695 + DP_CONTEXT(CLogicalAudioStream::MapUidToProcessingUnit *CD1*, CtxDevSound, DPLOCAL);
1.696 + DP_IN();
1.697 + TUint count = iAudioProcessingUnits.Count();
1.698 + for(TUint i=0; i<count; i++)
1.699 + {
1.700 + aInstance = static_cast<MAudioProcessingUnit*>(iAudioProcessingUnits[i]);
1.701 + if ( aInstance->IsTypeOf(aType) )
1.702 + {
1.703 + break;
1.704 + }
1.705 + aInstance = NULL;
1.706 + }
1.707 + DP_OUT();
1.708 + }
1.709 +
1.710 +// From MLogicalChain
1.711 +// ---------------------------------------------------------------------------
1.712 +// CLogicalAudioStream::SetMessageType
1.713 +// ---------------------------------------------------------------------------
1.714 +void CLogicalAudioStream::SetMessageType(TMMRCMessageType aMessageType)
1.715 + {
1.716 + DP_CONTEXT(CLogicalAudioStream::SetMessageType *CD1*, CtxDevSound, DPLOCAL);
1.717 + DP_IN();
1.718 + iMessageType |= aMessageType;
1.719 + DP_OUT();
1.720 + }
1.721 +
1.722 +// ---------------------------------------------------------------------------
1.723 +// CLogicalAudioStream::ResetMessage
1.724 +// ---------------------------------------------------------------------------
1.725 +void CLogicalAudioStream::ResetMessage()
1.726 + {
1.727 + DP_CONTEXT(CLogicalAudioStream::SetMessageType *CD1*, CtxDevSound, DPLOCAL);
1.728 + DP_IN();
1.729 + iMessageType = ENoMessage;
1.730 + DP_OUT();
1.731 + }
1.732 +
1.733 +// ---------------------------------------------------------------------------
1.734 +// CLogicalAudioStream::MessageType
1.735 +// ---------------------------------------------------------------------------
1.736 +TUint CLogicalAudioStream::MessageType()
1.737 + {
1.738 + DP_CONTEXT(CLogicalAudioStream::MessageType *CD1*, CtxDevSound, DPLOCAL);
1.739 + DP_IN();
1.740 + DP0_RET(iMessageType, "Message type %d");
1.741 + }
1.742 +
1.743 +
1.744 +// ---------------------------------------------------------------------------
1.745 +// CLogicalAudioStream::AudioProcessingUnitUid
1.746 +// ---------------------------------------------------------------------------
1.747 +TUid CLogicalAudioStream::AudioProcessingUnitUid(TInt aIndex)
1.748 + {
1.749 + DP_CONTEXT(CLogicalAudioStream::AudioProcessingUnitUid *CD1*, CtxDevSound, DPLOCAL);
1.750 + DP_IN();
1.751 + TUid uid = {0};
1.752 + MAudioProcessingUnit* pUnit(NULL);
1.753 + if (aIndex >= 0)
1.754 + {
1.755 + pUnit = static_cast<MAudioProcessingUnit*>(iAudioProcessingUnits[aIndex]);
1.756 + }
1.757 +
1.758 + if (pUnit != NULL)
1.759 + {
1.760 + if (pUnit->IsTypeOf(KUidAudioDecoder))
1.761 + {
1.762 + uid = KUidAudioDecoder;
1.763 + }
1.764 + else if (pUnit->IsTypeOf(KUidAudioEncoder))
1.765 + {
1.766 + uid = KUidAudioEncoder;
1.767 + }
1.768 + else if (pUnit->IsTypeOf(KUidMmfBufferSource))
1.769 + {
1.770 + uid = KUidMmfBufferSource;
1.771 + }
1.772 + else if (pUnit->IsTypeOf(KUidAudioGainControl))
1.773 + {
1.774 + uid = KUidAudioGainControl;
1.775 + }
1.776 + else if (pUnit->IsTypeOf(KUidAudioDeviceSink))
1.777 + {
1.778 + uid = KUidAudioDeviceSink;
1.779 + }
1.780 + else if (pUnit->IsTypeOf(KUidMmfBufferSink))
1.781 + {
1.782 + uid = KUidMmfBufferSink;
1.783 + }
1.784 + else if (pUnit->IsTypeOf(KUidAudioDeviceSource))
1.785 + {
1.786 + uid = KUidAudioDeviceSource;
1.787 + }
1.788 + else if (pUnit->IsTypeOf(KUidAudioCodec))
1.789 + {
1.790 + uid = KUidAudioCodec;
1.791 + }
1.792 + }
1.793 + DP_OUT();
1.794 + return uid;
1.795 + }
1.796 +
1.797 +// ---------------------------------------------------------------------------
1.798 +// CLogicalAudioStream::AudioProcessingUnitsCount
1.799 +// ---------------------------------------------------------------------------
1.800 +TInt CLogicalAudioStream::AudioProcessingUnitsCount()
1.801 + {
1.802 + DP_CONTEXT(CLogicalAudioStream::AudioProcessingUnitsCount *CD1*, CtxDevSound, DPLOCAL);
1.803 + DP_IN();
1.804 + DP0_RET(iAudioProcessingUnits.Count(), "%d");
1.805 + }
1.806 +
1.807 +// ---------------------------------------------------------------------------
1.808 +// CLogicalAudioStream::StreamState
1.809 +// ---------------------------------------------------------------------------
1.810 +TAudioState CLogicalAudioStream::StreamState()
1.811 + {
1.812 + DP_CONTEXT(CLogicalAudioStream::StreamState *CD1*, CtxDevSound, DPLOCAL);
1.813 + DP_IN();
1.814 + DP0_RET(iCurrentState, "Stream state %d");
1.815 + }
1.816 +
1.817 +// ---------------------------------------------------------------------------
1.818 +// From MLogicalChain
1.819 +// CLogicalAudioStream::SetStreamState
1.820 +// ---------------------------------------------------------------------------
1.821 +void CLogicalAudioStream::SetStreamState(TAudioState aAudioState)
1.822 + {
1.823 + DP_CONTEXT(CLogicalAudioStream::StreamState *CD1*, CtxDevSound, DPLOCAL);
1.824 + DP_IN();
1.825 + iCurrentState = aAudioState;
1.826 + DP_OUT();
1.827 + }
1.828 +
1.829 +// ---------------------------------------------------------------------------
1.830 +// From MLogicalChain
1.831 +// CLogicalAudioStream::CodecFormat
1.832 +// ---------------------------------------------------------------------------
1.833 +TUid CLogicalAudioStream::CodecFormat()
1.834 + {
1.835 + DP_CONTEXT(CLogicalAudioStream::CodecFormat *CD1*, CtxDevSound, DPLOCAL);
1.836 + DP_IN();
1.837 + CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec);
1.838 + DP_OUT();
1.839 + TUid tuidnull = {0};
1.840 + if(codec)
1.841 + {
1.842 + return codec->iFormat;
1.843 + }
1.844 + else
1.845 + {
1.846 + return tuidnull;
1.847 + }
1.848 + }
1.849 +
1.850 +// ---------------------------------------------------------------------------
1.851 +// From MLogicalChain
1.852 +// CLogicalAudioStream::GetSampleRate
1.853 +// ---------------------------------------------------------------------------
1.854 +TInt CLogicalAudioStream::GetSampleRate()
1.855 + {
1.856 + DP_CONTEXT(CLogicalAudioStream::GetSampleRate *CD1*, CtxDevSound, DPLOCAL);
1.857 + DP_IN();
1.858 + const TUint KDefaultSampleRate = 8000; // Default sample rate
1.859 + CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec);
1.860 + DP_OUT();
1.861 + TInt sampleRateValue = KDefaultSampleRate;
1.862 + if(codec)
1.863 + {
1.864 + sampleRateValue = codec->iSampleRateConfig;
1.865 + }
1.866 + return sampleRateValue;
1.867 + }
1.868 +
1.869 +// ---------------------------------------------------------------------------
1.870 +// From MLogicalChain
1.871 +// CLogicalAudioStream::GetMode
1.872 +// ---------------------------------------------------------------------------
1.873 +TUid CLogicalAudioStream::GetMode()
1.874 + {
1.875 + DP_CONTEXT(CLogicalAudioStream::GetMode *CD1*, CtxDevSound, DPLOCAL);
1.876 + DP_IN();
1.877 + CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec);
1.878 + TUid tuidnull = {0};
1.879 + DP_OUT();
1.880 + if(codec)
1.881 + {
1.882 + return codec->iModeConfig;
1.883 + }
1.884 + else
1.885 + {
1.886 + return tuidnull;
1.887 + }
1.888 + }
1.889 +
1.890 +
1.891 +// ---------------------------------------------------------------------------
1.892 +// From MLogicalChain
1.893 +// CLogicalAudioStream::Priority
1.894 +// ---------------------------------------------------------------------------
1.895 +TInt CLogicalAudioStream::Priority()
1.896 + {
1.897 + DP_CONTEXT(CLogicalAudioStream::Priority*CD1*, CtxDevSound, DPLOCAL);
1.898 + DP_IN();
1.899 + DP0_RET(iAudioTypeSettings.iPriority, "Priority %d");
1.900 + }
1.901 +
1.902 +// ---------------------------------------------------------------------------
1.903 +// From MLogicalChain
1.904 +// CLogicalAudioStream::GetVolumeRampParameters
1.905 +// ---------------------------------------------------------------------------
1.906 +void CLogicalAudioStream::GetVolumeRampParameters(TUid& aRampOperation, TTimeIntervalMicroSeconds& aRampDuration)
1.907 + {
1.908 + DP_CONTEXT(CLogicalAudioStream::GetVolumeRampParameters*CD1*, CtxDevSound, DPLOCAL);
1.909 + DP_IN();
1.910 + CLogicalAudioGainControl* gain = static_cast<CLogicalAudioGainControl*>(iGain);
1.911 + if(gain)
1.912 + {
1.913 + aRampOperation = gain->iDesiredRampOperation;
1.914 + aRampDuration = gain->iDesiredRampTime;
1.915 + }
1.916 + DP_OUT();
1.917 + }
1.918 +
1.919 +// ---------------------------------------------------------------------------
1.920 +// From MLogicalChain
1.921 +// CLogicalAudioStream::CopySettings
1.922 +// @param the logical chain from where the parameter will be copied
1.923 +// ---------------------------------------------------------------------------
1.924 +void CLogicalAudioStream::CopySettings(const MLogicalChain& aChain)
1.925 + {
1.926 + DP_CONTEXT(CLogicalAudioStream::CopySettings *CD1*, CtxDevSound, DPLOCAL);
1.927 + DP_IN();
1.928 + CopyStreamSettings(aChain);
1.929 + CopyCodecSettings(aChain);
1.930 + CopyGainSettings(aChain);
1.931 + DP_OUT();
1.932 + }
1.933 +
1.934 +void CLogicalAudioStream::CopyStreamSettings(const MLogicalChain& aChain)
1.935 + {
1.936 + DP_CONTEXT(CLogicalAudioStream::CopyStreamSettings *CD1*, CtxDevSound, DPLOCAL);
1.937 + DP_IN();
1.938 + // LogicalAudioStream settings
1.939 + CLogicalAudioStream& srcChain = static_cast<CLogicalAudioStream&>(const_cast<MLogicalChain&>(aChain));
1.940 +
1.941 + iAudioTypeSettings = srcChain.iAudioTypeSettings;
1.942 + iCurrentState = srcChain.iCurrentState;
1.943 + iRequestState = srcChain.iRequestState;
1.944 + iMessageType = srcChain.iMessageType;
1.945 + iTimeProcessed = srcChain.iTimeProcessed;
1.946 + DP_OUT();
1.947 + }
1.948 +
1.949 +void CLogicalAudioStream::CopyCodecSettings(const MLogicalChain& aChain)
1.950 + {
1.951 + DP_CONTEXT(CLogicalAudioStream::CopyCodecSettings *CD1*, CtxDevSound, DPLOCAL);
1.952 + DP_IN();
1.953 +
1.954 + CLogicalAudioStream& srcChain = static_cast<CLogicalAudioStream&>(const_cast<MLogicalChain&>(aChain));
1.955 + // Copy codec settings
1.956 + CLogicalAudioCodec* srcCodec = static_cast<CLogicalAudioCodec*>(srcChain.iCodec);
1.957 + if(iCodec && srcCodec)
1.958 + {
1.959 + CLogicalAudioCodec* logicalCodec = static_cast<CLogicalAudioCodec*>(iCodec);
1.960 + logicalCodec->iFormat = srcCodec->iFormat;
1.961 + logicalCodec->iSampleRateConfig = srcCodec->iSampleRateConfig;
1.962 + logicalCodec->iModeConfig = srcCodec->iModeConfig;
1.963 + }
1.964 + DP_OUT();
1.965 + }
1.966 +
1.967 +
1.968 +void CLogicalAudioStream::CopyGainSettings(const MLogicalChain& aChain)
1.969 + {
1.970 + DP_CONTEXT(CLogicalAudioStream::CopyGainSettings *CD1*, CtxDevSound, DPLOCAL);
1.971 + DP_IN();
1.972 +
1.973 + CLogicalAudioStream& srcChain = static_cast<CLogicalAudioStream&>(const_cast<MLogicalChain&>(aChain));
1.974 + // Copy gain settings
1.975 + CLogicalAudioGainControl* srcGain = static_cast<CLogicalAudioGainControl*>(srcChain.iGain);
1.976 + if (iGain && srcGain )
1.977 + {
1.978 + if(srcGain->iDesiredChannels.Count() > 0)
1.979 + {
1.980 + CLogicalAudioGainControl* logicalGain = static_cast<CLogicalAudioGainControl*>(iGain);
1.981 + TUint count = srcGain->iDesiredChannels.Count();
1.982 + for (TUint i(0); i < count; i++)
1.983 + {
1.984 + logicalGain->iDesiredChannels[i] = srcGain->iDesiredChannels[i];
1.985 + }
1.986 + logicalGain->iDesiredRampOperation = srcGain->iDesiredRampOperation;
1.987 + logicalGain->iDesiredRampTime = srcGain->iDesiredRampTime;
1.988 + }
1.989 + }
1.990 + DP_OUT();
1.991 + }
1.992 +
1.993 +// ---------------------------------------------------------------------------
1.994 +// From MLogicalChain
1.995 +// CLogicalAudioStream::CloneL
1.996 +// ---------------------------------------------------------------------------
1.997 +MLogicalChain* CLogicalAudioStream::CloneL()
1.998 + {
1.999 + DP_CONTEXT(CLogicalAudioStream::CloneL *CD1*, CtxDevSound, DPLOCAL);
1.1000 + DP_IN();
1.1001 + TInt err = KErrNone;
1.1002 + MLogicalChain* newLogicalChain = NULL;
1.1003 +
1.1004 + // Create another audiostream
1.1005 + CAudioStreamManager *manager = NULL;
1.1006 + manager = CAudioStreamManager::NewL(KUidAudioStream);
1.1007 + // Copy stream settings
1.1008 + CLogicalAudioStream* logicalAudioStream = static_cast<CLogicalAudioStream*>(manager);
1.1009 +
1.1010 + MAudioProcessingUnit* pUnit=NULL;
1.1011 + TInt count = iAudioProcessingUnits.Count();
1.1012 + for(TInt i = 0; i < count ; i++)
1.1013 + {
1.1014 + // Create processing unit
1.1015 + TUid type = AudioProcessingUnitUid(i);
1.1016 + TComponentParameters cParameters;
1.1017 + cParameters.iTypeUid = type;
1.1018 + cParameters.iInstanceId = 0;
1.1019 + cParameters.iContextId = 0;
1.1020 + cParameters.iSettingsObserver = NULL;
1.1021 + pUnit = CAudioProcessingUnit::NewL(cParameters);
1.1022 +
1.1023 + // If no error then add to the stream
1.1024 + if ( (type == KUidAudioDecoder) || (type == KUidAudioEncoder) )
1.1025 + {
1.1026 + err = logicalAudioStream->AddAudioCodec(pUnit);
1.1027 + }
1.1028 + else if (type == KUidMmfBufferSource || (type == KUidAudioDeviceSource) )
1.1029 + {
1.1030 + err = logicalAudioStream->AddSource(pUnit);
1.1031 + }
1.1032 + else if (type == KUidAudioGainControl)
1.1033 + {
1.1034 + err = logicalAudioStream->AddGainControl(pUnit);
1.1035 + }
1.1036 + else if (type == KUidAudioDeviceSink || ( type == KUidMmfBufferSink) )
1.1037 + {
1.1038 + err = logicalAudioStream->AddSink(pUnit);
1.1039 + }
1.1040 + // TODO:
1.1041 + // Check this couldn't be added
1.1042 + if(err != KErrNone)
1.1043 + {
1.1044 + logicalAudioStream->iAudioProcessingUnits.Remove(iAudioProcessingUnits.Count()-1);
1.1045 + delete pUnit;
1.1046 + }
1.1047 + }
1.1048 + // Cast to MLogicalChain
1.1049 + newLogicalChain = static_cast<MLogicalChain*>(logicalAudioStream);
1.1050 + newLogicalChain->CopySettings(*this);
1.1051 +
1.1052 + DP0_RET(newLogicalChain, "0x%x");
1.1053 + }
1.1054 +
1.1055 +// ---------------------------------------------------------------------------
1.1056 +// From MLogicalChain
1.1057 +// CLogicalAudioStream::Release
1.1058 +// ---------------------------------------------------------------------------
1.1059 +void CLogicalAudioStream::Release()
1.1060 + {
1.1061 + DP_CONTEXT(CLogicalAudioStream::Release *CD1*, CtxDevSound, DPLOCAL);
1.1062 + DP_IN();
1.1063 + // ResetAndDestroy
1.1064 + TInt count = iAudioProcessingUnits.Count();
1.1065 + TInt i;
1.1066 + for (i=0; i<count; i++)
1.1067 + {
1.1068 + CAudioProcessingUnit* pUnit = static_cast<CAudioProcessingUnit*>(iAudioProcessingUnits[i]);
1.1069 + delete pUnit;
1.1070 + }
1.1071 + iAudioProcessingUnits.Reset();
1.1072 + DP_OUT();
1.1073 + delete this;
1.1074 + }
1.1075 +
1.1076 +// ---------------------------------------------------------------------------
1.1077 +// From MLogicalChain
1.1078 +// CLogicalAudioStream::GetComponent
1.1079 +// ---------------------------------------------------------------------------
1.1080 +TAny* CLogicalAudioStream::GetComponent(TUid aType)
1.1081 + {
1.1082 + DP_CONTEXT(CLogicalAudioStream::GetComponent *CD1*, CtxDevSound, DPLOCAL);
1.1083 + DP_IN();
1.1084 + TAny* interface = NULL;
1.1085 +
1.1086 + // go through this or our subcomponents to see if somebody knows about the interface
1.1087 + interface = Interface(aType);
1.1088 + if (interface==NULL)
1.1089 + {
1.1090 + TUint count = iAudioProcessingUnits.Count();
1.1091 + // go through components looking for valid interface
1.1092 + for ( TInt i=0; i < count; i++ )
1.1093 + {
1.1094 + interface = iAudioProcessingUnits[i]->Interface(aType);
1.1095 + if (interface!=NULL)
1.1096 + {
1.1097 + break;
1.1098 + };
1.1099 + }
1.1100 + };
1.1101 +
1.1102 +
1.1103 + DP0_RET(interface, "0x%x");
1.1104 + }
1.1105 +
1.1106 +
1.1107 +
1.1108 +// ---------------------------------------------------------------------------
1.1109 +// From MLogicalChain
1.1110 +// CLogicalAudioStream::SetAdaptationSource
1.1111 +// ---------------------------------------------------------------------------
1.1112 +void CLogicalAudioStream::SetAdaptationSource(MMMFBufferSource& aSource)
1.1113 + {
1.1114 + DP_CONTEXT(CLogicalAudioStream::SetAdaptationSource *CD1*, CtxDevSound, DPLOCAL);
1.1115 + DP_IN();
1.1116 + MapUidToProcessingUnit(KUidMmfBufferSource, iAudioProcessingUnit);
1.1117 + ASSERT(iAudioProcessingUnit);
1.1118 +
1.1119 + CAudioProcessingUnit* cUnit = static_cast<CAudioProcessingUnit*>(iAudioProcessingUnit);
1.1120 + CLogicalBufferSource* bufferSource = (static_cast<CLogicalBufferSource*>(cUnit));
1.1121 +
1.1122 + bufferSource->iAdaptationBufferSource = &aSource;
1.1123 + aSource.SetDataSupplier(*bufferSource);
1.1124 +
1.1125 + iAudioProcessingUnit = NULL;
1.1126 + DP_OUT();
1.1127 + }
1.1128 +
1.1129 +// ---------------------------------------------------------------------------
1.1130 +// From MLogicalChain
1.1131 +// CLogicalAudioStream::SetAdaptationSink
1.1132 +// ---------------------------------------------------------------------------
1.1133 +void CLogicalAudioStream::SetAdaptationSink(MMMFBufferSink& aSink)
1.1134 + {
1.1135 + DP_CONTEXT(CLogicalAudioStream::SetAdaptationSink *CD1*, CtxDevSound, DPLOCAL);
1.1136 + DP_IN();
1.1137 + MapUidToProcessingUnit(KUidMmfBufferSink, iAudioProcessingUnit);
1.1138 + ASSERT(iAudioProcessingUnit);
1.1139 +
1.1140 + CAudioProcessingUnit* cUnit = static_cast<CAudioProcessingUnit*>(iAudioProcessingUnit);
1.1141 + CLogicalBufferSink* bufferSink = (static_cast<CLogicalBufferSink*>(cUnit));
1.1142 +
1.1143 + bufferSink->iAdaptationBufferSink = &aSink;
1.1144 + aSink.SetDataConsumer(*bufferSink);
1.1145 +
1.1146 + iAudioProcessingUnit = NULL;
1.1147 + DP_OUT();
1.1148 + }
1.1149 +
1.1150 +// ---------------------------------------------------------------------------
1.1151 +// From MLogicalChain
1.1152 +// CLogicalAudioStream::SetAdaptationGainControl
1.1153 +// ---------------------------------------------------------------------------
1.1154 +void CLogicalAudioStream::SetAdaptationGainControl(MAudioGainControl& aGain)
1.1155 + {
1.1156 + DP_CONTEXT(CLogicalAudioStream::SetAdaptationGainControl *CD1*, CtxDevSound, DPLOCAL);
1.1157 + DP_IN();
1.1158 + ASSERT(iGain);
1.1159 + CLogicalAudioGainControl* gain = static_cast<CLogicalAudioGainControl*>(iGain);
1.1160 + gain->iAdaptationGain = &aGain;
1.1161 + aGain.RegisterAudioGainControlObserver(*gain);
1.1162 + DP_OUT();
1.1163 + }
1.1164 +
1.1165 +
1.1166 +
1.1167 +// ---------------------------------------------------------------------------
1.1168 +// From MLogicalChain
1.1169 +// CLogicalAudioStream::SetPositionControl
1.1170 +// ---------------------------------------------------------------------------
1.1171 +void CLogicalAudioStream::SetStreamPositionControl(MStreamPositionControl& aPositionControl)
1.1172 + {
1.1173 + DP_CONTEXT(CLogicalAudioStream::SetStreamPositionControl *CD1*, CtxDevSound, DPLOCAL);
1.1174 + DP_IN();
1.1175 + iPositionControl = &aPositionControl;
1.1176 + DP_OUT();
1.1177 + }
1.1178 +
1.1179 +// ---------------------------------------------------------------------------
1.1180 +// CLogicalAudioStream::SetAdaptationStream
1.1181 +// ---------------------------------------------------------------------------
1.1182 +void CLogicalAudioStream::SetAdaptationStream(MConfigurationHelper& aStream)
1.1183 + {
1.1184 + DP_CONTEXT(CLogicalAudioStream::SetAdaptationStream *CD1*, CtxDevSound, DPLOCAL);
1.1185 + DP_IN();
1.1186 + CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec);
1.1187 + if (codec != NULL)
1.1188 + {
1.1189 + if (codec->iAdaptationStream == NULL)
1.1190 + {
1.1191 + codec->iAdaptationStream = &aStream;
1.1192 + }
1.1193 + }
1.1194 + DP_OUT();
1.1195 + }
1.1196 +
1.1197 +// ---------------------------------------------------------------------------
1.1198 +// CLogicalAudioStream::SetStreamBufferControl
1.1199 +// ---------------------------------------------------------------------------
1.1200 +void CLogicalAudioStream::SetStreamBufferControl(MStreamBufferControl& aStreamBufferControl)
1.1201 + {
1.1202 + DP_CONTEXT(CLogicalAudioStream::SetAdaptationStream *CD1*, CtxDevSound, DPLOCAL);
1.1203 + DP_IN();
1.1204 + iStreamBufferControl = &aStreamBufferControl;
1.1205 + DP_OUT();
1.1206 + }
1.1207 +
1.1208 +
1.1209 +// ---------------------------------------------------------------------------
1.1210 +// CLogicalAudioStream::SetCustomInterfaceProvider
1.1211 +// ---------------------------------------------------------------------------
1.1212 +void CLogicalAudioStream::SetCustomInterfaceProvider(MCustomInterfaceSupport& aInterfaceProvider)
1.1213 + {
1.1214 + DP_CONTEXT(CLogicalAudioStream::SetCustomInterfaceProvider *CD1*, CtxDevSound, DPLOCAL);
1.1215 + DP_IN();
1.1216 + iInterfaceProvider = &aInterfaceProvider;
1.1217 + DP_OUT();
1.1218 + }
1.1219 +
1.1220 +// ---------------------------------------------------------------------------
1.1221 +// CLogicalAudioStream::SampleRateSet
1.1222 +// ---------------------------------------------------------------------------
1.1223 +void CLogicalAudioStream::SampleRateSet(TInt aError)
1.1224 + {
1.1225 + DP_CONTEXT(CLogicalAudioStream::SampleRateSet *CD1*, CtxDevSound, DPLOCAL);
1.1226 + DP_IN();
1.1227 + CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec);
1.1228 + if(codec)
1.1229 + {
1.1230 + TUint count = codec->iAudioCodecObserver.Count();
1.1231 + for ( TUint idx(0); idx < count; idx++ )
1.1232 + {
1.1233 + codec->iAudioCodecObserver[idx]->SampleRateSet(aError);
1.1234 + }
1.1235 + }
1.1236 + DP_OUT();
1.1237 + }
1.1238 +
1.1239 +// ---------------------------------------------------------------------------
1.1240 +// CLogicalAudioStream::ModeSet
1.1241 +// ---------------------------------------------------------------------------
1.1242 +void CLogicalAudioStream::ModeSet(TInt aError)
1.1243 + {
1.1244 + DP_CONTEXT(CLogicalAudioStream::SampleRateSet *CD1*, CtxDevSound, DPLOCAL);
1.1245 + DP_IN();
1.1246 + CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec);
1.1247 + if(codec)
1.1248 + {
1.1249 + TUint count = codec->iAudioCodecObserver.Count();
1.1250 + for ( TUint idx(0); idx < count; idx++ )
1.1251 + {
1.1252 + codec->iAudioCodecObserver[idx]->ModeSet(aError);
1.1253 + }
1.1254 + }
1.1255 + DP_OUT();
1.1256 + }
1.1257 +
1.1258 +// ---------------------------------------------------------------------------
1.1259 +// CLogicalAudioStream::GetSupportedSampleRatesComplete
1.1260 +// ---------------------------------------------------------------------------
1.1261 +void CLogicalAudioStream::GetSupportedSampleRatesComplete (TInt aError)
1.1262 + {
1.1263 + DP_CONTEXT(CLogicalAudioStream::SampleRateSet *CD1*, CtxDevSound, DPLOCAL);
1.1264 + DP_IN();
1.1265 + CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec);
1.1266 + if(codec)
1.1267 + {
1.1268 + TUint count = codec->iAudioCodecObserver.Count();
1.1269 + for ( TUint idx(0); idx < count; idx++ )
1.1270 + {
1.1271 + codec->iAudioCodecObserver[idx]->GetSupportedSampleRatesComplete(aError);
1.1272 + }
1.1273 + }
1.1274 + DP_OUT();
1.1275 + }
1.1276 +
1.1277 +// ---------------------------------------------------------------------------
1.1278 +// CLogicalAudioStream::GetSupportedModesComplete
1.1279 +// ---------------------------------------------------------------------------
1.1280 +void CLogicalAudioStream::GetSupportedModesComplete (TInt aError)
1.1281 + {
1.1282 + DP_CONTEXT(CLogicalAudioStream::SampleRateSet *CD1*, CtxDevSound, DPLOCAL);
1.1283 + DP_IN();
1.1284 + CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec);
1.1285 + if(codec)
1.1286 + {
1.1287 + TUint count = codec->iAudioCodecObserver.Count();
1.1288 + for ( TUint idx(0); idx < count; idx++ )
1.1289 + {
1.1290 + codec->iAudioCodecObserver[idx]->GetSupportedModesComplete(aError);
1.1291 + }
1.1292 + }
1.1293 + DP_OUT();
1.1294 + }
1.1295 +
1.1296 +// ---------------------------------------------------------------------------
1.1297 +// CLogicalAudioStream::SetParentContext
1.1298 +// ---------------------------------------------------------------------------
1.1299 +void CLogicalAudioStream::SetParentContext(const CAudioContext& aContext)
1.1300 + {
1.1301 + iParentContext = const_cast<CAudioContext*>(&aContext);
1.1302 + }
1.1303 +
1.1304 +
1.1305 +// from MA3FBackdoorAccessIf
1.1306 +
1.1307 +MAudioContext* CLogicalAudioStream::AudioContext()
1.1308 + {
1.1309 + return iParentContext;
1.1310 + }
1.1311 +
1.1312 +MAudioStream* CLogicalAudioStream::AudioStream()
1.1313 + {
1.1314 + return this;
1.1315 + }
1.1316 +
1.1317 +MAudioProcessingUnit* CLogicalAudioStream::ProcessingUnit(TUid aType)
1.1318 + {
1.1319 + // look through our processing units for something of the correct type
1.1320 + TInt numProcessingUnits = iAudioProcessingUnits.Count();
1.1321 + for (TInt index=0; index < numProcessingUnits; index++)
1.1322 + {
1.1323 + MAudioProcessingUnit* ptr = iAudioProcessingUnits[index];
1.1324 + if (ptr->IsTypeOf(aType))
1.1325 + {
1.1326 + return ptr;
1.1327 + }
1.1328 + }
1.1329 + return NULL;
1.1330 + }