os/mm/devsoundextensions/restrictedaudiooutput/RestrictedAudioOutputProxy/src/RestrictedAudioOutputProxy.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 CRestrictedAudioOutputProxy class.
22 #include <RestrictedAudioOutput.h>
23 #include <RestrictedAudioOutputProxy.h>
24 #include <RestrictedAudioOutputMessageTypes.h>
25 #include <CustomInterfaceUtility.h>
28 // ================= MEMBER FUNCTIONS =======================
30 // C++ default constructor can NOT contain any code, that
33 CRestrictedAudioOutputProxy::CRestrictedAudioOutputProxy(
34 TMMFMessageDestinationPckg aMessageHandler,
35 MCustomCommand& aCustomCommand,
36 CCustomInterfaceUtility* aCustomInterfaceUtility )
37 : iCustomCommand(&aCustomCommand),
38 iMessageHandler(aMessageHandler),
39 iCustomInterfaceUtility(aCustomInterfaceUtility),
46 // Two-phased constructor.
47 EXPORT_C CRestrictedAudioOutputProxy* CRestrictedAudioOutputProxy::NewL(
48 TMMFMessageDestinationPckg aMessageHandler,
49 MCustomCommand& aCustomCommand,
50 CCustomInterfaceUtility* aCustomInterfaceUtility)
54 RDebug::Print(_L("CRestrictedAudioOutputProxy::NewL:\n"));
59 CRestrictedAudioOutputProxy* self = new(ELeave) CRestrictedAudioOutputProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility);
60 CleanupStack::PushL(self);
61 self->ConstructL(); // Call base class ConstructL
62 CleanupStack::Pop(self);
67 EXPORT_C CRestrictedAudioOutputProxy* CRestrictedAudioOutputProxy::NewL(CMMFDevSound& aDevSound)
71 RDebug::Print(_L("CRestrictedAudioOutputProxy::NewL (DevSound):\n"));
74 CRestrictedAudioOutputProxy* audioOutputProxy = (CRestrictedAudioOutputProxy*)aDevSound.CustomInterface(KUidRestrictedAudioOutput);
76 if (audioOutputProxy == NULL)
79 RDebug::Print(_L("No Adaptation Support - leaving"));
81 User::Leave(KErrNotSupported);
84 return audioOutputProxy;
89 CRestrictedAudioOutputProxy::~CRestrictedAudioOutputProxy()
92 RDebug::Print(_L("CRestrictedAudioOutputProxy::~CRestrictedAudioOutputProxy\n"));
96 // Remove the custom interface message handler before we destroy the proxy.
97 if (iCustomInterfaceUtility)
99 iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
101 delete iCustomInterfaceUtility;
105 // ---------------------------------------------------------
106 // CRestrictedAudioOutput::Uid
107 // ?implementation_description
108 // (other items were commented in a header).
109 // ---------------------------------------------------------
111 EXPORT_C const TUid CRestrictedAudioOutputProxy::Uid()
113 return KUidRestrictedAudioOutput;
116 // ---------------------------------------------------------
117 // CRestrictedAudioOutputProxy::Commit
118 // ?implementation_description
119 // (other items were commented in a header).
120 // ---------------------------------------------------------
122 EXPORT_C TInt CRestrictedAudioOutputProxy::Commit()
125 RDebug::Print(_L("CRestrictedAudioOutputProxy::Commit"));
129 TAllowedOutputPreference pref;
132 TInt err = GetAllowedOutputCount(count);
135 RDebug::Print(_L("CRestrictedAudioOutputProxy::Commit: Current array count = %d"), count);
138 for (TInt i=0; i < count;i++)
140 err = GetAllowedOutput(i, pref);
141 TRAP(err,iArray.AppendL(pref));
144 TInt length = iArray.Length() * count;
145 TPtrC8 arrayPtr((const TUint8*)&iArray[0], length);
146 TPckgC<TInt> countPckg(count);
148 iCustomCommand->CustomCommandSync(iMessageHandler, ERaofCommit, countPckg, arrayPtr );