os/mm/devsoundextensions/audiorouting/Input/AudioInputMessageHandler/src/AudioInputMessageHandler.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/audiorouting/Input/AudioInputMessageHandler/src/AudioInputMessageHandler.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,155 @@
1.4 +/*
1.5 +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: Audio input msg handler implementation
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +// INCLUDE FILES
1.24 +#include "AudioInputMessageHandler.h"
1.25 +#include "AudioInputMessageTypes.h"
1.26 +#include "AudioInput.h"
1.27 +
1.28 +// ================= MEMBER FUNCTIONS =======================
1.29 +
1.30 +// C++ default constructor can NOT contain any code, that
1.31 +// might leave.
1.32 +//
1.33 +CAudioInputMessageHandler::CAudioInputMessageHandler(CAudioInput* aAudioInput,
1.34 + CMMFObjectContainer& aContainer) :
1.35 + CMMFObject(KUidAudioInput),
1.36 + iContainer(aContainer)
1.37 + {
1.38 + iAudioInput = aAudioInput;
1.39 + }
1.40 +
1.41 +// Two-phased constructor.
1.42 +EXPORT_C CAudioInputMessageHandler* CAudioInputMessageHandler::NewL(TAny* aCustomInterface,
1.43 + CMMFObjectContainer& aContainer)
1.44 + {
1.45 + CAudioInput* audioInput = (CAudioInput*)aCustomInterface;
1.46 + CAudioInputMessageHandler* self = new (ELeave) CAudioInputMessageHandler(audioInput,
1.47 + aContainer);
1.48 +
1.49 + return self;
1.50 + }
1.51 +
1.52 +
1.53 +// Destructor
1.54 +CAudioInputMessageHandler::~CAudioInputMessageHandler()
1.55 + {
1.56 + delete iAudioInput;
1.57 + }
1.58 +
1.59 +
1.60 +// ---------------------------------------------------------
1.61 +// CAudioInput::AudioInput
1.62 +// ?implementation_description
1.63 +// (other items were commented in a header).
1.64 +// ---------------------------------------------------------
1.65 +//
1.66 +EXPORT_C TUid CAudioInputMessageHandler::Uid()
1.67 + {
1.68 + return KUidAudioInput;
1.69 + }
1.70 +
1.71 +// ---------------------------------------------------------
1.72 +// CAudioInput::SetAudioInputL
1.73 +// ?implementation_description
1.74 +// (other items were commented in a header).
1.75 +// ---------------------------------------------------------
1.76 +//
1.77 +void CAudioInputMessageHandler::HandleRequest(TMMFMessage& aMessage)
1.78 + {
1.79 + ASSERT(aMessage.Destination().InterfaceId() == KUidAudioInput);
1.80 + TRAPD(error,DoHandleRequestL(aMessage));
1.81 + if(error)
1.82 + {
1.83 + aMessage.Complete(error);
1.84 + }
1.85 + }
1.86 +
1.87 +// ---------------------------------------------------------
1.88 +// CAudioInput::SetAudioInputL
1.89 +// ?implementation_description
1.90 +// (other items were commented in a header).
1.91 +// ---------------------------------------------------------
1.92 +//
1.93 +void CAudioInputMessageHandler::DoHandleRequestL(TMMFMessage& aMessage)
1.94 + {
1.95 + switch(aMessage.Function())
1.96 + {
1.97 + case EAifDelete:
1.98 + {
1.99 + DoDeleteL(aMessage);
1.100 + break;
1.101 + }
1.102 + case EAifSetInputs:
1.103 + {
1.104 + DoSetInputsL(aMessage);
1.105 + break;
1.106 + }
1.107 + default:
1.108 + {
1.109 + aMessage.Complete(KErrNotSupported);
1.110 + }
1.111 + }
1.112 + }
1.113 +
1.114 +// ---------------------------------------------------------
1.115 +// CAudioInput::SetAudioInputL
1.116 +// ?implementation_description
1.117 +// (other items were commented in a header).
1.118 +// ---------------------------------------------------------
1.119 +//
1.120 +void CAudioInputMessageHandler::DoDeleteL(TMMFMessage& aMessage)
1.121 + {
1.122 + aMessage.Complete(KErrNone);
1.123 + iContainer.RemoveAndDestroyMMFObject(*this);
1.124 + }
1.125 +
1.126 +// ---------------------------------------------------------
1.127 +// CAudioInput::SetAudioInputL
1.128 +// ?implementation_description
1.129 +// (other items were commented in a header).
1.130 +// ---------------------------------------------------------
1.131 +//
1.132 +void CAudioInputMessageHandler::DoSetInputsL(TMMFMessage& aMessage)
1.133 + {
1.134 + TPckgBuf<TInt> countPckg;
1.135 + aMessage.ReadData1FromClient(countPckg);
1.136 + TInt count = countPckg();
1.137 +
1.138 + CArrayFixFlat<CAudioInput::TAudioInputPreference>* inputArray =
1.139 + new(ELeave) CArrayFixFlat<CAudioInput::TAudioInputPreference>(4);
1.140 + CleanupStack::PushL(inputArray);
1.141 + inputArray->ResizeL(count);
1.142 +
1.143 + TInt length = count * inputArray->Length();
1.144 + TPtr8 inputArrayPtr((TUint8*)&(*inputArray)[0],length, length);
1.145 + aMessage.ReadData2FromClient(inputArrayPtr);
1.146 +
1.147 + iAudioInput->SetAudioInputL(inputArray->Array());
1.148 + CleanupStack::PopAndDestroy(inputArray);//inputArray
1.149 +
1.150 + aMessage.Complete(KErrNone);
1.151 + }
1.152 +
1.153 +
1.154 +// ========================== OTHER EXPORTED FUNCTIONS =========================
1.155 +
1.156 +
1.157 +
1.158 +// End of File