os/mm/devsoundextensions/restrictedaudiooutput/RestrictedAudioOutputMessageHandler/src/RestrictedAudioOutputMessageHandler.cpp
Update contrib.
2 * Copyright (c) 2007 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: This is the implementation of the CRestrictedAudioOutputMessageHandler class.
21 #include "RestrictedAudioOutput.h"
22 #include "RestrictedAudioOutputMessageHandler.h"
23 #include "RestrictedAudioOutputMessageTypes.h"
26 // ================= MEMBER FUNCTIONS =======================
28 // C++ default constructor can NOT contain any code, that
31 CRestrictedAudioOutputMessageHandler::CRestrictedAudioOutputMessageHandler(CRestrictedAudioOutput* aAudioOutput)
32 : CMMFObject(KUidRestrictedAudioOutput)
34 iAudioOutput = aAudioOutput;
37 // Two-phased constructor.
38 EXPORT_C CRestrictedAudioOutputMessageHandler* CRestrictedAudioOutputMessageHandler::NewL(TAny* aCustomInterface)
40 CRestrictedAudioOutput* audioOutput = (CRestrictedAudioOutput*)aCustomInterface;
41 CRestrictedAudioOutputMessageHandler* self = new (ELeave) CRestrictedAudioOutputMessageHandler(audioOutput);
47 // -----------------------------------------------------------------------------
48 // CRestrictedAudioOutputMessageHandler::ConstructL
49 // Symbian 2nd phase constructor can leave.
50 // -----------------------------------------------------------------------------
52 void CRestrictedAudioOutputMessageHandler::ConstructL()
58 CRestrictedAudioOutputMessageHandler::~CRestrictedAudioOutputMessageHandler()
64 // ---------------------------------------------------------
65 // CRestrictedAudioOutputMessageHandler::AudioOutputL
66 // ?implementation_description
67 // (other items were commented in a header).
68 // ---------------------------------------------------------
70 EXPORT_C TUid CRestrictedAudioOutputMessageHandler::Uid()
72 return KUidRestrictedAudioOutput;
75 // ---------------------------------------------------------
76 // CRestrictedAudioOutputMessageHandler::SetAudioOutputL
77 // ?implementation_description
78 // (other items were commented in a header).
79 // ---------------------------------------------------------
81 void CRestrictedAudioOutputMessageHandler::HandleRequest(TMMFMessage& aMessage)
83 ASSERT(aMessage.Destination().InterfaceId() == KUidRestrictedAudioOutput);
84 TRAPD(error,DoHandleRequestL(aMessage));
87 aMessage.Complete(error);
91 // ---------------------------------------------------------
92 // CRestrictedAudioOutputMessageHandler::DoHandleRequestL
93 // ?implementation_description
94 // (other items were commented in a header).
95 // ---------------------------------------------------------
97 void CRestrictedAudioOutputMessageHandler::DoHandleRequestL(TMMFMessage& aMessage)
100 switch(aMessage.Function())
109 aMessage.Complete(KErrNotSupported);
115 // ---------------------------------------------------------
116 // CRestrictedAudioOutputMessageHandler::DoCommitL
117 // ?implementation_description
118 // (other items were commented in a header).
119 // ---------------------------------------------------------
121 void CRestrictedAudioOutputMessageHandler::DoCommitL(TMMFMessage& aMessage)
124 RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL"));
127 TPckgBuf<TInt> countPckg;
128 aMessage.ReadData1FromClient(countPckg);
129 TInt count = countPckg();
132 RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL Count: %d"),count);
135 CArrayFixFlat<CRestrictedAudioOutput::TAllowedOutputPreference>* outputArray =
136 new(ELeave) CArrayFixFlat<CRestrictedAudioOutput::TAllowedOutputPreference>(4);
137 CleanupStack::PushL(outputArray);
138 outputArray->ResizeL(count);
140 TInt length = count * outputArray->Length();
141 TPtr8 arrayPtr((TUint8*)&(*outputArray)[0],length, length);
142 aMessage.ReadData2FromClient(arrayPtr);
144 CRestrictedAudioOutput::TAllowedOutputPreference pref;
146 TInt err = iAudioOutput->Reset();
148 for (TInt i = 0; i < count; i++)
150 pref = (outputArray->Array())[i];
152 RDebug::Print(_L("DoCommitL Calling Append for: %d"),pref);
154 TInt err = iAudioOutput->AppendAllowedOutput(pref);
158 RDebug::Print(_L("CRestrictedAudioOutputMessageHandler::DoCommitL Calling Commit..."));
161 iAudioOutput->Commit();
162 CleanupStack::PopAndDestroy(); //outputArray
164 aMessage.Complete(KErrNone);