os/mm/devsoundextensions/audiorouting/Output/AudioOutputProxy/src/AudioOutputProxy.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/audiorouting/Output/AudioOutputProxy/src/AudioOutputProxy.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,230 @@
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 output proxy implementation
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +// INCLUDE FILES
1.24 +#include "AudioOutput.h"
1.25 +#include "AudioOutputProxyAO.h"
1.26 +#include "AudioOutputProxy.h"
1.27 +#include "AudioOutputMessageTypes.h"
1.28 +#include <CustomCommandUtility.h>
1.29 +#include "CustomInterfaceUtility.h"
1.30 +
1.31 +
1.32 +
1.33 +
1.34 +// ================= MEMBER FUNCTIONS =======================
1.35 +
1.36 +// C++ default constructor can NOT contain any code, that
1.37 +// might leave.
1.38 +//
1.39 +CAudioOutputProxy::CAudioOutputProxy(TMMFMessageDestinationPckg aMessageHandler,
1.40 + MCustomCommand& aCustomCommand,
1.41 + CCustomInterfaceUtility* aCustomInterfaceUtility) :
1.42 + iCustomCommand(&aCustomCommand),
1.43 + iMessageHandler(aMessageHandler),
1.44 + iCustomInterfaceUtility(aCustomInterfaceUtility)
1.45 + {
1.46 + iOutput = ENoPreference;
1.47 + iDefaultOutput = ENoPreference;
1.48 + iSecureOutput = EFalse;
1.49 + iRegistered = EFalse;
1.50 + }
1.51 +
1.52 +// Two-phased constructor.
1.53 +EXPORT_C CAudioOutputProxy* CAudioOutputProxy::NewL(TMMFMessageDestinationPckg aMessageHandler,
1.54 + MCustomCommand& aCustomCommand,
1.55 + CCustomInterfaceUtility* aCustomInterfaceUtility)
1.56 + {
1.57 + CAudioOutputProxy* self = new(ELeave) CAudioOutputProxy(aMessageHandler,aCustomCommand,aCustomInterfaceUtility);
1.58 + self->ConstructL();
1.59 + return self;
1.60 + }
1.61 +
1.62 +// -----------------------------------------------------------------------------
1.63 +// CAudioOutputProxy::ConstructL
1.64 +// Symbian 2nd phase constructor can leave.
1.65 +// -----------------------------------------------------------------------------
1.66 +//
1.67 +void CAudioOutputProxy::ConstructL()
1.68 + {
1.69 + }
1.70 +
1.71 +// Destructor
1.72 +CAudioOutputProxy::~CAudioOutputProxy()
1.73 + {
1.74 + if (iRegistered != EFalse)
1.75 + {
1.76 + if(iObserver)
1.77 + UnregisterObserver(*iObserver);
1.78 + }
1.79 +
1.80 + if (iCustomCommand)
1.81 + {
1.82 + iCustomCommand->CustomCommandSync(iMessageHandler, EAofDelete, KNullDesC8, KNullDesC8);
1.83 + }
1.84 +
1.85 + if(iAsyncSender)
1.86 + {
1.87 + delete iAsyncSender;
1.88 + iAsyncSender = NULL;
1.89 + }
1.90 +
1.91 + if(iCustomInterfaceUtility)
1.92 + {
1.93 + iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
1.94 + delete iCustomInterfaceUtility;
1.95 + iCustomInterfaceUtility = NULL;
1.96 + }
1.97 + }
1.98 +
1.99 +// ---------------------------------------------------------
1.100 +// CAudioOutput::Uid
1.101 +// ?implementation_description
1.102 +// (other items were commented in a header).
1.103 +// ---------------------------------------------------------
1.104 +//
1.105 +EXPORT_C const TUid CAudioOutputProxy::Uid()
1.106 + {
1.107 + return KUidAudioOutput;
1.108 + }
1.109 +
1.110 +// ---------------------------------------------------------
1.111 +// CAudioOutput::AudioOutput
1.112 +// ?implementation_description
1.113 +// (other items were commented in a header).
1.114 +// ---------------------------------------------------------
1.115 +//
1.116 +CAudioOutput::TAudioOutputPreference CAudioOutputProxy::AudioOutput()
1.117 + {
1.118 +
1.119 + TPckgBuf<TAudioOutputPreference> outPutPckg;
1.120 + TInt error = iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EAofGetAudioOutput, KNullDesC8, KNullDesC8, outPutPckg);
1.121 +
1.122 + if (KErrNone == error)
1.123 + iOutput = outPutPckg();
1.124 + else
1.125 + iOutput = ENoPreference;
1.126 +
1.127 + return iOutput;
1.128 + }
1.129 +// ---------------------------------------------------------
1.130 +// CAudioOutput::DefaultAudioOutput
1.131 +// ?implementation_description
1.132 +// (other items were commented in a header).
1.133 +// ---------------------------------------------------------
1.134 +//
1.135 +CAudioOutput::TAudioOutputPreference CAudioOutputProxy::DefaultAudioOutput()
1.136 + {
1.137 + return iDefaultOutput;
1.138 + }
1.139 +// ---------------------------------------------------------
1.140 +// CAudioOutput::RegisterObserverL
1.141 +// ?implementation_description
1.142 +// (other items were commented in a header).
1.143 +// ---------------------------------------------------------
1.144 +//
1.145 +void CAudioOutputProxy::RegisterObserverL(MAudioOutputObserver& aObserver)
1.146 + {
1.147 + if(iRegistered)
1.148 + {
1.149 + iObserver = &aObserver;
1.150 + iAsyncSender->SetObserver(aObserver);
1.151 + }
1.152 + else
1.153 + {
1.154 + iRegistered = ETrue;
1.155 + iObserver = &aObserver;
1.156 + delete iAsyncSender;
1.157 + iAsyncSender = NULL;
1.158 +
1.159 + iAsyncSender = CAudioOutputProxyAO::NewL(this,aObserver,iCustomCommand);
1.160 + iAsyncSender->SetRegisterFlag(ETrue);
1.161 + iAsyncSender->SendAsyncMessage(iMessageHandler,EAofRegisterObserver);
1.162 + }
1.163 + }
1.164 +
1.165 +// ---------------------------------------------------------
1.166 +// CAudioOutput::SecureOutput
1.167 +// ?implementation_description
1.168 +// (other items were commented in a header).
1.169 +// ---------------------------------------------------------
1.170 +//
1.171 +TBool CAudioOutputProxy::SecureOutput()
1.172 + {
1.173 + return iSecureOutput;
1.174 + }
1.175 +
1.176 +// ---------------------------------------------------------
1.177 +// CAudioOutput::SetAudioOutputL
1.178 +// ?implementation_description
1.179 +// (other items were commented in a header).
1.180 +// ---------------------------------------------------------
1.181 +//
1.182 +void CAudioOutputProxy::SetAudioOutputL(TAudioOutputPreference aAudioOutput)
1.183 + {
1.184 + iOutput = aAudioOutput;
1.185 + TPckgC<TAudioOutputPreference> outputPckg(aAudioOutput);
1.186 + iCustomCommand->CustomCommandSync(iMessageHandler, EAofSetAudioOutput, outputPckg, KNullDesC8);
1.187 + }
1.188 +// ---------------------------------------------------------
1.189 +// CAudioOutput::SetAudioOutputL
1.190 +// ?implementation_description
1.191 +// (other items were commented in a header).
1.192 +// ---------------------------------------------------------
1.193 +//
1.194 +void CAudioOutputProxy::SetSecureOutputL(TBool aSecureOutput)
1.195 + {
1.196 + iSecureOutput = aSecureOutput;
1.197 + TPckgC<TBool> outputPckg(aSecureOutput);
1.198 + TInt err = KErrNone;
1.199 + //ou1cimx1#454515 CAudioOutputConfigurator::SetSecureOutputL() is deprecated
1.200 + err = iCustomCommand->CustomCommandSync(iMessageHandler, EAofSetSecureOutput, outputPckg, KNullDesC8);
1.201 + if(err != KErrNone)
1.202 + {
1.203 + User::Leave(err);
1.204 + }
1.205 +
1.206 + }
1.207 +
1.208 +// ---------------------------------------------------------
1.209 +// CAudioOutput::RegisterObserverL
1.210 +// ?implementation_description
1.211 +// (other items were commented in a header).
1.212 +// ---------------------------------------------------------
1.213 +//
1.214 +void CAudioOutputProxy::UnregisterObserver(MAudioOutputObserver& aObserver)
1.215 + {
1.216 + iRegistered = EFalse;
1.217 + if (iObserver == &aObserver)
1.218 + {
1.219 + if (iAsyncSender)
1.220 + {
1.221 + iAsyncSender->SetRegisterFlag(EFalse);
1.222 + iCustomCommand->CustomCommandSync(iMessageHandler, EAofUnregisterObserver, KNullDesC8, KNullDesC8);
1.223 + iObserver = NULL;
1.224 + }
1.225 + }
1.226 + }
1.227 +
1.228 +
1.229 +// ========================== OTHER EXPORTED FUNCTIONS =========================
1.230 +
1.231 +
1.232 +
1.233 +// End of File