os/mm/devsoundextensions/audiorouting/Input/AudioInputMessageHandler/src/AudioInputMessageHandler.cpp
Update contrib.
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Audio input msg handler implementation
21 #include "AudioInputMessageHandler.h"
22 #include "AudioInputMessageTypes.h"
23 #include "AudioInput.h"
25 // ================= MEMBER FUNCTIONS =======================
27 // C++ default constructor can NOT contain any code, that
30 CAudioInputMessageHandler::CAudioInputMessageHandler(CAudioInput* aAudioInput,
31 CMMFObjectContainer& aContainer) :
32 CMMFObject(KUidAudioInput),
33 iContainer(aContainer)
35 iAudioInput = aAudioInput;
38 // Two-phased constructor.
39 EXPORT_C CAudioInputMessageHandler* CAudioInputMessageHandler::NewL(TAny* aCustomInterface,
40 CMMFObjectContainer& aContainer)
42 CAudioInput* audioInput = (CAudioInput*)aCustomInterface;
43 CAudioInputMessageHandler* self = new (ELeave) CAudioInputMessageHandler(audioInput,
51 CAudioInputMessageHandler::~CAudioInputMessageHandler()
57 // ---------------------------------------------------------
58 // CAudioInput::AudioInput
59 // ?implementation_description
60 // (other items were commented in a header).
61 // ---------------------------------------------------------
63 EXPORT_C TUid CAudioInputMessageHandler::Uid()
65 return KUidAudioInput;
68 // ---------------------------------------------------------
69 // CAudioInput::SetAudioInputL
70 // ?implementation_description
71 // (other items were commented in a header).
72 // ---------------------------------------------------------
74 void CAudioInputMessageHandler::HandleRequest(TMMFMessage& aMessage)
76 ASSERT(aMessage.Destination().InterfaceId() == KUidAudioInput);
77 TRAPD(error,DoHandleRequestL(aMessage));
80 aMessage.Complete(error);
84 // ---------------------------------------------------------
85 // CAudioInput::SetAudioInputL
86 // ?implementation_description
87 // (other items were commented in a header).
88 // ---------------------------------------------------------
90 void CAudioInputMessageHandler::DoHandleRequestL(TMMFMessage& aMessage)
92 switch(aMessage.Function())
101 DoSetInputsL(aMessage);
106 aMessage.Complete(KErrNotSupported);
111 // ---------------------------------------------------------
112 // CAudioInput::SetAudioInputL
113 // ?implementation_description
114 // (other items were commented in a header).
115 // ---------------------------------------------------------
117 void CAudioInputMessageHandler::DoDeleteL(TMMFMessage& aMessage)
119 aMessage.Complete(KErrNone);
120 iContainer.RemoveAndDestroyMMFObject(*this);
123 // ---------------------------------------------------------
124 // CAudioInput::SetAudioInputL
125 // ?implementation_description
126 // (other items were commented in a header).
127 // ---------------------------------------------------------
129 void CAudioInputMessageHandler::DoSetInputsL(TMMFMessage& aMessage)
131 TPckgBuf<TInt> countPckg;
132 aMessage.ReadData1FromClient(countPckg);
133 TInt count = countPckg();
135 CArrayFixFlat<CAudioInput::TAudioInputPreference>* inputArray =
136 new(ELeave) CArrayFixFlat<CAudioInput::TAudioInputPreference>(4);
137 CleanupStack::PushL(inputArray);
138 inputArray->ResizeL(count);
140 TInt length = count * inputArray->Length();
141 TPtr8 inputArrayPtr((TUint8*)&(*inputArray)[0],length, length);
142 aMessage.ReadData2FromClient(inputArrayPtr);
144 iAudioInput->SetAudioInputL(inputArray->Array());
145 CleanupStack::PopAndDestroy(inputArray);//inputArray
147 aMessage.Complete(KErrNone);
151 // ========================== OTHER EXPORTED FUNCTIONS =========================